From d73124a025002061170f2c61057d8f6f9d72ae3b Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Mon, 4 Apr 2016 10:40:23 +0200 Subject: [PATCH] Make the test of truncated chacha20poly1305 ciphers less deterministic --- test/default/aead_chacha20poly1305.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/default/aead_chacha20poly1305.c b/test/default/aead_chacha20poly1305.c index f8e14e11..7725d656 100644 --- a/test/default/aead_chacha20poly1305.c +++ b/test/default/aead_chacha20poly1305.c @@ -111,8 +111,9 @@ tv(void) } m2len = 1; if (crypto_aead_chacha20poly1305_decrypt( - m2, &m2len, NULL, c, crypto_aead_chacha20poly1305_ABYTES / 2, NULL, - 0U, nonce, firstkey) != -1) { + m2, &m2len, NULL, c, + randombytes_uniform(crypto_aead_chacha20poly1305_ABYTES), + NULL, 0U, nonce, firstkey) != -1) { printf("crypto_aead_chacha20poly1305_decrypt() worked with a short " "ciphertext\n"); } @@ -281,8 +282,9 @@ tv_ietf(void) } m2len = 1; if (crypto_aead_chacha20poly1305_ietf_decrypt( - m2, &m2len, NULL, c, crypto_aead_chacha20poly1305_ietf_ABYTES / 2, NULL, - 0U, nonce, firstkey) != -1) { + m2, &m2len, NULL, c, + randombytes_uniform(crypto_aead_chacha20poly1305_ietf_ABYTES), + NULL, 0U, nonce, firstkey) != -1) { printf("crypto_aead_chacha20poly1305_ietf_decrypt() worked with a short " "ciphertext\n"); } @@ -314,7 +316,7 @@ tv_ietf(void) printf("\n"); if (crypto_aead_chacha20poly1305_ietf_decrypt(c, &m2len, NULL, c, CLEN, - NULL, 0U, nonce, firstkey) != 0) { + NULL, 0U, nonce, firstkey) != 0) { printf("crypto_aead_chacha20poly1305_ietf_decrypt() failed (adlen=0)\n"); } if (m2len != MLEN) {