From c7f4e81debb5d2a6e9b346b58ad72b184bce665d Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Tue, 22 Jan 2019 18:17:36 +0100 Subject: [PATCH 1/2] fix cast --- bn_mp_prime_is_prime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bn_mp_prime_is_prime.c b/bn_mp_prime_is_prime.c index b5b8987..24e1eb2 100644 --- a/bn_mp_prime_is_prime.c +++ b/bn_mp_prime_is_prime.c @@ -305,7 +305,7 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result) fips_rand &= mask; } #endif - if (fips_rand > ((unsigned int) INT_MAX - DIGIT_BIT)) { + if (fips_rand > (unsigned int)(INT_MAX - DIGIT_BIT)) { len = INT_MAX / DIGIT_BIT; } else { len = (((int)fips_rand + DIGIT_BIT) / DIGIT_BIT); From 998b126fee1a3379230018c118373eaa214af994 Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Tue, 22 Jan 2019 18:26:01 +0100 Subject: [PATCH 2/2] explicit operator precedence --- bn_mp_prime_is_prime.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bn_mp_prime_is_prime.c b/bn_mp_prime_is_prime.c index 24e1eb2..15637c8 100644 --- a/bn_mp_prime_is_prime.c +++ b/bn_mp_prime_is_prime.c @@ -71,7 +71,7 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result) } #ifdef MP_8BIT /* The search in the loop above was exhaustive in this case */ - if (a->used == 1 && PRIME_SIZE >= 31) { + if ((a->used == 1) && (PRIME_SIZE >= 31)) { return MP_OKAY; } #endif @@ -126,7 +126,7 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result) */ #if defined (MP_8BIT) || defined (LTM_USE_FROBENIUS_TEST) err = mp_prime_frobenius_underwood(a, &res); - if (err != MP_OKAY && err != MP_ITER) { + if ((err != MP_OKAY) && (err != MP_ITER)) { goto LBL_B; } if (res == MP_NO) { @@ -296,7 +296,7 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result) * One 8-bit digit is too small, so concatenate two if the size of * unsigned int allows for it. */ - if ((sizeof(unsigned int) * CHAR_BIT)/2 >= (sizeof(mp_digit) * CHAR_BIT)) { + if (((sizeof(unsigned int) * CHAR_BIT)/2) >= (sizeof(mp_digit) * CHAR_BIT)) { if ((err = mp_rand(&b, 1)) != MP_OKAY) { goto LBL_B; }