From d311731bada832546c0971995818de528198f97c Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 20 Nov 2014 12:00:37 -0800 Subject: [PATCH] Revert "Fix integer narrowing warnings in tests." This reverts commit 173ad74d3ea137d27f351861b2fc977ee0a3c413. --- test/default/box_easy2.c | 4 ++-- test/default/generichash.c | 2 +- test/default/generichash2.c | 2 +- test/default/generichash3.c | 2 +- test/default/pwhash.c | 7 +++++-- test/default/secretbox_easy2.c | 4 ++-- test/default/shorthash.c | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/test/default/box_easy2.c b/test/default/box_easy2.c index 2d5bf998..9feea81c 100644 --- a/test/default/box_easy2.c +++ b/test/default/box_easy2.c @@ -14,12 +14,12 @@ unsigned char mac[crypto_box_MACBYTES]; int main(void) { - uint32_t mlen; + unsigned long long mlen; unsigned long long i; crypto_box_keypair(alicepk, alicesk); crypto_box_keypair(bobpk, bobsk); - mlen = randombytes_uniform((uint32_t)sizeof m); + mlen = (unsigned long long)randombytes_uniform((uint32_t)sizeof m); randombytes_buf(m, mlen); randombytes_buf(nonce, sizeof nonce); crypto_box_easy(c, m, mlen, nonce, bobpk, alicesk); diff --git a/test/default/generichash.c b/test/default/generichash.c index d6d3afee..71c12e44 100644 --- a/test/default/generichash.c +++ b/test/default/generichash.c @@ -7,7 +7,7 @@ int main(void) #define MAXLEN 64 unsigned char in[MAXLEN], out[crypto_generichash_BYTES_MAX], k[crypto_generichash_KEYBYTES_MAX]; - unsigned char h, i, j; + size_t h, i, j; for (h = 0; h < crypto_generichash_KEYBYTES_MAX; ++h) k[h] = h; diff --git a/test/default/generichash2.c b/test/default/generichash2.c index 5984d7fd..cd9c889c 100644 --- a/test/default/generichash2.c +++ b/test/default/generichash2.c @@ -8,7 +8,7 @@ int main(void) crypto_generichash_state st; unsigned char in[MAXLEN], out[crypto_generichash_BYTES_MAX], k[crypto_generichash_KEYBYTES_MAX]; - unsigned char h, i, j; + size_t h, i, j; for (h = 0; h < crypto_generichash_KEYBYTES_MAX; ++h) k[h] = h; diff --git a/test/default/generichash3.c b/test/default/generichash3.c index 36d6203b..dca852d5 100644 --- a/test/default/generichash3.c +++ b/test/default/generichash3.c @@ -14,7 +14,7 @@ int main(void) '3', '7', '4', '0', '0', 'd', '2', 'a' }; unsigned char in[MAXLEN], out[crypto_generichash_blake2b_BYTES_MAX], k[crypto_generichash_blake2b_KEYBYTES_MAX]; - unsigned char h, i, j; + size_t h, i, j; for (h = 0; h < crypto_generichash_blake2b_KEYBYTES_MAX; ++h) k[h] = h; diff --git a/test/default/pwhash.c b/test/default/pwhash.c index e3a83f5c..f61214ff 100644 --- a/test/default/pwhash.c +++ b/test/default/pwhash.c @@ -8,7 +8,7 @@ static void tv(void) const char *passwd_hex; unsigned long long passwdlen; const char *salt_hex; - size_t outlen; + unsigned long long outlen; unsigned long long opslimit; size_t memlimit; } tests[] = { @@ -114,7 +114,7 @@ static void tv2(void) const char *passwd_hex; unsigned long long passwdlen; const char *salt_hex; - size_t outlen; + unsigned long long outlen; unsigned long long opslimit; size_t memlimit; } tests[] = { @@ -285,8 +285,11 @@ int main(void) { char str_out[crypto_pwhash_scryptsalsa208sha256_STRBYTES]; char str_out2[crypto_pwhash_scryptsalsa208sha256_STRBYTES]; + unsigned char out[OUT_LEN]; + char out_hex[OUT_LEN * 2 + 1]; const char *salt = "[<~A 32-bytes salt for scrypt~>]"; const char *passwd = "Correct Horse Battery Staple"; + size_t i; tv(); tv2(); diff --git a/test/default/secretbox_easy2.c b/test/default/secretbox_easy2.c index b1d24597..99e1b097 100644 --- a/test/default/secretbox_easy2.c +++ b/test/default/secretbox_easy2.c @@ -11,11 +11,11 @@ unsigned char mac[crypto_secretbox_MACBYTES]; int main(void) { - uint32_t mlen; + unsigned long long mlen; unsigned long long i; randombytes_buf(k, sizeof k); - mlen = randombytes_uniform((uint32_t)sizeof m); + mlen = (unsigned long long)randombytes_uniform((uint32_t)sizeof m); randombytes_buf(m, mlen); randombytes_buf(nonce, sizeof nonce); crypto_secretbox_easy(c, m, mlen, nonce, k); diff --git a/test/default/shorthash.c b/test/default/shorthash.c index 9918ef21..18081cd0 100644 --- a/test/default/shorthash.c +++ b/test/default/shorthash.c @@ -7,7 +7,7 @@ int main(void) #define MAXLEN 64 unsigned char in[MAXLEN], out[crypto_shorthash_BYTES], k[crypto_shorthash_KEYBYTES]; - unsigned char i, j; + size_t i, j; for (i = 0; i < crypto_shorthash_KEYBYTES; ++i) k[i] = i;