Fix DSA key generation
This commit is contained in:
Ludovic FLAMENT
2015-07-23 13:24:20 +02:00
parent 349edd40c2
commit 8951d72f03
43 changed files with 1254 additions and 427 deletions

View File

@@ -963,7 +963,7 @@ top:
/* if not zero goto step 4 */
if (mp_iszero (&u) == 0) {
if (++loop_check > 1024) {
if (++loop_check > 4096) {
res = MP_VAL;
goto LBL_ERR;
}
@@ -2501,33 +2501,6 @@ int mp_reduce_2k_setup(mp_int *a, mp_digit *d)
}
/* computes a = 2**b
*
* Simple algorithm which zeroes the int, grows it then just sets one bit
* as required.
*/
int
mp_2expt (mp_int * a, int b)
{
int res;
/* zero a as per default */
mp_zero (a);
/* grow a to accomodate the single bit */
if ((res = mp_grow (a, b / DIGIT_BIT + 1)) != MP_OKAY) {
return res;
}
/* set the used count of where the bit will go */
a->used = b / DIGIT_BIT + 1;
/* put the single bit in its place */
a->dp[b / DIGIT_BIT] = ((mp_digit)1) << (b % DIGIT_BIT);
return MP_OKAY;
}
/* set the b bit of a */
int
mp_set_bit (mp_int * a, int b)
@@ -2550,6 +2523,19 @@ mp_set_bit (mp_int * a, int b)
return MP_OKAY;
}
/* computes a = 2**b
*
* Simple algorithm which zeroes the int, set the required bit
*/
int
mp_2expt (mp_int * a, int b)
{
/* zero a as per default */
mp_zero (a);
return mp_set_bit(a, b);
}
/* multiply by a digit */
int
mp_mul_d (mp_int * a, mp_digit b, mp_int * c)