From 2041cec2e842220387ae194e72eba84172f5cf5a Mon Sep 17 00:00:00 2001 From: Jesper Louis Andersen Date: Mon, 3 Feb 2020 14:58:52 +0100 Subject: [PATCH] Update the eqc suite. Parameter order in chacha20poly1305_ietf changed. Fix this in the EQC tests. While here, also do the Nonce changes. --- eqc_test/enacl_eqc.erl | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/eqc_test/enacl_eqc.erl b/eqc_test/enacl_eqc.erl index b0f4859..66781bb 100644 --- a/eqc_test/enacl_eqc.erl +++ b/eqc_test/enacl_eqc.erl @@ -525,20 +525,22 @@ prop_secretbox_failure_integrity() -> %% ------------------------------------------------------------ %% * aead_chacha20poly1305_encrypt/4, %% * aead_chacha20poly1305_decrypt/4, -prop_aead_chacha20poly1305() -> +prop_aead_chacha20poly1305_ietf() -> + NPubBytes = enacl:aead_chacha20poly1305_ietf_NPUBBYTES(), ?FORALL({Key, Msg, AD, Nonce}, - {binary(32), binary(), ?LET(ADBytes, choose(0,16), binary(ADBytes)), largeint()}, + {binary(32), binary(), ?LET(ADBytes, choose(0,16), binary(ADBytes)), binary(NPubBytes)}, begin - EncryptMsg = enacl:aead_chacha20poly1305_encrypt(Key, Nonce, AD, Msg), - equals(enacl:aead_chacha20poly1305_decrypt(Key, Nonce, AD, EncryptMsg), Msg) + EncryptMsg = enacl:aead_chacha20poly1305_ietf_encrypt(Msg, AD, Nonce, Key), + equals(enacl:aead_chacha20poly1305_ietf_decrypt(EncryptMsg, AD, Nonce, Key), Msg) end). -prop_aead_chacha20poly1305_fail() -> +prop_aead_chacha20poly1305_ietf_fail() -> + NPubBytes = enacl:aead_chacha20poly1305_ietf_NPUBBYTES(), ?FORALL({Key, Msg, AD, Nonce}, - {binary(32), binary(), ?LET(ADBytes, choose(0,16), binary(ADBytes)), largeint()}, + {binary(32), binary(), ?LET(ADBytes, choose(0,16), binary(ADBytes)), binary(NPubBytes)}, begin - EncryptMsg = enacl:aead_chacha20poly1305_encrypt(Key, Nonce, AD, Msg), - case enacl:aead_chacha20poly1305_decrypt(Key, Nonce, AD, <<0:8, EncryptMsg/binary>>) of + EncryptMsg = enacl:aead_chacha20poly1305_ietf_encrypt(Msg, AD, Nonce, Key), + case enacl:aead_chacha20poly1305_ietf_decrypt(<<0:8, EncryptMsg/binary>>, AD, Nonce, Key) of {error, _} -> true; _ -> false end