explicit condition (part C)
This commit is contained in:
parent
e25f1701e4
commit
38f90d1b17
@ -20,7 +20,7 @@ static int s_is_power_of_two(mp_digit b, int *p)
|
|||||||
int x;
|
int x;
|
||||||
|
|
||||||
/* fast return if no power of two */
|
/* fast return if no power of two */
|
||||||
if ((b==0) || (b & (b-1))) {
|
if ((b == 0) || ((b & (b-1)) != 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ int mp_export(void* rop, size_t* countp, int order, size_t size,
|
|||||||
nail_bytes = nails / 8;
|
nail_bytes = nails / 8;
|
||||||
|
|
||||||
bits = mp_count_bits(&t);
|
bits = mp_count_bits(&t);
|
||||||
count = bits / (size * 8 - nails) + (bits % (size * 8 - nails) ? 1 : 0);
|
count = bits / (size * 8 - nails) + ((bits % (size * 8 - nails) != 0) ? 1 : 0);
|
||||||
|
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
for (j = 0; j < size; ++j) {
|
for (j = 0; j < size; ++j) {
|
||||||
@ -74,7 +74,7 @@ int mp_export(void* rop, size_t* countp, int order, size_t size,
|
|||||||
|
|
||||||
mp_clear(&t);
|
mp_clear(&t);
|
||||||
|
|
||||||
if (countp) {
|
if (countp != NULL) {
|
||||||
*countp = count;
|
*countp = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@ int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast)
|
|||||||
/* set initial result */
|
/* set initial result */
|
||||||
mp_set (c, 1);
|
mp_set (c, 1);
|
||||||
|
|
||||||
if (fast) {
|
if (fast != 0) {
|
||||||
while (b > 0) {
|
while (b > 0) {
|
||||||
/* if the bit is set multiply */
|
/* if the bit is set multiply */
|
||||||
if (b & 1) {
|
if ((b & 1) != 0) {
|
||||||
if ((res = mp_mul (c, &g, c)) != MP_OKAY) {
|
if ((res = mp_mul (c, &g, c)) != MP_OKAY) {
|
||||||
mp_clear (&g);
|
mp_clear (&g);
|
||||||
return res;
|
return res;
|
||||||
|
@ -37,7 +37,7 @@ int mp_init_multi(mp_int *mp, ...)
|
|||||||
/* now start cleaning up */
|
/* now start cleaning up */
|
||||||
cur_arg = mp;
|
cur_arg = mp;
|
||||||
va_start(clean_args, mp);
|
va_start(clean_args, mp);
|
||||||
while (n--) {
|
while (n-- != 0) {
|
||||||
mp_clear(cur_arg);
|
mp_clear(cur_arg);
|
||||||
cur_arg = va_arg(clean_args, mp_int*);
|
cur_arg = va_arg(clean_args, mp_int*);
|
||||||
}
|
}
|
||||||
|
@ -82,13 +82,13 @@ int mp_is_square(mp_int *arg,int *ret)
|
|||||||
* free "t" so the easiest way is to goto ERR. We know that res
|
* free "t" so the easiest way is to goto ERR. We know that res
|
||||||
* is already equal to MP_OKAY from the mp_mod call
|
* is already equal to MP_OKAY from the mp_mod call
|
||||||
*/
|
*/
|
||||||
if ( (1L<<(r%11)) & 0x5C4L ) goto ERR;
|
if (((1L<<(r%11)) & 0x5C4L) != 0L) goto ERR;
|
||||||
if ( (1L<<(r%13)) & 0x9E4L ) goto ERR;
|
if (((1L<<(r%13)) & 0x9E4L) != 0L) goto ERR;
|
||||||
if ( (1L<<(r%17)) & 0x5CE8L ) goto ERR;
|
if (((1L<<(r%17)) & 0x5CE8L) != 0L) goto ERR;
|
||||||
if ( (1L<<(r%19)) & 0x4F50CL ) goto ERR;
|
if (((1L<<(r%19)) & 0x4F50CL) != 0L) goto ERR;
|
||||||
if ( (1L<<(r%23)) & 0x7ACCA0L ) goto ERR;
|
if (((1L<<(r%23)) & 0x7ACCA0L) != 0L) goto ERR;
|
||||||
if ( (1L<<(r%29)) & 0xC2EDD0CL ) goto ERR;
|
if (((1L<<(r%29)) & 0xC2EDD0CL) != 0L) goto ERR;
|
||||||
if ( (1L<<(r%31)) & 0x6DE2B848L ) goto ERR;
|
if (((1L<<(r%31)) & 0x6DE2B848L) != 0L) goto ERR;
|
||||||
|
|
||||||
/* Final check - is sqr(sqrt(arg)) == arg ? */
|
/* Final check - is sqr(sqrt(arg)) == arg ? */
|
||||||
if ((res = mp_sqrt(arg,&t)) != MP_OKAY) {
|
if ((res = mp_sqrt(arg,&t)) != MP_OKAY) {
|
||||||
|
@ -31,7 +31,7 @@ mp_mod (mp_int * a, mp_int * b, mp_int * c)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mp_iszero(&t) || t.sign == b->sign) {
|
if (mp_iszero(&t) != MP_NO || t.sign == b->sign) {
|
||||||
res = MP_OKAY;
|
res = MP_OKAY;
|
||||||
mp_exch (&t, c);
|
mp_exch (&t, c);
|
||||||
} else {
|
} else {
|
||||||
|
@ -85,7 +85,7 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
|
|||||||
|
|
||||||
|
|
||||||
/* propagate carries upwards as required*/
|
/* propagate carries upwards as required*/
|
||||||
while (u) {
|
while (u != 0) {
|
||||||
*tmpx += u;
|
*tmpx += u;
|
||||||
u = *tmpx >> DIGIT_BIT;
|
u = *tmpx >> DIGIT_BIT;
|
||||||
*tmpx++ &= MP_MASK;
|
*tmpx++ &= MP_MASK;
|
||||||
|
@ -41,7 +41,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* LTM_PRIME_SAFE implies LTM_PRIME_BBS */
|
/* LTM_PRIME_SAFE implies LTM_PRIME_BBS */
|
||||||
if (flags & LTM_PRIME_SAFE) {
|
if ((flags & LTM_PRIME_SAFE) != 0) {
|
||||||
flags |= LTM_PRIME_BBS;
|
flags |= LTM_PRIME_BBS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,13 +60,13 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
|
|||||||
/* calc the maskOR_msb */
|
/* calc the maskOR_msb */
|
||||||
maskOR_msb = 0;
|
maskOR_msb = 0;
|
||||||
maskOR_msb_offset = ((size & 7) == 1) ? 1 : 0;
|
maskOR_msb_offset = ((size & 7) == 1) ? 1 : 0;
|
||||||
if (flags & LTM_PRIME_2MSB_ON) {
|
if ((flags & LTM_PRIME_2MSB_ON) != 0) {
|
||||||
maskOR_msb |= 0x80 >> ((9 - size) & 7);
|
maskOR_msb |= 0x80 >> ((9 - size) & 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the maskOR_lsb */
|
/* get the maskOR_lsb */
|
||||||
maskOR_lsb = 1;
|
maskOR_lsb = 1;
|
||||||
if (flags & LTM_PRIME_BBS) {
|
if ((flags & LTM_PRIME_BBS) != 0) {
|
||||||
maskOR_lsb |= 3;
|
maskOR_lsb |= 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & LTM_PRIME_SAFE) {
|
if ((flags & LTM_PRIME_SAFE) != 0) {
|
||||||
/* see if (a-1)/2 is prime */
|
/* see if (a-1)/2 is prime */
|
||||||
if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) { goto error; }
|
if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) { goto error; }
|
||||||
if ((err = mp_div_2(a, a)) != MP_OKAY) { goto error; }
|
if ((err = mp_div_2(a, a)) != MP_OKAY) { goto error; }
|
||||||
@ -104,7 +104,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
|
|||||||
}
|
}
|
||||||
} while (res == MP_NO);
|
} while (res == MP_NO);
|
||||||
|
|
||||||
if (flags & LTM_PRIME_SAFE) {
|
if ((flags & LTM_PRIME_SAFE) != 0) {
|
||||||
/* restore a to the original value */
|
/* restore a to the original value */
|
||||||
if ((err = mp_mul_2(a, a)) != MP_OKAY) { goto error; }
|
if ((err = mp_mul_2(a, a)) != MP_OKAY) { goto error; }
|
||||||
if ((err = mp_add_d(a, 1, a)) != MP_OKAY) { goto error; }
|
if ((err = mp_add_d(a, 1, a)) != MP_OKAY) { goto error; }
|
||||||
|
@ -43,7 +43,7 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
|
|||||||
mp_zero (a);
|
mp_zero (a);
|
||||||
|
|
||||||
/* process each digit of the string */
|
/* process each digit of the string */
|
||||||
while (*str) {
|
while (*str != '\0') {
|
||||||
/* if the radix <= 36 the conversion is case insensitive
|
/* if the radix <= 36 the conversion is case insensitive
|
||||||
* this allows numbers like 1AB and 1ab to represent the same value
|
* this allows numbers like 1AB and 1ab to represent the same value
|
||||||
* [e.g. in hex]
|
* [e.g. in hex]
|
||||||
|
Loading…
Reference in New Issue
Block a user