Skip to content

Commit 40c763a

Browse files
committed
literal suffix in call function
1 parent d0cb8ba commit 40c763a

21 files changed

+46
-46
lines changed

bn_fast_mp_invmod.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int fast_mp_invmod(const mp_int *a, const mp_int *b, mp_int *c)
5959
if ((res = mp_copy(&y, &v)) != MP_OKAY) {
6060
goto LBL_ERR;
6161
}
62-
mp_set(&D, 1);
62+
mp_set(&D, 1uL);
6363

6464
top:
6565
/* 4. while u is even do */
@@ -128,7 +128,7 @@ int fast_mp_invmod(const mp_int *a, const mp_int *b, mp_int *c)
128128
/* now a = C, b = D, gcd == g*v */
129129

130130
/* if v != 1 then there is no inverse */
131-
if (mp_cmp_d(&v, 1) != MP_EQ) {
131+
if (mp_cmp_d(&v, 1uL) != MP_EQ) {
132132
res = MP_VAL;
133133
goto LBL_ERR;
134134
}

bn_mp_div.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ int mp_div(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d)
4747
}
4848

4949

50-
mp_set(&tq, 1);
50+
mp_set(&tq, 1uL);
5151
n = mp_count_bits(a) - mp_count_bits(b);
5252
if (((res = mp_abs(a, &ta)) != MP_OKAY) ||
5353
((res = mp_abs(b, &tb)) != MP_OKAY) ||

bn_mp_expt_d_ex.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ int mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
2828
}
2929

3030
/* set initial result */
31-
mp_set(c, 1);
31+
mp_set(c, 1uL);
3232

3333
if (fast != 0) {
3434
while (b > 0) {

bn_mp_exptmod_fast.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ int mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y
160160
goto LBL_RES;
161161
#endif
162162
} else {
163-
mp_set(&res, 1);
163+
mp_set(&res, 1uL);
164164
if ((err = mp_mod(G, P, &M[1])) != MP_OKAY) {
165165
goto LBL_RES;
166166
}

bn_mp_exteuclid.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ int mp_exteuclid(const mp_int *a, const mp_int *b, mp_int *U1, mp_int *U2, mp_in
2828
}
2929

3030
/* initialize, (u1,u2,u3) = (1,0,a) */
31-
mp_set(&u1, 1);
31+
mp_set(&u1, 1uL);
3232
if ((err = mp_copy(a, &u3)) != MP_OKAY) {
3333
goto LBL_ERR;
3434
}
3535

3636
/* initialize, (v1,v2,v3) = (0,1,b) */
37-
mp_set(&v2, 1);
37+
mp_set(&v2, 1uL);
3838
if ((err = mp_copy(b, &v3)) != MP_OKAY) {
3939
goto LBL_ERR;
4040
}

bn_mp_fread.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int mp_fread(mp_int *a, int radix, FILE *stream)
5656

5757
ch = fgetc(stream);
5858
}
59-
if (mp_cmp_d(a, 0) != MP_EQ) {
59+
if (mp_cmp_d(a, 0uL) != MP_EQ) {
6060
a->sign = neg;
6161
}
6262

bn_mp_invmod.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
int mp_invmod(const mp_int *a, const mp_int *b, mp_int *c)
2020
{
2121
/* b cannot be negative and has to be >1 */
22-
if ((b->sign == MP_NEG) || (mp_cmp_d(b, 1) != MP_GT)) {
22+
if ((b->sign == MP_NEG) || (mp_cmp_d(b, 1uL) != MP_GT)) {
2323
return MP_VAL;
2424
}
2525

bn_mp_invmod_slow.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ int mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c)
5353
if ((res = mp_copy(&y, &v)) != MP_OKAY) {
5454
goto LBL_ERR;
5555
}
56-
mp_set(&A, 1);
57-
mp_set(&D, 1);
56+
mp_set(&A, 1uL);
57+
mp_set(&D, 1uL);
5858

5959
top:
6060
/* 4. while u is even do */
@@ -143,13 +143,13 @@ int mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c)
143143
/* now a = C, b = D, gcd == g*v */
144144

145145
/* if v != 1 then there is no inverse */
146-
if (mp_cmp_d(&v, 1) != MP_EQ) {
146+
if (mp_cmp_d(&v, 1uL) != MP_EQ) {
147147
res = MP_VAL;
148148
goto LBL_ERR;
149149
}
150150

151151
/* if its too low */
152-
while (mp_cmp_d(&C, 0) == MP_LT) {
152+
while (mp_cmp_d(&C, 0uL) == MP_LT) {
153153
if ((res = mp_add(&C, b, &C)) != MP_OKAY) {
154154
goto LBL_ERR;
155155
}

bn_mp_is_square.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int mp_is_square(const mp_int *arg, int *ret)
6363
}
6464

6565
/* Next check mod 105 (3*5*7) */
66-
if ((res = mp_mod_d(arg, 105, &c)) != MP_OKAY) {
66+
if ((res = mp_mod_d(arg, 105uL, &c)) != MP_OKAY) {
6767
return res;
6868
}
6969
if (rem_105[c] == 1) {

bn_mp_jacobi.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ int mp_jacobi(const mp_int *a, const mp_int *n, int *c)
3232
}
3333

3434
/* if n <= 0 return MP_VAL */
35-
if (mp_cmp_d(n, 0) != MP_GT) {
35+
if (mp_cmp_d(n, 0uL) != MP_GT) {
3636
return MP_VAL;
3737
}
3838

3939
/* step 1. handle case of a == 0 */
4040
if (mp_iszero(a) == MP_YES) {
4141
/* special case of a == 0 and n == 1 */
42-
if (mp_cmp_d(n, 1) == MP_EQ) {
42+
if (mp_cmp_d(n, 1uL) == MP_EQ) {
4343
*c = 1;
4444
} else {
4545
*c = 0;
@@ -48,7 +48,7 @@ int mp_jacobi(const mp_int *a, const mp_int *n, int *c)
4848
}
4949

5050
/* step 2. if a == 1, return 1 */
51-
if (mp_cmp_d(a, 1) == MP_EQ) {
51+
if (mp_cmp_d(a, 1uL) == MP_EQ) {
5252
*c = 1;
5353
return MP_OKAY;
5454
}
@@ -91,7 +91,7 @@ int mp_jacobi(const mp_int *a, const mp_int *n, int *c)
9191
}
9292

9393
/* if a1 == 1 we're done */
94-
if (mp_cmp_d(&a1, 1) == MP_EQ) {
94+
if (mp_cmp_d(&a1, 1uL) == MP_EQ) {
9595
*c = s;
9696
} else {
9797
/* n1 = n mod a1 */

bn_mp_montgomery_calc_normalization.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int mp_montgomery_calc_normalization(mp_int *a, const mp_int *b)
3333
return res;
3434
}
3535
} else {
36-
mp_set(a, 1);
36+
mp_set(a, 1uL);
3737
bits = 1;
3838
}
3939

bn_mp_n_root_ex.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
5252
a_.sign = MP_ZPOS;
5353

5454
/* t2 = 2 */
55-
mp_set(&t2, 2);
55+
mp_set(&t2, 2uL);
5656

5757
do {
5858
/* t1 = t2 */
@@ -101,7 +101,7 @@ int mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
101101
}
102102

103103
if (mp_cmp(&t2, &a_) == MP_GT) {
104-
if ((res = mp_sub_d(&t1, 1, &t1)) != MP_OKAY) {
104+
if ((res = mp_sub_d(&t1, 1uL, &t1)) != MP_OKAY) {
105105
goto LBL_T3;
106106
}
107107
} else {

bn_mp_prime_fermat.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ int mp_prime_fermat(const mp_int *a, const mp_int *b, int *result)
3232
*result = MP_NO;
3333

3434
/* ensure b > 1 */
35-
if (mp_cmp_d(b, 1) != MP_GT) {
35+
if (mp_cmp_d(b, 1uL) != MP_GT) {
3636
return MP_VAL;
3737
}
3838

bn_mp_prime_miller_rabin.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ int mp_prime_miller_rabin(const mp_int *a, const mp_int *b, int *result)
3131
*result = MP_NO;
3232

3333
/* ensure b > 1 */
34-
if (mp_cmp_d(b, 1) != MP_GT) {
34+
if (mp_cmp_d(b, 1uL) != MP_GT) {
3535
return MP_VAL;
3636
}
3737

3838
/* get n1 = a - 1 */
3939
if ((err = mp_init_copy(&n1, a)) != MP_OKAY) {
4040
return err;
4141
}
42-
if ((err = mp_sub_d(&n1, 1, &n1)) != MP_OKAY) {
42+
if ((err = mp_sub_d(&n1, 1uL, &n1)) != MP_OKAY) {
4343
goto LBL_N1;
4444
}
4545

@@ -67,7 +67,7 @@ int mp_prime_miller_rabin(const mp_int *a, const mp_int *b, int *result)
6767
}
6868

6969
/* if y != 1 and y != n1 do */
70-
if ((mp_cmp_d(&y, 1) != MP_EQ) && (mp_cmp(&y, &n1) != MP_EQ)) {
70+
if ((mp_cmp_d(&y, 1uL) != MP_EQ) && (mp_cmp(&y, &n1) != MP_EQ)) {
7171
j = 1;
7272
/* while j <= s-1 and y != n1 */
7373
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)
7676
}
7777

7878
/* if y == 1 then composite */
79-
if (mp_cmp_d(&y, 1) == MP_EQ) {
79+
if (mp_cmp_d(&y, 1uL) == MP_EQ) {
8080
goto LBL_Y;
8181
}
8282

bn_mp_prime_next_prime.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style)
6262
}
6363
}
6464
/* at this point a maybe 1 */
65-
if (mp_cmp_d(a, 1) == MP_EQ) {
66-
mp_set(a, 2);
65+
if (mp_cmp_d(a, 1uL) == MP_EQ) {
66+
mp_set(a, 2uL);
6767
return MP_OKAY;
6868
}
6969
/* fall through to the sieve */
@@ -88,7 +88,7 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style)
8888
} else {
8989
if (mp_iseven(a) == MP_YES) {
9090
/* force odd */
91-
if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) {
91+
if ((err = mp_sub_d(a, 1uL, a)) != MP_OKAY) {
9292
return err;
9393
}
9494
}

bn_mp_prime_random_ex.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
100100

101101
if ((flags & LTM_PRIME_SAFE) != 0) {
102102
/* see if (a-1)/2 is prime */
103-
if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) {
103+
if ((err = mp_sub_d(a, 1uL, a)) != MP_OKAY) {
104104
goto error;
105105
}
106106
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
119119
if ((err = mp_mul_2(a, a)) != MP_OKAY) {
120120
goto error;
121121
}
122-
if ((err = mp_add_d(a, 1, a)) != MP_OKAY) {
122+
if ((err = mp_add_d(a, 1uL, a)) != MP_OKAY) {
123123
goto error;
124124
}
125125
}

bn_mp_reduce.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ int mp_reduce(mp_int *x, const mp_int *m, const mp_int *mu)
7373
}
7474

7575
/* If x < 0, add b**(k+1) to it */
76-
if (mp_cmp_d(x, 0) == MP_LT) {
77-
mp_set(&q, 1);
76+
if (mp_cmp_d(x, 0uL) == MP_LT) {
77+
mp_set(&q, 1uL);
7878
if ((res = mp_lshd(&q, um + 1)) != MP_OKAY)
7979
goto CLEANUP;
8080
if ((res = mp_add(x, &q, x)) != MP_OKAY)

bn_mp_sqrtmod_prime.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ int mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret)
2222
mp_digit i;
2323

2424
/* first handle the simple cases */
25-
if (mp_cmp_d(n, 0) == MP_EQ) {
25+
if (mp_cmp_d(n, 0uL) == MP_EQ) {
2626
mp_zero(ret);
2727
return MP_OKAY;
2828
}
29-
if (mp_cmp_d(prime, 2) == MP_EQ) return MP_VAL; /* prime must be odd */
29+
if (mp_cmp_d(prime, 2uL) == MP_EQ) return MP_VAL; /* prime must be odd */
3030
if ((res = mp_jacobi(n, prime, &legendre)) != MP_OKAY) return res;
3131
if (legendre == -1) return MP_VAL; /* quadratic non-residue mod prime */
3232

@@ -38,9 +38,9 @@ int mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret)
3838
* compute directly: res = n^(prime+1)/4 mod prime
3939
* Handbook of Applied Cryptography algorithm 3.36
4040
*/
41-
if ((res = mp_mod_d(prime, 4, &i)) != MP_OKAY) goto cleanup;
41+
if ((res = mp_mod_d(prime, 4uL, &i)) != MP_OKAY) goto cleanup;
4242
if (i == 3) {
43-
if ((res = mp_add_d(prime, 1, &t1)) != MP_OKAY) goto cleanup;
43+
if ((res = mp_add_d(prime, 1uL, &t1)) != MP_OKAY) goto cleanup;
4444
if ((res = mp_div_2(&t1, &t1)) != MP_OKAY) goto cleanup;
4545
if ((res = mp_div_2(&t1, &t1)) != MP_OKAY) goto cleanup;
4646
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)
5252

5353
/* factor out powers of 2 from prime-1, defining Q and S as: prime-1 = Q*2^S */
5454
if ((res = mp_copy(prime, &Q)) != MP_OKAY) goto cleanup;
55-
if ((res = mp_sub_d(&Q, 1, &Q)) != MP_OKAY) goto cleanup;
55+
if ((res = mp_sub_d(&Q, 1uL, &Q)) != MP_OKAY) goto cleanup;
5656
/* Q = prime - 1 */
5757
mp_zero(&S);
5858
/* S = 0 */
5959
while (mp_iseven(&Q) != MP_NO) {
6060
if ((res = mp_div_2(&Q, &Q)) != MP_OKAY) goto cleanup;
6161
/* Q = Q / 2 */
62-
if ((res = mp_add_d(&S, 1, &S)) != MP_OKAY) goto cleanup;
62+
if ((res = mp_add_d(&S, 1uL, &S)) != MP_OKAY) goto cleanup;
6363
/* S = S + 1 */
6464
}
6565

@@ -69,13 +69,13 @@ int mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret)
6969
while (1) {
7070
if ((res = mp_jacobi(&Z, prime, &legendre)) != MP_OKAY) goto cleanup;
7171
if (legendre == -1) break;
72-
if ((res = mp_add_d(&Z, 1, &Z)) != MP_OKAY) goto cleanup;
72+
if ((res = mp_add_d(&Z, 1uL, &Z)) != MP_OKAY) goto cleanup;
7373
/* Z = Z + 1 */
7474
}
7575

7676
if ((res = mp_exptmod(&Z, &Q, prime, &C)) != MP_OKAY) goto cleanup;
7777
/* C = Z ^ Q mod prime */
78-
if ((res = mp_add_d(&Q, 1, &t1)) != MP_OKAY) goto cleanup;
78+
if ((res = mp_add_d(&Q, 1uL, &t1)) != MP_OKAY) goto cleanup;
7979
if ((res = mp_div_2(&t1, &t1)) != MP_OKAY) goto cleanup;
8080
/* t1 = (Q + 1) / 2 */
8181
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)
9191
if ((res = mp_copy(&T, &t1)) != MP_OKAY) goto cleanup;
9292
i = 0;
9393
while (1) {
94-
if (mp_cmp_d(&t1, 1) == MP_EQ) break;
94+
if (mp_cmp_d(&t1, 1uL) == MP_EQ) break;
9595
if ((res = mp_exptmod(&t1, &two, prime, &t1)) != MP_OKAY) goto cleanup;
9696
i++;
9797
}
@@ -101,7 +101,7 @@ int mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret)
101101
goto cleanup;
102102
}
103103
if ((res = mp_sub_d(&M, i, &t1)) != MP_OKAY) goto cleanup;
104-
if ((res = mp_sub_d(&t1, 1, &t1)) != MP_OKAY) goto cleanup;
104+
if ((res = mp_sub_d(&t1, 1uL, &t1)) != MP_OKAY) goto cleanup;
105105
if ((res = mp_exptmod(&two, &t1, prime, &t1)) != MP_OKAY) goto cleanup;
106106
/* t1 = 2 ^ (M - i - 1) */
107107
if ((res = mp_exptmod(&C, &t1, prime, &t1)) != MP_OKAY) goto cleanup;

bn_mp_toom_mul.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ int mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
219219
goto ERR;
220220
}
221221
/* 3r2 - r1 - r3 */
222-
if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) {
222+
if ((res = mp_mul_d(&w2, 3uL, &w2)) != MP_OKAY) {
223223
goto ERR;
224224
}
225225
if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {

bn_mp_toom_sqr.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ int mp_toom_sqr(const mp_int *a, mp_int *b)
162162
goto ERR;
163163
}
164164
/* 3r2 - r1 - r3 */
165-
if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) {
165+
if ((res = mp_mul_d(&w2, 3uL, &w2)) != MP_OKAY) {
166166
goto ERR;
167167
}
168168
if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {

bn_s_mp_exptmod.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ int s_mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, i
133133
if ((err = mp_init(&res)) != MP_OKAY) {
134134
goto LBL_MU;
135135
}
136-
mp_set(&res, 1);
136+
mp_set(&res, 1uL);
137137

138138
/* set initial mode and bit cnt */
139139
mode = 0;

0 commit comments

Comments
 (0)