diff options
author | Pauli <pauli@openssl.org> | 2023-06-22 09:35:12 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-07-01 21:18:25 +1000 |
commit | 97937cfcd8b5a011dd54e74eb2cc3cc26a533b10 (patch) | |
tree | f3f5a958e23cbb67ee4d7371f21489609a5a2439 | |
parent | 8752694bad830a91ba508451b220c23a99f182f1 (diff) |
rsa: update to structure based atomics
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21260)
-rw-r--r-- | crypto/rsa/rsa_lib.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c index fa3561c33f..c591b8941d 100644 --- a/crypto/rsa/rsa_lib.c +++ b/crypto/rsa/rsa_lib.c @@ -79,7 +79,6 @@ static RSA *rsa_new_intern(ENGINE *engine, OSSL_LIB_CTX *libctx) if (ret == NULL) return NULL; - ret->references = 1; ret->lock = CRYPTO_THREAD_lock_new(); if (ret->lock == NULL) { ERR_raise(ERR_LIB_RSA, ERR_R_CRYPTO_LIB); @@ -87,6 +86,9 @@ static RSA *rsa_new_intern(ENGINE *engine, OSSL_LIB_CTX *libctx) return NULL; } + if (!CRYPTO_NEW_REF(&ret->references, 1)) + goto err; + ret->libctx = libctx; ret->meth = RSA_get_default_method(); #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE) @@ -135,7 +137,7 @@ void RSA_free(RSA *r) if (r == NULL) return; - CRYPTO_DOWN_REF(&r->references, &i, r->lock); + CRYPTO_DOWN_REF(&r->references, &i); REF_PRINT_COUNT("RSA", r); if (i > 0) return; @@ -152,6 +154,7 @@ void RSA_free(RSA *r) #endif CRYPTO_THREAD_lock_free(r->lock); + CRYPTO_FREE_REF(&r->references); BN_free(r->n); BN_free(r->e); @@ -179,7 +182,7 @@ int RSA_up_ref(RSA *r) { int i; - if (CRYPTO_UP_REF(&r->references, &i, r->lock) <= 0) + if (CRYPTO_UP_REF(&r->references, &i) <= 0) return 0; REF_PRINT_COUNT("RSA", r); |