From dbaa94fe27d99a45bec00344b1485a152a39db34 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 1 Dec 2017 16:32:25 +0100 Subject: [PATCH] Casts --- test/default/metamorphic.c | 16 ++++++++-------- test/default/xchacha20.c | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/default/metamorphic.c b/test/default/metamorphic.c index 4e9b9be0..21932fb8 100644 --- a/test/default/metamorphic.c +++ b/test/default/metamorphic.c @@ -35,8 +35,8 @@ mm_generichash(void) randombytes_buf(m, mlen); crypto_generichash_init(&st, k, klen, hlen); - l1 = randombytes_uniform(mlen); - l2 = randombytes_uniform(mlen - l1); + l1 = randombytes_uniform((uint32_t) mlen); + l2 = randombytes_uniform((uint32_t) mlen - l1); crypto_generichash_update(&st, m, l1); crypto_generichash_update(&st, m + l1, l2); crypto_generichash_update(&st, m + l1 + l2, mlen - l1 - l2); @@ -75,8 +75,8 @@ mm_onetimeauth(void) randombytes_buf(m, mlen); crypto_onetimeauth_init(&st, k); - l1 = randombytes_uniform(mlen); - l2 = randombytes_uniform(mlen - l1); + l1 = randombytes_uniform((uint32_t) mlen); + l2 = randombytes_uniform((uint32_t) mlen - l1); crypto_onetimeauth_update(&st, m, l1); crypto_onetimeauth_update(&st, m + l1, l2); crypto_onetimeauth_update(&st, m + l1 + l2, mlen - l1 - l2); @@ -115,8 +115,8 @@ mm_hmacsha256(void) randombytes_buf(m, mlen); crypto_auth_hmacsha256_init(&st, k, crypto_auth_hmacsha256_KEYBYTES); - l1 = randombytes_uniform(mlen); - l2 = randombytes_uniform(mlen - l1); + l1 = randombytes_uniform((uint32_t) mlen); + l2 = randombytes_uniform((uint32_t) mlen - l1); crypto_auth_hmacsha256_update(&st, m, l1); crypto_auth_hmacsha256_update(&st, m + l1, l2); crypto_auth_hmacsha256_update(&st, m + l1 + l2, mlen - l1 - l2); @@ -155,8 +155,8 @@ mm_hmacsha512(void) randombytes_buf(m, mlen); crypto_auth_hmacsha512_init(&st, k, crypto_auth_hmacsha512_KEYBYTES); - l1 = randombytes_uniform(mlen); - l2 = randombytes_uniform(mlen - l1); + l1 = randombytes_uniform((uint32_t) mlen); + l2 = randombytes_uniform((uint32_t) mlen - l1); crypto_auth_hmacsha512_update(&st, m, l1); crypto_auth_hmacsha512_update(&st, m + l1, l2); crypto_auth_hmacsha512_update(&st, m + l1 + l2, mlen - l1 - l2); diff --git a/test/default/xchacha20.c b/test/default/xchacha20.c index a5719c8b..5d75c6cb 100644 --- a/test/default/xchacha20.c +++ b/test/default/xchacha20.c @@ -244,7 +244,7 @@ tv_secretbox_xchacha20poly1305(void) assert(crypto_secretbox_xchacha20poly1305_easy(out2, m, m_len, nonce, key) == 0); assert(memcmp(out, out2, crypto_secretbox_xchacha20poly1305_MACBYTES + m_len) == 0); - n = randombytes_uniform(crypto_secretbox_xchacha20poly1305_MACBYTES + m_len); + n = randombytes_uniform(crypto_secretbox_xchacha20poly1305_MACBYTES + (uint32_t) m_len); assert(crypto_secretbox_xchacha20poly1305_open_easy (out2, out2, crypto_secretbox_xchacha20poly1305_MACBYTES - 1, nonce, key) == -1);