diff options
author | Bodo Möller <bodo@openssl.org> | 2002-10-28 14:02:19 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 2002-10-28 14:02:19 +0000 |
commit | 19b8d06a7911d41ce8b3e347b4f58878e12d92ff (patch) | |
tree | deb9c6b9a4d34e5fb9dac030f672c17e17ca4cbb /crypto/ec/ec_cvt.c | |
parent | 5c6bf03117a26942327f43d02e9113e9870f7aba (diff) | |
download | openssl-19b8d06a7911d41ce8b3e347b4f58878e12d92ff.tar.gz |
clean up new code for NIST primes
create new lock CRYPTO_LOCK_BN to avoid race condition
Diffstat (limited to 'crypto/ec/ec_cvt.c')
-rw-r--r-- | crypto/ec/ec_cvt.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/crypto/ec/ec_cvt.c b/crypto/ec/ec_cvt.c index 20782569a9..7571a3c368 100644 --- a/crypto/ec/ec_cvt.c +++ b/crypto/ec/ec_cvt.c @@ -99,9 +99,25 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx)) { - /* remove the last error code form the error queue */ - ERR_get_error(); - /* try the normal mont method */ + unsigned long err; + + err = ERR_peek_last_error(); + + if (!(ERR_GET_LIB(err) == ERR_LIB_EC && + ((ERR_GET_REASON(err) == EC_R_NOT_A_NIST_PRIME) || + (ERR_GET_REASON(err) == EC_R_NOT_A_SUPPORTED_NIST_PRIME)))) + { + /* real error */ + + EC_GROUP_clear_free(ret); + return NULL; + } + + + /* not an actual error, we just cannot use EC_GFp_nist_method */ + + ERR_clear_error(); + EC_GROUP_clear_free(ret); meth = EC_GFp_mont_method(); @@ -119,6 +135,7 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM return ret; } + EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) { const EC_METHOD *meth; |