Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/crypto/ec
diff options
context:
space:
mode:
authorAdam Langley <alangley@gmail.com>2015-05-15 22:49:30 +0300
committerAdam Langley <agl@google.com>2015-05-20 22:15:26 +0300
commit0da323a8b8a4402f1c5d264cdc43c6b622118b67 (patch)
treef8d6f8775ff6253002ad18b60e52302fd391cdbd /crypto/ec
parent6f2e733bab69a5c853a929a96671736458b8d4c1 (diff)
Convert reference counts in crypto/
This change converts the reference counts in crypto/ to use |CRYPTO_refcount_t|. The reference counts in |X509_PKEY| and |X509_INFO| were never actually used and so were dropped. Change-Id: I75d572cdac1f8c1083c482e29c9519282d7fd16c Reviewed-on: https://boringssl-review.googlesource.com/4772 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/ec')
-rw-r--r--crypto/ec/ec_key.c5
-rw-r--r--crypto/ec/internal.h3
-rw-r--r--crypto/ec/p256-64.c1
-rw-r--r--crypto/ec/wnaf.c7
4 files changed, 9 insertions, 7 deletions
diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c
index 348ec462..e5cbfed7 100644
--- a/crypto/ec/ec_key.c
+++ b/crypto/ec/ec_key.c
@@ -143,7 +143,7 @@ void EC_KEY_free(EC_KEY *r) {
return;
}
- if (CRYPTO_add(&r->references, -1, CRYPTO_LOCK_EC)) {
+ if (!CRYPTO_refcount_dec_and_test_zero(&r->references)) {
return;
}
@@ -234,7 +234,8 @@ EC_KEY *EC_KEY_dup(const EC_KEY *ec_key) {
}
int EC_KEY_up_ref(EC_KEY *r) {
- return CRYPTO_add(&r->references, 1, CRYPTO_LOCK_EC) > 1;
+ CRYPTO_refcount_inc(&r->references);
+ return 1;
}
int EC_KEY_is_opaque(const EC_KEY *key) {
diff --git a/crypto/ec/internal.h b/crypto/ec/internal.h
index 0a8bf24a..71062c16 100644
--- a/crypto/ec/internal.h
+++ b/crypto/ec/internal.h
@@ -72,6 +72,7 @@
#include <openssl/bn.h>
#include <openssl/ex_data.h>
+#include <openssl/thread.h>
#if defined(__cplusplus)
extern "C" {
@@ -331,7 +332,7 @@ struct ec_key_st {
unsigned int enc_flag;
point_conversion_form_t conv_form;
- int references;
+ CRYPTO_refcount_t references;
int flags;
ECDSA_METHOD *ecdsa_meth;
diff --git a/crypto/ec/p256-64.c b/crypto/ec/p256-64.c
index 8f824dec..fdb942c3 100644
--- a/crypto/ec/p256-64.c
+++ b/crypto/ec/p256-64.c
@@ -1601,7 +1601,6 @@ static void batch_mul(felem x_out, felem y_out, felem z_out,
/* Precomputation for the group generator. */
typedef struct {
smallfelem g_pre_comp[2][16][3];
- int references;
} NISTP256_PRE_COMP;
/******************************************************************************/
diff --git a/crypto/ec/wnaf.c b/crypto/ec/wnaf.c
index d87a7d97..ae0d73fb 100644
--- a/crypto/ec/wnaf.c
+++ b/crypto/ec/wnaf.c
@@ -75,6 +75,7 @@
#include <openssl/thread.h>
#include "internal.h"
+#include "../internal.h"
/* This file implements the wNAF-based interleaving multi-exponentation method
@@ -91,7 +92,7 @@ typedef struct ec_pre_comp_st {
EC_POINT **points; /* array with pre-calculated multiples of generator:
* 'num' pointers to EC_POINT objects followed by a NULL */
size_t num; /* numblocks * 2^(w-1) */
- int references;
+ CRYPTO_refcount_t references;
} EC_PRE_COMP;
static EC_PRE_COMP *ec_pre_comp_new(void) {
@@ -116,13 +117,13 @@ void *ec_pre_comp_dup(EC_PRE_COMP *pre_comp) {
return NULL;
}
- CRYPTO_add(&pre_comp->references, 1, CRYPTO_LOCK_EC_PRE_COMP);
+ CRYPTO_refcount_inc(&pre_comp->references);
return pre_comp;
}
void ec_pre_comp_free(EC_PRE_COMP *pre_comp) {
if (pre_comp == NULL ||
- CRYPTO_add(&pre_comp->references, -1, CRYPTO_LOCK_EC_PRE_COMP) > 0) {
+ !CRYPTO_refcount_dec_and_test_zero(&pre_comp->references)) {
return;
}