diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2020-12-05 10:50:20 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2020-12-06 00:48:09 +0000 |
commit | 281cf995547f7683a9e9186bc6384a9fb6035d10 (patch) | |
tree | d969a453d0d7c59c0f9b6af66f4bfb3f70caed2d /src/bench/chacha_poly_aead.cpp | |
parent | f35e4d906fee907f28ac5d8f32d4948e6b7b14c3 (diff) |
Do not run functions with necessary side-effects in assert()
Diffstat (limited to 'src/bench/chacha_poly_aead.cpp')
-rw-r--r-- | src/bench/chacha_poly_aead.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/bench/chacha_poly_aead.cpp b/src/bench/chacha_poly_aead.cpp index 3b1d3e697a..e994279a4d 100644 --- a/src/bench/chacha_poly_aead.cpp +++ b/src/bench/chacha_poly_aead.cpp @@ -31,12 +31,15 @@ static void CHACHA20_POLY1305_AEAD(benchmark::Bench& bench, size_t buffersize, b uint32_t len = 0; bench.batch(buffersize).unit("byte").run([&] { // encrypt or decrypt the buffer with a static key - assert(aead.Crypt(seqnr_payload, seqnr_aad, aad_pos, out.data(), out.size(), in.data(), buffersize, true)); + const bool crypt_ok_1 = aead.Crypt(seqnr_payload, seqnr_aad, aad_pos, out.data(), out.size(), in.data(), buffersize, true); + assert(crypt_ok_1); if (include_decryption) { // if we decrypt, include the GetLength - assert(aead.GetLength(&len, seqnr_aad, aad_pos, in.data())); - assert(aead.Crypt(seqnr_payload, seqnr_aad, aad_pos, out.data(), out.size(), in.data(), buffersize, true)); + const bool get_length_ok = aead.GetLength(&len, seqnr_aad, aad_pos, in.data()); + assert(get_length_ok); + const bool crypt_ok_2 = aead.Crypt(seqnr_payload, seqnr_aad, aad_pos, out.data(), out.size(), in.data(), buffersize, true); + assert(crypt_ok_2); } // increase main sequence number |