Write test cases for the streaming API.

This commit is contained in:
Jesper Louis Andersen
2014-11-26 14:24:14 +01:00
parent 6354ea4f69
commit 6a707aef57
2 changed files with 48 additions and 1 deletions
+12 -1
View File
@@ -31,9 +31,13 @@
secretbox/3,
secretbox_open/3,
secretbox_nonce_size/0,
secretbox_key_size/0
secretbox_key_size/0,
stream/3,
stream_xor/3
]).
%% Low-level functions
-export([
hash/1,
verify_16/2,
@@ -145,6 +149,13 @@ secretbox_nonce_size() ->
secretbox_key_size() ->
enacl_nif:crypto_secretbox_KEYBYTES().
stream(Len, Nonce, Key) when is_integer(Len), Len >= 0 ->
enacl_nif:crypto_stream(Len, Nonce, Key);
stream(_, _, _) -> error(badarg).
stream_xor(Msg, Nonce, Key) ->
enacl_nif:crypto_stream_xor(Msg, Nonce, Key).
%% Helpers
p_zerobytes() ->
binary:copy(<<0>>, enacl_nif:crypto_box_ZEROBYTES()).