From 1353736b3e6f33a9f6e47f837c5de05cc0dd3647 Mon Sep 17 00:00:00 2001 From: Pauli Date: Thu, 22 Jun 2023 09:32:45 +1000 Subject: ec: update to structure based atomics Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/21260) --- crypto/ec/ecp_nistp521.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'crypto/ec/ecp_nistp521.c') diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c index 388ccd06cf..97815cac1f 100644 --- a/crypto/ec/ecp_nistp521.c +++ b/crypto/ec/ecp_nistp521.c @@ -1665,7 +1665,6 @@ static void batch_mul(felem x_out, felem y_out, felem z_out, struct nistp521_pre_comp_st { felem g_pre_comp[16][3]; CRYPTO_REF_COUNT references; - CRYPTO_RWLOCK *lock; }; const EC_METHOD *EC_GFp_nistp521_method(void) @@ -1744,11 +1743,7 @@ static NISTP521_PRE_COMP *nistp521_pre_comp_new(void) if (ret == NULL) return ret; - ret->references = 1; - - ret->lock = CRYPTO_THREAD_lock_new(); - if (ret->lock == NULL) { - ERR_raise(ERR_LIB_EC, ERR_R_CRYPTO_LIB); + if (!CRYPTO_NEW_REF(&ret->references, 1)) { OPENSSL_free(ret); return NULL; } @@ -1759,7 +1754,7 @@ NISTP521_PRE_COMP *EC_nistp521_pre_comp_dup(NISTP521_PRE_COMP *p) { int i; if (p != NULL) - CRYPTO_UP_REF(&p->references, &i, p->lock); + CRYPTO_UP_REF(&p->references, &i); return p; } @@ -1770,13 +1765,13 @@ void EC_nistp521_pre_comp_free(NISTP521_PRE_COMP *p) if (p == NULL) return; - CRYPTO_DOWN_REF(&p->references, &i, p->lock); + CRYPTO_DOWN_REF(&p->references, &i); REF_PRINT_COUNT("EC_nistp521", p); if (i > 0) return; REF_ASSERT_ISNT(i < 0); - CRYPTO_THREAD_lock_free(p->lock); + CRYPTO_FREE_REF(&p->references); OPENSSL_free(p); } -- cgit v1.2.3