Update enacl dep and fix some minor details #1
@ -1,9 +1,6 @@
|
|||||||
{erl_opts, [debug_info]}.
|
{erl_opts, [debug_info]}.
|
||||||
{plugins, [rebar3_hex]}.
|
{plugins, [rebar3_hex]}.
|
||||||
{deps, [{enacl, "1.1.1"}]}.
|
{deps, [{enacl, {git, "https://git.qpq.swiss/QPQ-AG/enacl.git", {ref, "4eb7ec70"}}}]}.
|
||||||
|
|
||||||
{profiles, [{test, [{deps, [{jsx, {git, "https://github.com/talentdeficit/jsx.git", {tag, "2.8.0"}}}]}]}
|
|
||||||
]}.
|
|
||||||
|
|
||||||
{xref_checks, [undefined_function_calls, undefined_functions,
|
{xref_checks, [undefined_function_calls, undefined_functions,
|
||||||
locals_not_used,
|
locals_not_used,
|
||||||
|
10
rebar.lock
10
rebar.lock
@ -1,6 +1,4 @@
|
|||||||
{"1.2.0",
|
[{<<"enacl">>,
|
||||||
[{<<"enacl">>,{pkg,<<"enacl">>,<<"1.1.1">>},0}]}.
|
{git,"https://git.qpq.swiss/QPQ-AG/enacl.git",
|
||||||
[
|
{ref,"4eb7ec70084ba7c87b1af8797c4c4e90c84f95a2"}},
|
||||||
{pkg_hash,[
|
0}].
|
||||||
{<<"enacl">>, <<"F65DC64D9BFF2D8A534CB77AEF14DA5E7A2FA148987D87856F79A4745C9C2627">>}]}
|
|
||||||
].
|
|
||||||
|
@ -54,12 +54,8 @@ set_nonce(CState = #noise_cs{}, Nonce) ->
|
|||||||
encrypt_with_ad(CState = #noise_cs{ k = empty }, _AD, PlainText) ->
|
encrypt_with_ad(CState = #noise_cs{ k = empty }, _AD, PlainText) ->
|
||||||
{ok, CState, PlainText};
|
{ok, CState, PlainText};
|
||||||
encrypt_with_ad(CState = #noise_cs{ k = K, n = N, cipher = Cipher }, AD, PlainText) ->
|
encrypt_with_ad(CState = #noise_cs{ k = K, n = N, cipher = Cipher }, AD, PlainText) ->
|
||||||
case enoise_crypto:encrypt(Cipher, K, N, AD, PlainText) of
|
Encrypted = enoise_crypto:encrypt(Cipher, K, N, AD, PlainText),
|
||||||
Encrypted when is_binary(Encrypted) ->
|
{ok, CState#noise_cs{ n = N+1 }, Encrypted}.
|
||||||
{ok, CState#noise_cs{ n = N+1 }, Encrypted};
|
|
||||||
Err = {error, _} ->
|
|
||||||
Err
|
|
||||||
end.
|
|
||||||
|
|
||||||
-spec decrypt_with_ad(CState :: state(), AD :: binary(), CipherText :: binary()) ->
|
-spec decrypt_with_ad(CState :: state(), AD :: binary(), CipherText :: binary()) ->
|
||||||
{ok, state(), binary()} | {error, term()}.
|
{ok, state(), binary()} | {error, term()}.
|
||||||
|
@ -65,8 +65,7 @@ rekey(Cipher, K) ->
|
|||||||
|
|
||||||
-spec encrypt(Cipher :: enoise_cipher_state:noise_cipher(),
|
-spec encrypt(Cipher :: enoise_cipher_state:noise_cipher(),
|
||||||
Key :: binary(), Nonce :: non_neg_integer(),
|
Key :: binary(), Nonce :: non_neg_integer(),
|
||||||
Ad :: binary(), PlainText :: binary()) ->
|
Ad :: binary(), PlainText :: binary()) -> binary().
|
||||||
binary() | {error, term()}.
|
|
||||||
encrypt('ChaChaPoly', K, N, Ad, PlainText) ->
|
encrypt('ChaChaPoly', K, N, Ad, PlainText) ->
|
||||||
Nonce = <<0:32, N:64/little-unsigned-integer>>,
|
Nonce = <<0:32, N:64/little-unsigned-integer>>,
|
||||||
enacl:aead_chacha20poly1305_ietf_encrypt(PlainText, Ad, Nonce, K);
|
enacl:aead_chacha20poly1305_ietf_encrypt(PlainText, Ad, Nonce, K);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user