Upgrade enacl to 1.1.1
This commit is contained in:
parent
1e6ee6703f
commit
a3e803fc1a
@ -1,6 +1,6 @@
|
|||||||
{erl_opts, [debug_info]}.
|
{erl_opts, [debug_info]}.
|
||||||
{plugins, [rebar3_hex]}.
|
{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"}}}]}]}
|
{profiles, [{test, [{deps, [{jsx, {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}}]}]}
|
||||||
]}.
|
]}.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{"1.1.0",
|
{"1.1.0",
|
||||||
[{<<"enacl">>,{pkg,<<"enacl">>,<<"0.17.2">>},0}]}.
|
[{<<"enacl">>,{pkg,<<"enacl">>,<<"1.1.1">>},0}]}.
|
||||||
[
|
[
|
||||||
{pkg_hash,[
|
{pkg_hash,[
|
||||||
{<<"enacl">>, <<"4AD59142943E72D72C56E33C30DEDEF28ADD8EBEE79C51033562B0CB4B93EDE0">>}]}
|
{<<"enacl">>, <<"F65DC64D9BFF2D8A534CB77AEF14DA5E7A2FA148987D87856F79A4745C9C2627">>}]}
|
||||||
].
|
].
|
||||||
|
@ -64,7 +64,8 @@ rekey(Cipher, K) ->
|
|||||||
Ad :: binary(), PlainText :: binary()) ->
|
Ad :: binary(), PlainText :: binary()) ->
|
||||||
binary() | {error, term()}.
|
binary() | {error, term()}.
|
||||||
encrypt('ChaChaPoly', K, N, Ad, PlainText) ->
|
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) ->
|
encrypt('AESGCM', K, N, Ad, PlainText) ->
|
||||||
Nonce = <<0:32, N:64>>,
|
Nonce = <<0:32, N:64>>,
|
||||||
{CipherText, CipherTag} = crypto:block_encrypt(aes_gcm, K, Nonce, {Ad, PlainText}),
|
{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()) ->
|
AD :: binary(), CipherText :: binary()) ->
|
||||||
binary() | {error, term()}.
|
binary() | {error, term()}.
|
||||||
decrypt('ChaChaPoly', K, N, Ad, CipherText) ->
|
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) ->
|
decrypt('AESGCM', K, N, Ad, CipherText0) ->
|
||||||
CTLen = byte_size(CipherText0) - ?MAC_LEN,
|
CTLen = byte_size(CipherText0) - ?MAC_LEN,
|
||||||
<<CipherText:CTLen/binary, MAC:?MAC_LEN/binary>> = CipherText0,
|
<<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().
|
-spec hash(Hash :: enoise_sym_state:noise_hash(), Data :: binary()) -> binary().
|
||||||
hash(blake2b, Data) ->
|
hash(blake2b, Data) ->
|
||||||
{ok, Hash} = enacl:generichash(64, Data), Hash;
|
Hash = enacl:generichash(64, Data), Hash;
|
||||||
hash(sha256, Data) ->
|
hash(sha256, Data) ->
|
||||||
crypto:hash(sha256, Data);
|
crypto:hash(sha256, Data);
|
||||||
hash(sha512, Data) ->
|
hash(sha512, Data) ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user