1
0
forked from QPQ-AG/enoise

Revert "Update enacl dep and fix some minor details (#1)"

This reverts commit 479ec70870.
This commit is contained in:
Ulf Wiger
2025-03-29 20:57:45 +01:00
parent 479ec70870
commit 91916908a0
5 changed files with 16 additions and 9 deletions
+6 -2
View File
@@ -54,8 +54,12 @@ set_nonce(CState = #noise_cs{}, Nonce) ->
encrypt_with_ad(CState = #noise_cs{ k = empty }, _AD, PlainText) ->
{ok, CState, PlainText};
encrypt_with_ad(CState = #noise_cs{ k = K, n = N, cipher = Cipher }, AD, PlainText) ->
Encrypted = enoise_crypto:encrypt(Cipher, K, N, AD, PlainText),
{ok, CState#noise_cs{ n = N+1 }, Encrypted}.
case enoise_crypto:encrypt(Cipher, K, N, AD, PlainText) of
Encrypted when is_binary(Encrypted) ->
{ok, CState#noise_cs{ n = N+1 }, Encrypted};
Err = {error, _} ->
Err
end.
-spec decrypt_with_ad(CState :: state(), AD :: binary(), CipherText :: binary()) ->
{ok, state(), binary()} | {error, term()}.