bignum_cmp(random, key->modulus) >= 0) {
freebn(random);
continue;
- } else {
- break;
}
+
+ /*
+ * Also, make sure it has an inverse mod modulus.
+ */
+ random_inverse = modinv(random, key->modulus);
+ if (!random_inverse) {
+ freebn(random);
+ continue;
+ }
+
+ break;
}
/*
*/
random_encrypted = crt_modpow(random, key->exponent,
key->modulus, key->p, key->q, key->iqmp);
- random_inverse = modinv(random, key->modulus);
input_blinded = modmul(input, random_encrypted, key->modulus);
ret_blinded = crt_modpow(input_blinded, key->private_exponent,
key->modulus, key->p, key->q, key->iqmp);
freebn(key->iqmp);
key->iqmp = modinv(key->q, key->p);
+ if (!key->iqmp)
+ return 0;
}
/*