Merge pull request #8 from helium/madninja/upgrade_enacl

Upgrade enacl to 1.1.1
This commit is contained in:
Hans Svensson 2020-09-24 21:59:23 +02:00 committed by GitHub
commit 3819ba5c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{erl_opts, [debug_info]}.
{plugins, [rebar3_hex]}.
{deps, [{enacl, "0.17.2"}]}.
{deps, [{enacl, "1.1.1"}]}.
{profiles, [{test, [{deps, [{jsx, {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}}]}]}
]}.

View File

@ -1,6 +1,6 @@
{"1.1.0",
[{<<"enacl">>,{pkg,<<"enacl">>,<<"0.17.2">>},0}]}.
[{<<"enacl">>,{pkg,<<"enacl">>,<<"1.1.1">>},0}]}.
[
{pkg_hash,[
{<<"enacl">>, <<"4AD59142943E72D72C56E33C30DEDEF28ADD8EBEE79C51033562B0CB4B93EDE0">>}]}
{<<"enacl">>, <<"F65DC64D9BFF2D8A534CB77AEF14DA5E7A2FA148987D87856F79A4745C9C2627">>}]}
].

View File

@ -64,7 +64,8 @@ rekey(Cipher, K) ->
Ad :: binary(), PlainText :: binary()) ->
binary() | {error, term()}.
encrypt('ChaChaPoly', K, N, Ad, PlainText) ->
enacl:aead_chacha20poly1305_encrypt(K, N, Ad, PlainText);
Nonce = <<0:32, N:64/little-unsigned-integer>>,
enacl:aead_chacha20poly1305_ietf_encrypt(PlainText, Ad, Nonce, K);
encrypt('AESGCM', K, N, Ad, PlainText) ->
Nonce = <<0:32, N:64>>,
{CipherText, CipherTag} = crypto:block_encrypt(aes_gcm, K, Nonce, {Ad, PlainText}),
@ -75,7 +76,8 @@ encrypt('AESGCM', K, N, Ad, PlainText) ->
AD :: binary(), CipherText :: binary()) ->
binary() | {error, term()}.
decrypt('ChaChaPoly', K, N, Ad, CipherText) ->
enacl:aead_chacha20poly1305_decrypt(K, N, Ad, CipherText);
Nonce = <<0:32, N:64/little-unsigned-integer>>,
enacl:aead_chacha20poly1305_ietf_decrypt(CipherText, Ad, Nonce, K);
decrypt('AESGCM', K, N, Ad, CipherText0) ->
CTLen = byte_size(CipherText0) - ?MAC_LEN,
<<CipherText:CTLen/binary, MAC:?MAC_LEN/binary>> = CipherText0,
@ -88,7 +90,7 @@ decrypt('AESGCM', K, N, Ad, CipherText0) ->
-spec hash(Hash :: enoise_sym_state:noise_hash(), Data :: binary()) -> binary().
hash(blake2b, Data) ->
{ok, Hash} = enacl:generichash(64, Data), Hash;
Hash = enacl:generichash(64, Data), Hash;
hash(sha256, Data) ->
crypto:hash(sha256, Data);
hash(sha512, Data) ->