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
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2014-08-06 05:46:37 +0400
committerAdam Langley <agl@google.com>2014-08-07 04:03:56 +0400
commite6e15fc3a19ac6e4317d7245df24313c261fc2bb (patch)
treebe8cbfd4a795836e3a519fac7f2ed3a181d55733 /crypto/evp
parentbf681a40d6142edfa44a27dc0d6e07e0c37865a4 (diff)
Use EVP_PKEY_dup instead of manually incrementing the refcount.
Reference counting should be internal to the type, otherwise callers need to know which lock to use. Change-Id: If4d805876a321ef6dece115c805e605584ff311e Reviewed-on: https://boringssl-review.googlesource.com/1414 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/evp_ctx.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/crypto/evp/evp_ctx.c b/crypto/evp/evp_ctx.c
index 1416d3a2..d1ed67d6 100644
--- a/crypto/evp/evp_ctx.c
+++ b/crypto/evp/evp_ctx.c
@@ -119,8 +119,7 @@ static EVP_PKEY_CTX *evp_pkey_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) {
ret->operation = EVP_PKEY_OP_UNDEFINED;
if (pkey) {
- ret->pkey = pkey;
- CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
+ ret->pkey = EVP_PKEY_dup(pkey);
}
if (pmeth->init) {
@@ -176,14 +175,12 @@ EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx) {
rctx->operation = pctx->operation;
if (pctx->pkey) {
- CRYPTO_add(&pctx->pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
+ rctx->pkey = EVP_PKEY_dup(pctx->pkey);
}
- rctx->pkey = pctx->pkey;
if (pctx->peerkey) {
- CRYPTO_add(&pctx->peerkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
+ rctx->peerkey = EVP_PKEY_dup(pctx->peerkey);
}
- rctx->peerkey = pctx->peerkey;
if (pctx->pmeth->copy(rctx, pctx) > 0) {
return rctx;
@@ -437,7 +434,7 @@ int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer) {
return 0;
}
- CRYPTO_add(&peer->references, 1, CRYPTO_LOCK_EVP_PKEY);
+ EVP_PKEY_dup(peer);
return 1;
}