don't set prime data until good primes are generated.

This commit is contained in:
mcgreer%netscape.com 2000-09-19 06:03:52 +00:00
Родитель bc35c73f74
Коммит eca80fd5cb
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -30,7 +30,7 @@
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: rsa.c,v 1.12 2000-09-13 18:44:11 mcgreer%netscape.com Exp $
* $Id: rsa.c,v 1.13 2000-09-19 06:03:52 mcgreer%netscape.com Exp $
*/
#include "secerr.h"
@ -172,13 +172,13 @@ RSA_NewKey(int keySizeInBits, SECItem *publicExponent)
CHECK_MPI_OK( mp_read_unsigned_octets(&q, qb, primeLen) );
CHECK_MPI_OK( mpp_make_prime(&p, primeLen * 8, PR_FALSE, &counter) );
CHECK_MPI_OK( mpp_make_prime(&q, primeLen * 8, PR_FALSE, &counter) );
MPINT_TO_SECITEM(&p, &key->prime1, arena);
MPINT_TO_SECITEM(&q, &key->prime2, arena);
rv = rsa_keygen_from_primes(&p, &q, &e, key);
if (rv == SECSuccess)
break; /* generated two good primes */
prerr = PORT_GetError();
} while (prerr == SEC_ERROR_NEED_RANDOM); /* loop until have primes */
MPINT_TO_SECITEM(&p, &key->prime1, arena);
MPINT_TO_SECITEM(&q, &key->prime2, arena);
cleanup:
mp_clear(&p);
mp_clear(&q);