diff --git a/bn_fast_mp_invmod.c b/bn_fast_mp_invmod.c index cabed0c..6be44f8 100644 --- a/bn_fast_mp_invmod.c +++ b/bn_fast_mp_invmod.c @@ -59,7 +59,7 @@ int fast_mp_invmod(const mp_int *a, const mp_int *b, mp_int *c) if ((res = mp_copy(&y, &v)) != MP_OKAY) { goto LBL_ERR; } - mp_set(&D, 1); + mp_set(&D, 1uL); top: /* 4. while u is even do */ @@ -128,7 +128,7 @@ top: /* now a = C, b = D, gcd == g*v */ /* if v != 1 then there is no inverse */ - if (mp_cmp_d(&v, 1) != MP_EQ) { + if (mp_cmp_d(&v, 1uL) != MP_EQ) { res = MP_VAL; goto LBL_ERR; } diff --git a/bn_mp_div.c b/bn_mp_div.c index dbfdc03..acf0d78 100644 --- a/bn_mp_div.c +++ b/bn_mp_div.c @@ -47,7 +47,7 @@ int mp_div(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d) } - mp_set(&tq, 1); + mp_set(&tq, 1uL); n = mp_count_bits(a) - mp_count_bits(b); if (((res = mp_abs(a, &ta)) != MP_OKAY) || ((res = mp_abs(b, &tb)) != MP_OKAY) || diff --git a/bn_mp_expt_d_ex.c b/bn_mp_expt_d_ex.c index 99319a5..d8d6b45 100644 --- a/bn_mp_expt_d_ex.c +++ b/bn_mp_expt_d_ex.c @@ -28,7 +28,7 @@ int mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast) } /* set initial result */ - mp_set(c, 1); + mp_set(c, 1uL); if (fast != 0) { while (b > 0) { diff --git a/bn_mp_exptmod_fast.c b/bn_mp_exptmod_fast.c index 4a188d0..84eb114 100644 --- a/bn_mp_exptmod_fast.c +++ b/bn_mp_exptmod_fast.c @@ -160,7 +160,7 @@ int mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y goto LBL_RES; #endif } else { - mp_set(&res, 1); + mp_set(&res, 1uL); if ((err = mp_mod(G, P, &M[1])) != MP_OKAY) { goto LBL_RES; } diff --git a/bn_mp_exteuclid.c b/bn_mp_exteuclid.c index 08e5ff2..67018ac 100644 --- a/bn_mp_exteuclid.c +++ b/bn_mp_exteuclid.c @@ -28,13 +28,13 @@ int mp_exteuclid(const mp_int *a, const mp_int *b, mp_int *U1, mp_int *U2, mp_in } /* initialize, (u1,u2,u3) = (1,0,a) */ - mp_set(&u1, 1); + mp_set(&u1, 1uL); if ((err = mp_copy(a, &u3)) != MP_OKAY) { goto LBL_ERR; } /* initialize, (v1,v2,v3) = (0,1,b) */ - mp_set(&v2, 1); + mp_set(&v2, 1uL); if ((err = mp_copy(b, &v3)) != MP_OKAY) { goto LBL_ERR; } diff --git a/bn_mp_fread.c b/bn_mp_fread.c index 85e5ee3..807be70 100644 --- a/bn_mp_fread.c +++ b/bn_mp_fread.c @@ -56,7 +56,7 @@ int mp_fread(mp_int *a, int radix, FILE *stream) ch = fgetc(stream); } - if (mp_cmp_d(a, 0) != MP_EQ) { + if (mp_cmp_d(a, 0uL) != MP_EQ) { a->sign = neg; } diff --git a/bn_mp_invmod.c b/bn_mp_invmod.c index 528b0c7..96717ea 100644 --- a/bn_mp_invmod.c +++ b/bn_mp_invmod.c @@ -19,7 +19,7 @@ int mp_invmod(const mp_int *a, const mp_int *b, mp_int *c) { /* b cannot be negative and has to be >1 */ - if ((b->sign == MP_NEG) || (mp_cmp_d(b, 1) != MP_GT)) { + if ((b->sign == MP_NEG) || (mp_cmp_d(b, 1uL) != MP_GT)) { return MP_VAL; } diff --git a/bn_mp_invmod_slow.c b/bn_mp_invmod_slow.c index 2bb5196..360f161 100644 --- a/bn_mp_invmod_slow.c +++ b/bn_mp_invmod_slow.c @@ -53,8 +53,8 @@ int mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c) if ((res = mp_copy(&y, &v)) != MP_OKAY) { goto LBL_ERR; } - mp_set(&A, 1); - mp_set(&D, 1); + mp_set(&A, 1uL); + mp_set(&D, 1uL); top: /* 4. while u is even do */ @@ -143,13 +143,13 @@ top: /* now a = C, b = D, gcd == g*v */ /* if v != 1 then there is no inverse */ - if (mp_cmp_d(&v, 1) != MP_EQ) { + if (mp_cmp_d(&v, 1uL) != MP_EQ) { res = MP_VAL; goto LBL_ERR; } /* if its too low */ - while (mp_cmp_d(&C, 0) == MP_LT) { + while (mp_cmp_d(&C, 0uL) == MP_LT) { if ((res = mp_add(&C, b, &C)) != MP_OKAY) { goto LBL_ERR; } diff --git a/bn_mp_is_square.c b/bn_mp_is_square.c index dd5150e..9547a53 100644 --- a/bn_mp_is_square.c +++ b/bn_mp_is_square.c @@ -63,7 +63,7 @@ int mp_is_square(const mp_int *arg, int *ret) } /* Next check mod 105 (3*5*7) */ - if ((res = mp_mod_d(arg, 105, &c)) != MP_OKAY) { + if ((res = mp_mod_d(arg, 105uL, &c)) != MP_OKAY) { return res; } if (rem_105[c] == 1) { diff --git a/bn_mp_jacobi.c b/bn_mp_jacobi.c index c314c82..63df203 100644 --- a/bn_mp_jacobi.c +++ b/bn_mp_jacobi.c @@ -32,14 +32,14 @@ int mp_jacobi(const mp_int *a, const mp_int *n, int *c) } /* if n <= 0 return MP_VAL */ - if (mp_cmp_d(n, 0) != MP_GT) { + if (mp_cmp_d(n, 0uL) != MP_GT) { return MP_VAL; } /* step 1. handle case of a == 0 */ if (mp_iszero(a) == MP_YES) { /* special case of a == 0 and n == 1 */ - if (mp_cmp_d(n, 1) == MP_EQ) { + if (mp_cmp_d(n, 1uL) == MP_EQ) { *c = 1; } else { *c = 0; @@ -48,7 +48,7 @@ int mp_jacobi(const mp_int *a, const mp_int *n, int *c) } /* step 2. if a == 1, return 1 */ - if (mp_cmp_d(a, 1) == MP_EQ) { + if (mp_cmp_d(a, 1uL) == MP_EQ) { *c = 1; return MP_OKAY; } @@ -91,7 +91,7 @@ int mp_jacobi(const mp_int *a, const mp_int *n, int *c) } /* if a1 == 1 we're done */ - if (mp_cmp_d(&a1, 1) == MP_EQ) { + if (mp_cmp_d(&a1, 1uL) == MP_EQ) { *c = s; } else { /* n1 = n mod a1 */ diff --git a/bn_mp_montgomery_calc_normalization.c b/bn_mp_montgomery_calc_normalization.c index f2b0856..360e3e5 100644 --- a/bn_mp_montgomery_calc_normalization.c +++ b/bn_mp_montgomery_calc_normalization.c @@ -33,7 +33,7 @@ int mp_montgomery_calc_normalization(mp_int *a, const mp_int *b) return res; } } else { - mp_set(a, 1); + mp_set(a, 1uL); bits = 1; } diff --git a/bn_mp_n_root_ex.c b/bn_mp_n_root_ex.c index ca50649..f5d7da5 100644 --- a/bn_mp_n_root_ex.c +++ b/bn_mp_n_root_ex.c @@ -52,7 +52,7 @@ int mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast) a_.sign = MP_ZPOS; /* t2 = 2 */ - mp_set(&t2, 2); + mp_set(&t2, 2uL); do { /* t1 = t2 */ @@ -101,7 +101,7 @@ int mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast) } if (mp_cmp(&t2, &a_) == MP_GT) { - if ((res = mp_sub_d(&t1, 1, &t1)) != MP_OKAY) { + if ((res = mp_sub_d(&t1, 1uL, &t1)) != MP_OKAY) { goto LBL_T3; } } else { diff --git a/bn_mp_prime_fermat.c b/bn_mp_prime_fermat.c index 9c15435..e71e0ae 100644 --- a/bn_mp_prime_fermat.c +++ b/bn_mp_prime_fermat.c @@ -32,7 +32,7 @@ int mp_prime_fermat(const mp_int *a, const mp_int *b, int *result) *result = MP_NO; /* ensure b > 1 */ - if (mp_cmp_d(b, 1) != MP_GT) { + if (mp_cmp_d(b, 1uL) != MP_GT) { return MP_VAL; } diff --git a/bn_mp_prime_miller_rabin.c b/bn_mp_prime_miller_rabin.c index 5de5f05..34c4d1c 100644 --- a/bn_mp_prime_miller_rabin.c +++ b/bn_mp_prime_miller_rabin.c @@ -31,7 +31,7 @@ int mp_prime_miller_rabin(const mp_int *a, const mp_int *b, int *result) *result = MP_NO; /* ensure b > 1 */ - if (mp_cmp_d(b, 1) != MP_GT) { + if (mp_cmp_d(b, 1uL) != MP_GT) { return MP_VAL; } @@ -39,7 +39,7 @@ int mp_prime_miller_rabin(const mp_int *a, const mp_int *b, int *result) if ((err = mp_init_copy(&n1, a)) != MP_OKAY) { return err; } - if ((err = mp_sub_d(&n1, 1, &n1)) != MP_OKAY) { + if ((err = mp_sub_d(&n1, 1uL, &n1)) != MP_OKAY) { goto LBL_N1; } @@ -67,7 +67,7 @@ int mp_prime_miller_rabin(const mp_int *a, const mp_int *b, int *result) } /* if y != 1 and y != n1 do */ - if ((mp_cmp_d(&y, 1) != MP_EQ) && (mp_cmp(&y, &n1) != MP_EQ)) { + if ((mp_cmp_d(&y, 1uL) != MP_EQ) && (mp_cmp(&y, &n1) != MP_EQ)) { j = 1; /* while j <= s-1 and y != n1 */ while ((j <= (s - 1)) && (mp_cmp(&y, &n1) != MP_EQ)) { @@ -76,7 +76,7 @@ int mp_prime_miller_rabin(const mp_int *a, const mp_int *b, int *result) } /* if y == 1 then composite */ - if (mp_cmp_d(&y, 1) == MP_EQ) { + if (mp_cmp_d(&y, 1uL) == MP_EQ) { goto LBL_Y; } diff --git a/bn_mp_prime_next_prime.c b/bn_mp_prime_next_prime.c index f383cbb..1dfa2be 100644 --- a/bn_mp_prime_next_prime.c +++ b/bn_mp_prime_next_prime.c @@ -62,8 +62,8 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style) } } /* at this point a maybe 1 */ - if (mp_cmp_d(a, 1) == MP_EQ) { - mp_set(a, 2); + if (mp_cmp_d(a, 1uL) == MP_EQ) { + mp_set(a, 2uL); return MP_OKAY; } /* fall through to the sieve */ @@ -88,7 +88,7 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style) } else { if (mp_iseven(a) == MP_YES) { /* force odd */ - if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) { + if ((err = mp_sub_d(a, 1uL, a)) != MP_OKAY) { return err; } } diff --git a/bn_mp_prime_random_ex.c b/bn_mp_prime_random_ex.c index d3d6f3d..9acfdee 100644 --- a/bn_mp_prime_random_ex.c +++ b/bn_mp_prime_random_ex.c @@ -100,7 +100,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback if ((flags & LTM_PRIME_SAFE) != 0) { /* see if (a-1)/2 is prime */ - if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) { + if ((err = mp_sub_d(a, 1uL, a)) != MP_OKAY) { goto error; } if ((err = mp_div_2(a, a)) != MP_OKAY) { @@ -119,7 +119,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback if ((err = mp_mul_2(a, a)) != MP_OKAY) { goto error; } - if ((err = mp_add_d(a, 1, a)) != MP_OKAY) { + if ((err = mp_add_d(a, 1uL, a)) != MP_OKAY) { goto error; } } diff --git a/bn_mp_reduce.c b/bn_mp_reduce.c index bbc521f..9e8b962 100644 --- a/bn_mp_reduce.c +++ b/bn_mp_reduce.c @@ -73,8 +73,8 @@ int mp_reduce(mp_int *x, const mp_int *m, const mp_int *mu) } /* If x < 0, add b**(k+1) to it */ - if (mp_cmp_d(x, 0) == MP_LT) { - mp_set(&q, 1); + if (mp_cmp_d(x, 0uL) == MP_LT) { + mp_set(&q, 1uL); if ((res = mp_lshd(&q, um + 1)) != MP_OKAY) goto CLEANUP; if ((res = mp_add(x, &q, x)) != MP_OKAY) diff --git a/bn_mp_sqrtmod_prime.c b/bn_mp_sqrtmod_prime.c index 261723e..d76ef6b 100644 --- a/bn_mp_sqrtmod_prime.c +++ b/bn_mp_sqrtmod_prime.c @@ -22,11 +22,11 @@ int mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) mp_digit i; /* first handle the simple cases */ - if (mp_cmp_d(n, 0) == MP_EQ) { + if (mp_cmp_d(n, 0uL) == MP_EQ) { mp_zero(ret); return MP_OKAY; } - if (mp_cmp_d(prime, 2) == MP_EQ) return MP_VAL; /* prime must be odd */ + if (mp_cmp_d(prime, 2uL) == MP_EQ) return MP_VAL; /* prime must be odd */ if ((res = mp_jacobi(n, prime, &legendre)) != MP_OKAY) return res; if (legendre == -1) return MP_VAL; /* quadratic non-residue mod prime */ @@ -38,9 +38,9 @@ int mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) * compute directly: res = n^(prime+1)/4 mod prime * Handbook of Applied Cryptography algorithm 3.36 */ - if ((res = mp_mod_d(prime, 4, &i)) != MP_OKAY) goto cleanup; + if ((res = mp_mod_d(prime, 4uL, &i)) != MP_OKAY) goto cleanup; if (i == 3) { - if ((res = mp_add_d(prime, 1, &t1)) != MP_OKAY) goto cleanup; + if ((res = mp_add_d(prime, 1uL, &t1)) != MP_OKAY) goto cleanup; if ((res = mp_div_2(&t1, &t1)) != MP_OKAY) goto cleanup; if ((res = mp_div_2(&t1, &t1)) != MP_OKAY) goto cleanup; if ((res = mp_exptmod(n, &t1, prime, ret)) != MP_OKAY) goto cleanup; @@ -52,14 +52,14 @@ int mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) /* factor out powers of 2 from prime-1, defining Q and S as: prime-1 = Q*2^S */ if ((res = mp_copy(prime, &Q)) != MP_OKAY) goto cleanup; - if ((res = mp_sub_d(&Q, 1, &Q)) != MP_OKAY) goto cleanup; + if ((res = mp_sub_d(&Q, 1uL, &Q)) != MP_OKAY) goto cleanup; /* Q = prime - 1 */ mp_zero(&S); /* S = 0 */ while (mp_iseven(&Q) != MP_NO) { if ((res = mp_div_2(&Q, &Q)) != MP_OKAY) goto cleanup; /* Q = Q / 2 */ - if ((res = mp_add_d(&S, 1, &S)) != MP_OKAY) goto cleanup; + if ((res = mp_add_d(&S, 1uL, &S)) != MP_OKAY) goto cleanup; /* S = S + 1 */ } @@ -69,13 +69,13 @@ int mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) while (1) { if ((res = mp_jacobi(&Z, prime, &legendre)) != MP_OKAY) goto cleanup; if (legendre == -1) break; - if ((res = mp_add_d(&Z, 1, &Z)) != MP_OKAY) goto cleanup; + if ((res = mp_add_d(&Z, 1uL, &Z)) != MP_OKAY) goto cleanup; /* Z = Z + 1 */ } if ((res = mp_exptmod(&Z, &Q, prime, &C)) != MP_OKAY) goto cleanup; /* C = Z ^ Q mod prime */ - if ((res = mp_add_d(&Q, 1, &t1)) != MP_OKAY) goto cleanup; + if ((res = mp_add_d(&Q, 1uL, &t1)) != MP_OKAY) goto cleanup; if ((res = mp_div_2(&t1, &t1)) != MP_OKAY) goto cleanup; /* t1 = (Q + 1) / 2 */ if ((res = mp_exptmod(n, &t1, prime, &R)) != MP_OKAY) goto cleanup; @@ -91,7 +91,7 @@ int mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) if ((res = mp_copy(&T, &t1)) != MP_OKAY) goto cleanup; i = 0; while (1) { - if (mp_cmp_d(&t1, 1) == MP_EQ) break; + if (mp_cmp_d(&t1, 1uL) == MP_EQ) break; if ((res = mp_exptmod(&t1, &two, prime, &t1)) != MP_OKAY) goto cleanup; i++; } @@ -101,7 +101,7 @@ int mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) goto cleanup; } if ((res = mp_sub_d(&M, i, &t1)) != MP_OKAY) goto cleanup; - if ((res = mp_sub_d(&t1, 1, &t1)) != MP_OKAY) goto cleanup; + if ((res = mp_sub_d(&t1, 1uL, &t1)) != MP_OKAY) goto cleanup; if ((res = mp_exptmod(&two, &t1, prime, &t1)) != MP_OKAY) goto cleanup; /* t1 = 2 ^ (M - i - 1) */ if ((res = mp_exptmod(&C, &t1, prime, &t1)) != MP_OKAY) goto cleanup; diff --git a/bn_mp_toom_mul.c b/bn_mp_toom_mul.c index 3554ea8..00b6bfb 100644 --- a/bn_mp_toom_mul.c +++ b/bn_mp_toom_mul.c @@ -219,7 +219,7 @@ int mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c) goto ERR; } /* 3r2 - r1 - r3 */ - if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) { + if ((res = mp_mul_d(&w2, 3uL, &w2)) != MP_OKAY) { goto ERR; } if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) { diff --git a/bn_mp_toom_sqr.c b/bn_mp_toom_sqr.c index b985435..183de20 100644 --- a/bn_mp_toom_sqr.c +++ b/bn_mp_toom_sqr.c @@ -162,7 +162,7 @@ int mp_toom_sqr(const mp_int *a, mp_int *b) goto ERR; } /* 3r2 - r1 - r3 */ - if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) { + if ((res = mp_mul_d(&w2, 3uL, &w2)) != MP_OKAY) { goto ERR; } if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) { diff --git a/bn_s_mp_exptmod.c b/bn_s_mp_exptmod.c index a886361..1535b2e 100644 --- a/bn_s_mp_exptmod.c +++ b/bn_s_mp_exptmod.c @@ -133,7 +133,7 @@ int s_mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, i if ((err = mp_init(&res)) != MP_OKAY) { goto LBL_MU; } - mp_set(&res, 1); + mp_set(&res, 1uL); /* set initial mode and bit cnt */ mode = 0;