diff --git a/rebar.config b/rebar.config index 79dcd42..4407b81 100644 --- a/rebar.config +++ b/rebar.config @@ -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"}}}]}]} ]}. diff --git a/rebar.lock b/rebar.lock index cedfb79..72b4a45 100644 --- a/rebar.lock +++ b/rebar.lock @@ -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">>}]} ]. diff --git a/src/enoise_crypto.erl b/src/enoise_crypto.erl index 92b52d9..8789310 100644 --- a/src/enoise_crypto.erl +++ b/src/enoise_crypto.erl @@ -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, <> = 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) ->