diff options
author | stratospher <44024636+stratospher@users.noreply.github.com> | 2023-08-13 11:55:46 +0530 |
---|---|---|
committer | stratospher <44024636+stratospher@users.noreply.github.com> | 2023-08-14 09:03:21 +0530 |
commit | d22d5d925c000bf25ad2410ca66c4c21eea75004 (patch) | |
tree | 5e4e9e2f0f5e808dcb5175271b8797e9aa8dce94 /src/test/crypto_tests.cpp | |
parent | b2ec0326fd76e64a6d0d7e4745506b29f60d0be5 (diff) | |
download | bitcoin-d22d5d925c000bf25ad2410ca66c4c21eea75004.tar.xz |
crypto: BIP324 ciphersuite follow-up
follow-up to #28008.
* move `dummy_tag` variable in FSChaCha20Poly1305 crypto_tests
outside of the loop to be reused every time
* use easy to read `cipher.last()` in `AEADChaCha20Poly1305::Decrypt()`
* comment for initiator in `BIP324Cipher::Initialize()`
* systematically damage ciphertext with bit positions in bip324_tests
* use 4095 max bytes for aad in bip324 fuzz test
Diffstat (limited to 'src/test/crypto_tests.cpp')
-rw-r--r-- | src/test/crypto_tests.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/test/crypto_tests.cpp b/src/test/crypto_tests.cpp index 6663c914a9..6fbe74a680 100644 --- a/src/test/crypto_tests.cpp +++ b/src/test/crypto_tests.cpp @@ -300,11 +300,11 @@ static void TestFSChaCha20Poly1305(const std::string& plain_hex, const std::stri for (int it = 0; it < 10; ++it) { // During it==0 we use the single-plain Encrypt/Decrypt; others use a split at prefix. size_t prefix = it ? InsecureRandRange(plain.size() + 1) : plain.size(); + std::byte dummy_tag[FSChaCha20Poly1305::EXPANSION] = {{}}; // Do msg_idx dummy encryptions to seek to the correct packet. FSChaCha20Poly1305 enc_aead{key, 224}; for (uint64_t i = 0; i < msg_idx; ++i) { - std::byte dummy_tag[FSChaCha20Poly1305::EXPANSION] = {{}}; enc_aead.Encrypt(Span{dummy_tag}.first(0), Span{dummy_tag}.first(0), dummy_tag); } @@ -319,7 +319,6 @@ static void TestFSChaCha20Poly1305(const std::string& plain_hex, const std::stri // Do msg_idx dummy decryptions to seek to the correct packet. FSChaCha20Poly1305 dec_aead{key, 224}; for (uint64_t i = 0; i < msg_idx; ++i) { - std::byte dummy_tag[FSChaCha20Poly1305::EXPANSION] = {{}}; dec_aead.Decrypt(dummy_tag, Span{dummy_tag}.first(0), Span{dummy_tag}.first(0)); } |