Streamline naming

More changes before 1.0 with a
more direct naming scheme.
This commit is contained in:
Jesper Louis Andersen
2020-02-06 13:57:07 +01:00
parent 014d50cf47
commit cceef4530a
5 changed files with 138 additions and 121 deletions
+23 -23
View File
@@ -20,7 +20,7 @@ test() ->
randombytes() ->
randombytes(100*1000).
randombytes(0) -> ok;
randombytes(N) ->
enacl:randombytes(1024),
@@ -29,7 +29,7 @@ randombytes(N) ->
hash() ->
B = binary:copy(<<0>>, 4096),
hash(B, 10*1000).
hash(_B, 0) -> ok;
hash(B, N) ->
enacl:hash(B),
@@ -37,7 +37,7 @@ hash(B, N) ->
box_keypair() ->
box_keypair(10*1000).
box_keypair(0) -> ok;
box_keypair(N) ->
enacl:box_keypair(),
@@ -47,9 +47,9 @@ box() ->
#{ public := PK1} = enacl:box_keypair(),
#{ secret := SK2} = enacl:box_keypair(),
B = binary:copy(<<0>>, 1),
Nonce = binary:copy(<<0>>, enacl:box_nonce_size()),
Nonce = binary:copy(<<0>>, enacl:box_NONCEBYTES()()),
box(B, Nonce, PK1, SK2, 10*1000).
box(_B, _Nonce, _PK1, _SK2, 0) -> ok;
box(B, Nonce, PK1, SK2, N) ->
enacl:box(B, Nonce, PK1, SK2),
@@ -62,15 +62,15 @@ box_before_after() ->
box_beforenm(PK1, SK2, 10*1000),
R = enacl:box_beforenm(PK1, SK2),
B = binary:copy(<<0>>, 8192),
Nonce = binary:copy(<<0>>, enacl:box_nonce_size()),
Nonce = binary:copy(<<0>>, enacl:box_NONCEBYTES()()),
box_afternm(B, Nonce, R, 10*1000),
ok.
box_beforenm(_PK, _SK, 0) -> ok;
box_beforenm(PK, SK, N) ->
enacl:box_beforenm(PK, SK),
box_beforenm(PK, SK, N-1).
box_afternm(_Msg, _Nonce, _Key, 0) -> ok;
box_afternm(Msg, Nonce, Key, N) ->
enacl:box_afternm(Msg, Nonce, Key),
@@ -78,7 +78,7 @@ box_afternm(Msg, Nonce, Key, N) ->
sign_keypair() ->
sign_keypair(10*1000).
sign_keypair(0) -> ok;
sign_keypair(N) ->
enacl:sign_keypair(),
@@ -91,7 +91,7 @@ sign() ->
Msg = binary:copy(<<0>>, 1024),
#{ secret := SK } = enacl:sign_keypair(),
sign(Msg, SK, 10*1000).
sign(_Msg, _SK, 0) -> ok;
sign(Msg, SK, N) ->
enacl:sign(Msg, SK),
@@ -100,10 +100,10 @@ sign(Msg, SK, N) ->
secretbox() ->
Msg = binary:copy(<<0>>, 8192),
Nonce = binary:copy(<<0>>, enacl:secretbox_nonce_size()),
Key = binary:copy(<<0>>, enacl:secretbox_key_size()),
Nonce = binary:copy(<<0>>, enacl:secretbox_NONCEBYTES()()),
Key = binary:copy(<<0>>, enacl:secretbox_KEYBYTES()),
secretbox(Msg, Nonce, Key, 10*1000).
secretbox(_Msg, _Nonce, _Key, 0) -> ok;
secretbox(Msg, Nonce, Key, N) ->
enacl:secretbox(Msg, Nonce, Key),
@@ -111,8 +111,8 @@ secretbox(Msg, Nonce, Key, N) ->
stream() ->
stream(16384, binary:copy(<<0>>, enacl:stream_nonce_size()), binary:copy(<<0>>, enacl:stream_key_size()), 10*1000).
stream(16384, binary:copy(<<0>>, enacl:stream_NONCEBYTES()), binary:copy(<<0>>, enacl:stream_KEYBYTES()), 10*1000).
stream(_L, _Nonce, _K, 0) -> ok;
stream(L, Nonce, K, N) ->
enacl:stream(L, Nonce, K),
@@ -120,31 +120,31 @@ stream(L, Nonce, K, N) ->
auth() ->
Msg = binary:copy(<<0>>, 4096),
Key = binary:copy(<<0>>, enacl:auth_key_size()),
Key = binary:copy(<<0>>, enacl:auth_KEYBYTES()),
auth(Msg, Key, 10*1000).
auth(_Msg, _Key, 0) -> ok;
auth(Msg, Key, N) ->
enacl:auth(Msg, Key),
auth(Msg, Key, N-1).
onetime_auth() ->
Msg = binary:copy(<<0>>, 16384),
Key = binary:copy(<<0>>, enacl:onetime_auth_key_size()),
Key = binary:copy(<<0>>, enacl:onetime_auth_KEYBYTES()),
onetime_auth(Msg, Key, 10*1000).
onetime_auth(_Msg, _Key, 0) -> ok;
onetime_auth(Msg, Key, N) ->
enacl:onetime_auth(Msg, Key),
onetime_auth(Msg, Key, N-1).
scalarmult() ->
Secret = binary:copy(<<0>>, 32),
BasePoint = binary:copy(<<1>>, 32),
scalarmult(Secret, BasePoint, 10*1000).
scalarmult(_S, _B, 0) -> ok;
scalarmult(S, B, N) ->
enacl:curve25519_scalarmult(S, B),
scalarmult(S, B, N-1).