Simple secretstream CT test case
This commit is contained in:
parent
8361450745
commit
ec3af40ef8
@ -44,7 +44,8 @@ groups() ->
|
|||||||
aead_chacha20poly1305_ietf,
|
aead_chacha20poly1305_ietf,
|
||||||
pwhash,
|
pwhash,
|
||||||
sign,
|
sign,
|
||||||
kx]},
|
kx,
|
||||||
|
secretstream]},
|
||||||
|
|
||||||
[Neg, Pos].
|
[Neg, Pos].
|
||||||
|
|
||||||
@ -162,3 +163,23 @@ kx(_Config) ->
|
|||||||
CTX = SRX,
|
CTX = SRX,
|
||||||
STX = CRX,
|
STX = CRX,
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
secretstream(_Config) ->
|
||||||
|
Part1 = <<"Arbitrary data to encrypt">>,
|
||||||
|
Part2 = <<"split into">>,
|
||||||
|
Part3 = <<"three messages">>,
|
||||||
|
|
||||||
|
Key = enacl:secretstream_xchacha20poly1305_keygen(),
|
||||||
|
|
||||||
|
%% Encrypt
|
||||||
|
{Header, State} = enacl:secretstream_xchacha20poly1305_init_push(Key),
|
||||||
|
Block1 = enacl:secretstream_xchacha20poly1305_push(State, Part1, <<"AD1">>, message),
|
||||||
|
Block2 = enacl:secretstream_xchacha20poly1305_push(State, Part2, <<>>, message),
|
||||||
|
Block3 = enacl:secretstream_xchacha20poly1305_push(State, Part3, <<"AD3">>, final),
|
||||||
|
|
||||||
|
%% Decrypt
|
||||||
|
DState = enacl:secretstream_xchacha20poly1305_init_pull(Header, Key),
|
||||||
|
{Part1, message} = enacl:secretstream_xchacha20poly1305_pull(DState, Block1, <<"AD1">>),
|
||||||
|
{Part2, message} = enacl:secretstream_xchacha20poly1305_pull(DState, Block2, <<>>),
|
||||||
|
{Part3, final} = enacl:secretstream_xchacha20poly1305_pull(DState, Block3, <<"AD3">>),
|
||||||
|
ok.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user