literal suffix in call function
This commit is contained in:
		
							parent
							
								
									d0cb8ba954
								
							
						
					
					
						commit
						40c763a18d
					
				| @ -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) { |    if ((res = mp_copy(&y, &v)) != MP_OKAY) { | ||||||
|       goto LBL_ERR; |       goto LBL_ERR; | ||||||
|    } |    } | ||||||
|    mp_set(&D, 1); |    mp_set(&D, 1uL); | ||||||
| 
 | 
 | ||||||
| top: | top: | ||||||
|    /* 4.  while u is even do */ |    /* 4.  while u is even do */ | ||||||
| @ -128,7 +128,7 @@ top: | |||||||
|    /* now a = C, b = D, gcd == g*v */ |    /* now a = C, b = D, gcd == g*v */ | ||||||
| 
 | 
 | ||||||
|    /* if v != 1 then there is no inverse */ |    /* 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; |       res = MP_VAL; | ||||||
|       goto LBL_ERR; |       goto LBL_ERR; | ||||||
|    } |    } | ||||||
|  | |||||||
| @ -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); |    n = mp_count_bits(a) - mp_count_bits(b); | ||||||
|    if (((res = mp_abs(a, &ta)) != MP_OKAY) || |    if (((res = mp_abs(a, &ta)) != MP_OKAY) || | ||||||
|        ((res = mp_abs(b, &tb)) != MP_OKAY) || |        ((res = mp_abs(b, &tb)) != MP_OKAY) || | ||||||
|  | |||||||
| @ -28,7 +28,7 @@ int mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast) | |||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    /* set initial result */ |    /* set initial result */ | ||||||
|    mp_set(c, 1); |    mp_set(c, 1uL); | ||||||
| 
 | 
 | ||||||
|    if (fast != 0) { |    if (fast != 0) { | ||||||
|       while (b > 0) { |       while (b > 0) { | ||||||
|  | |||||||
| @ -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; |       goto LBL_RES; | ||||||
| #endif | #endif | ||||||
|    } else { |    } else { | ||||||
|       mp_set(&res, 1); |       mp_set(&res, 1uL); | ||||||
|       if ((err = mp_mod(G, P, &M[1])) != MP_OKAY) { |       if ((err = mp_mod(G, P, &M[1])) != MP_OKAY) { | ||||||
|          goto LBL_RES; |          goto LBL_RES; | ||||||
|       } |       } | ||||||
|  | |||||||
| @ -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) */ |    /* initialize, (u1,u2,u3) = (1,0,a) */ | ||||||
|    mp_set(&u1, 1); |    mp_set(&u1, 1uL); | ||||||
|    if ((err = mp_copy(a, &u3)) != MP_OKAY)                                        { |    if ((err = mp_copy(a, &u3)) != MP_OKAY)                                        { | ||||||
|       goto LBL_ERR; |       goto LBL_ERR; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    /* initialize, (v1,v2,v3) = (0,1,b) */ |    /* initialize, (v1,v2,v3) = (0,1,b) */ | ||||||
|    mp_set(&v2, 1); |    mp_set(&v2, 1uL); | ||||||
|    if ((err = mp_copy(b, &v3)) != MP_OKAY)                                        { |    if ((err = mp_copy(b, &v3)) != MP_OKAY)                                        { | ||||||
|       goto LBL_ERR; |       goto LBL_ERR; | ||||||
|    } |    } | ||||||
|  | |||||||
| @ -56,7 +56,7 @@ int mp_fread(mp_int *a, int radix, FILE *stream) | |||||||
| 
 | 
 | ||||||
|       ch = fgetc(stream); |       ch = fgetc(stream); | ||||||
|    } |    } | ||||||
|    if (mp_cmp_d(a, 0) != MP_EQ) { |    if (mp_cmp_d(a, 0uL) != MP_EQ) { | ||||||
|       a->sign = neg; |       a->sign = neg; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -19,7 +19,7 @@ | |||||||
| int mp_invmod(const mp_int *a, const mp_int *b, mp_int *c) | int mp_invmod(const mp_int *a, const mp_int *b, mp_int *c) | ||||||
| { | { | ||||||
|    /* b cannot be negative and has to be >1 */ |    /* 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; |       return MP_VAL; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -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) { |    if ((res = mp_copy(&y, &v)) != MP_OKAY) { | ||||||
|       goto LBL_ERR; |       goto LBL_ERR; | ||||||
|    } |    } | ||||||
|    mp_set(&A, 1); |    mp_set(&A, 1uL); | ||||||
|    mp_set(&D, 1); |    mp_set(&D, 1uL); | ||||||
| 
 | 
 | ||||||
| top: | top: | ||||||
|    /* 4.  while u is even do */ |    /* 4.  while u is even do */ | ||||||
| @ -143,13 +143,13 @@ top: | |||||||
|    /* now a = C, b = D, gcd == g*v */ |    /* now a = C, b = D, gcd == g*v */ | ||||||
| 
 | 
 | ||||||
|    /* if v != 1 then there is no inverse */ |    /* 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; |       res = MP_VAL; | ||||||
|       goto LBL_ERR; |       goto LBL_ERR; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    /* if its too low */ |    /* 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) { |       if ((res = mp_add(&C, b, &C)) != MP_OKAY) { | ||||||
|          goto LBL_ERR; |          goto LBL_ERR; | ||||||
|       } |       } | ||||||
|  | |||||||
| @ -63,7 +63,7 @@ int mp_is_square(const mp_int *arg, int *ret) | |||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    /* Next check mod 105 (3*5*7) */ |    /* 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; |       return res; | ||||||
|    } |    } | ||||||
|    if (rem_105[c] == 1) { |    if (rem_105[c] == 1) { | ||||||
|  | |||||||
| @ -32,14 +32,14 @@ int mp_jacobi(const mp_int *a, const mp_int *n, int *c) | |||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    /* if n <= 0 return MP_VAL */ |    /* 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; |       return MP_VAL; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    /* step 1. handle case of a == 0 */ |    /* step 1. handle case of a == 0 */ | ||||||
|    if (mp_iszero(a) == MP_YES) { |    if (mp_iszero(a) == MP_YES) { | ||||||
|       /* special case of a == 0 and n == 1 */ |       /* 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; |          *c = 1; | ||||||
|       } else { |       } else { | ||||||
|          *c = 0; |          *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 */ |    /* 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; |       *c = 1; | ||||||
|       return MP_OKAY; |       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 a1 == 1 we're done */ | ||||||
|    if (mp_cmp_d(&a1, 1) == MP_EQ) { |    if (mp_cmp_d(&a1, 1uL) == MP_EQ) { | ||||||
|       *c = s; |       *c = s; | ||||||
|    } else { |    } else { | ||||||
|       /* n1 = n mod a1 */ |       /* n1 = n mod a1 */ | ||||||
|  | |||||||
| @ -33,7 +33,7 @@ int mp_montgomery_calc_normalization(mp_int *a, const mp_int *b) | |||||||
|          return res; |          return res; | ||||||
|       } |       } | ||||||
|    } else { |    } else { | ||||||
|       mp_set(a, 1); |       mp_set(a, 1uL); | ||||||
|       bits = 1; |       bits = 1; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -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; |    a_.sign = MP_ZPOS; | ||||||
| 
 | 
 | ||||||
|    /* t2 = 2 */ |    /* t2 = 2 */ | ||||||
|    mp_set(&t2, 2); |    mp_set(&t2, 2uL); | ||||||
| 
 | 
 | ||||||
|    do { |    do { | ||||||
|       /* t1 = t2 */ |       /* 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 (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; |             goto LBL_T3; | ||||||
|          } |          } | ||||||
|       } else { |       } else { | ||||||
|  | |||||||
| @ -32,7 +32,7 @@ int mp_prime_fermat(const mp_int *a, const mp_int *b, int *result) | |||||||
|    *result = MP_NO; |    *result = MP_NO; | ||||||
| 
 | 
 | ||||||
|    /* ensure b > 1 */ |    /* ensure b > 1 */ | ||||||
|    if (mp_cmp_d(b, 1) != MP_GT) { |    if (mp_cmp_d(b, 1uL) != MP_GT) { | ||||||
|       return MP_VAL; |       return MP_VAL; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -31,7 +31,7 @@ int mp_prime_miller_rabin(const mp_int *a, const mp_int *b, int *result) | |||||||
|    *result = MP_NO; |    *result = MP_NO; | ||||||
| 
 | 
 | ||||||
|    /* ensure b > 1 */ |    /* ensure b > 1 */ | ||||||
|    if (mp_cmp_d(b, 1) != MP_GT) { |    if (mp_cmp_d(b, 1uL) != MP_GT) { | ||||||
|       return MP_VAL; |       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) { |    if ((err = mp_init_copy(&n1, a)) != MP_OKAY) { | ||||||
|       return err; |       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; |       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 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; |       j = 1; | ||||||
|       /* while j <= s-1 and y != n1 */ |       /* while j <= s-1 and y != n1 */ | ||||||
|       while ((j <= (s - 1)) && (mp_cmp(&y, &n1) != MP_EQ)) { |       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 y == 1 then composite */ | ||||||
|          if (mp_cmp_d(&y, 1) == MP_EQ) { |          if (mp_cmp_d(&y, 1uL) == MP_EQ) { | ||||||
|             goto LBL_Y; |             goto LBL_Y; | ||||||
|          } |          } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -62,8 +62,8 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style) | |||||||
|          } |          } | ||||||
|       } |       } | ||||||
|       /* at this point a maybe 1 */ |       /* at this point a maybe 1 */ | ||||||
|       if (mp_cmp_d(a, 1) == MP_EQ) { |       if (mp_cmp_d(a, 1uL) == MP_EQ) { | ||||||
|          mp_set(a, 2); |          mp_set(a, 2uL); | ||||||
|          return MP_OKAY; |          return MP_OKAY; | ||||||
|       } |       } | ||||||
|       /* fall through to the sieve */ |       /* fall through to the sieve */ | ||||||
| @ -88,7 +88,7 @@ int mp_prime_next_prime(mp_int *a, int t, int bbs_style) | |||||||
|    } else { |    } else { | ||||||
|       if (mp_iseven(a) == MP_YES) { |       if (mp_iseven(a) == MP_YES) { | ||||||
|          /* force odd */ |          /* force odd */ | ||||||
|          if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) { |          if ((err = mp_sub_d(a, 1uL, a)) != MP_OKAY) { | ||||||
|             return err; |             return err; | ||||||
|          } |          } | ||||||
|       } |       } | ||||||
|  | |||||||
| @ -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) { |       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)                    { |          if ((err = mp_sub_d(a, 1uL, a)) != MP_OKAY)                  { | ||||||
|             goto error; |             goto error; | ||||||
|          } |          } | ||||||
|          if ((err = mp_div_2(a, a)) != MP_OKAY)                       { |          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)                          { |       if ((err = mp_mul_2(a, a)) != MP_OKAY)                          { | ||||||
|          goto error; |          goto error; | ||||||
|       } |       } | ||||||
|       if ((err = mp_add_d(a, 1, a)) != MP_OKAY)                       { |       if ((err = mp_add_d(a, 1uL, a)) != MP_OKAY)                     { | ||||||
|          goto error; |          goto error; | ||||||
|       } |       } | ||||||
|    } |    } | ||||||
|  | |||||||
| @ -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 x < 0, add b**(k+1) to it */ | ||||||
|    if (mp_cmp_d(x, 0) == MP_LT) { |    if (mp_cmp_d(x, 0uL) == MP_LT) { | ||||||
|       mp_set(&q, 1); |       mp_set(&q, 1uL); | ||||||
|       if ((res = mp_lshd(&q, um + 1)) != MP_OKAY) |       if ((res = mp_lshd(&q, um + 1)) != MP_OKAY) | ||||||
|          goto CLEANUP; |          goto CLEANUP; | ||||||
|       if ((res = mp_add(x, &q, x)) != MP_OKAY) |       if ((res = mp_add(x, &q, x)) != MP_OKAY) | ||||||
|  | |||||||
| @ -22,11 +22,11 @@ int mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) | |||||||
|    mp_digit i; |    mp_digit i; | ||||||
| 
 | 
 | ||||||
|    /* first handle the simple cases */ |    /* first handle the simple cases */ | ||||||
|    if (mp_cmp_d(n, 0) == MP_EQ) { |    if (mp_cmp_d(n, 0uL) == MP_EQ) { | ||||||
|       mp_zero(ret); |       mp_zero(ret); | ||||||
|       return MP_OKAY; |       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 ((res = mp_jacobi(n, prime, &legendre)) != MP_OKAY)        return res; | ||||||
|    if (legendre == -1)                                           return MP_VAL; /* quadratic non-residue mod prime */ |    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 |     * compute directly: res = n^(prime+1)/4 mod prime | ||||||
|     * Handbook of Applied Cryptography algorithm 3.36 |     * 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 (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_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; |       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 */ |    /* 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_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 */ |    /* Q = prime - 1 */ | ||||||
|    mp_zero(&S); |    mp_zero(&S); | ||||||
|    /* S = 0 */ |    /* S = 0 */ | ||||||
|    while (mp_iseven(&Q) != MP_NO) { |    while (mp_iseven(&Q) != MP_NO) { | ||||||
|       if ((res = mp_div_2(&Q, &Q)) != MP_OKAY)                    goto cleanup; |       if ((res = mp_div_2(&Q, &Q)) != MP_OKAY)                    goto cleanup; | ||||||
|       /* Q = Q / 2 */ |       /* 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 */ |       /* S = S + 1 */ | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
| @ -69,13 +69,13 @@ int mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) | |||||||
|    while (1) { |    while (1) { | ||||||
|       if ((res = mp_jacobi(&Z, prime, &legendre)) != MP_OKAY)     goto cleanup; |       if ((res = mp_jacobi(&Z, prime, &legendre)) != MP_OKAY)     goto cleanup; | ||||||
|       if (legendre == -1) break; |       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 */ |       /* Z = Z + 1 */ | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    if ((res = mp_exptmod(&Z, &Q, prime, &C)) != MP_OKAY)         goto cleanup; |    if ((res = mp_exptmod(&Z, &Q, prime, &C)) != MP_OKAY)         goto cleanup; | ||||||
|    /* C = Z ^ Q mod prime */ |    /* 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; |    if ((res = mp_div_2(&t1, &t1)) != MP_OKAY)                    goto cleanup; | ||||||
|    /* t1 = (Q + 1) / 2 */ |    /* t1 = (Q + 1) / 2 */ | ||||||
|    if ((res = mp_exptmod(n, &t1, prime, &R)) != MP_OKAY)         goto cleanup; |    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; |       if ((res = mp_copy(&T, &t1)) != MP_OKAY)                    goto cleanup; | ||||||
|       i = 0; |       i = 0; | ||||||
|       while (1) { |       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; |          if ((res = mp_exptmod(&t1, &two, prime, &t1)) != MP_OKAY) goto cleanup; | ||||||
|          i++; |          i++; | ||||||
|       } |       } | ||||||
| @ -101,7 +101,7 @@ int mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) | |||||||
|          goto cleanup; |          goto cleanup; | ||||||
|       } |       } | ||||||
|       if ((res = mp_sub_d(&M, i, &t1)) != MP_OKAY)                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; |       if ((res = mp_exptmod(&two, &t1, prime, &t1)) != MP_OKAY)   goto cleanup; | ||||||
|       /* t1 = 2 ^ (M - i - 1) */ |       /* t1 = 2 ^ (M - i - 1) */ | ||||||
|       if ((res = mp_exptmod(&C, &t1, prime, &t1)) != MP_OKAY)     goto cleanup; |       if ((res = mp_exptmod(&C, &t1, prime, &t1)) != MP_OKAY)     goto cleanup; | ||||||
|  | |||||||
| @ -219,7 +219,7 @@ int mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c) | |||||||
|       goto ERR; |       goto ERR; | ||||||
|    } |    } | ||||||
|    /* 3r2 - r1 - r3 */ |    /* 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; |       goto ERR; | ||||||
|    } |    } | ||||||
|    if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) { |    if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) { | ||||||
|  | |||||||
| @ -162,7 +162,7 @@ int mp_toom_sqr(const mp_int *a, mp_int *b) | |||||||
|       goto ERR; |       goto ERR; | ||||||
|    } |    } | ||||||
|    /* 3r2 - r1 - r3 */ |    /* 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; |       goto ERR; | ||||||
|    } |    } | ||||||
|    if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) { |    if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) { | ||||||
|  | |||||||
| @ -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) { |    if ((err = mp_init(&res)) != MP_OKAY) { | ||||||
|       goto LBL_MU; |       goto LBL_MU; | ||||||
|    } |    } | ||||||
|    mp_set(&res, 1); |    mp_set(&res, 1uL); | ||||||
| 
 | 
 | ||||||
|    /* set initial mode and bit cnt */ |    /* set initial mode and bit cnt */ | ||||||
|    mode   = 0; |    mode   = 0; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user