Switch EVP_PKEY_dup calls to EVP_PKEY_up_ref.
Keep internal callers up-to-date with deprecations.
Change-Id: I7ee171afc669592d170f83bd4064857d59332878
Reviewed-on: https://boringssl-review.googlesource.com/4640
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/evp/evp_ctx.c b/crypto/evp/evp_ctx.c
index 4d927ff..9f42274 100644
--- a/crypto/evp/evp_ctx.c
+++ b/crypto/evp/evp_ctx.c
@@ -120,7 +120,7 @@
ret->operation = EVP_PKEY_OP_UNDEFINED;
if (pkey) {
- ret->pkey = EVP_PKEY_dup(pkey);
+ ret->pkey = EVP_PKEY_up_ref(pkey);
}
if (pmeth->init) {
@@ -173,14 +173,14 @@
rctx->operation = pctx->operation;
if (pctx->pkey) {
- rctx->pkey = EVP_PKEY_dup(pctx->pkey);
+ rctx->pkey = EVP_PKEY_up_ref(pctx->pkey);
if (rctx->pkey == NULL) {
goto err;
}
}
if (pctx->peerkey) {
- rctx->peerkey = EVP_PKEY_dup(pctx->peerkey);
+ rctx->peerkey = EVP_PKEY_up_ref(pctx->peerkey);
if (rctx->peerkey == NULL) {
goto err;
}
@@ -431,7 +431,7 @@
return 0;
}
- EVP_PKEY_dup(peer);
+ EVP_PKEY_up_ref(peer);
return 1;
}
diff --git a/crypto/x509/x_pubkey.c b/crypto/x509/x_pubkey.c
index 4b96ed7..d6512ae 100644
--- a/crypto/x509/x_pubkey.c
+++ b/crypto/x509/x_pubkey.c
@@ -134,7 +134,7 @@
if (key->pkey != NULL)
{
- return EVP_PKEY_dup(key->pkey);
+ return EVP_PKEY_up_ref(key->pkey);
}
if (key->public_key == NULL) goto error;
@@ -179,7 +179,7 @@
CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
}
- return EVP_PKEY_dup(ret);
+ return EVP_PKEY_up_ref(ret);
error:
if (ret != NULL)
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index b3562f0..674277f 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -661,7 +661,7 @@
return 0;
}
EVP_PKEY_free(ctx->tlsext_channel_id_private);
- ctx->tlsext_channel_id_private = EVP_PKEY_dup(private_key);
+ ctx->tlsext_channel_id_private = EVP_PKEY_up_ref(private_key);
return 1;
}
@@ -673,7 +673,7 @@
return 0;
}
EVP_PKEY_free(ssl->tlsext_channel_id_private);
- ssl->tlsext_channel_id_private = EVP_PKEY_dup(private_key);
+ ssl->tlsext_channel_id_private = EVP_PKEY_up_ref(private_key);
return 1;
}
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
index 6a4526e..770912b 100644
--- a/ssl/ssl_cert.c
+++ b/ssl/ssl_cert.c
@@ -225,7 +225,7 @@
}
if (cpk->privatekey != NULL) {
- rpk->privatekey = EVP_PKEY_dup(cpk->privatekey);
+ rpk->privatekey = EVP_PKEY_up_ref(cpk->privatekey);
}
if (cpk->chain) {
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index a6d2587..6c8e2c9 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -353,7 +353,8 @@
s->tlsext_channel_id_enabled = ctx->tlsext_channel_id_enabled;
if (ctx->tlsext_channel_id_private) {
- s->tlsext_channel_id_private = EVP_PKEY_dup(ctx->tlsext_channel_id_private);
+ s->tlsext_channel_id_private =
+ EVP_PKEY_up_ref(ctx->tlsext_channel_id_private);
}
s->signed_cert_timestamps_enabled = s->ctx->signed_cert_timestamps_enabled;
diff --git a/ssl/ssl_rsa.c b/ssl/ssl_rsa.c
index 449493d..87f4c1c 100644
--- a/ssl/ssl_rsa.c
+++ b/ssl/ssl_rsa.c
@@ -180,7 +180,7 @@
}
EVP_PKEY_free(c->pkeys[i].privatekey);
- c->pkeys[i].privatekey = EVP_PKEY_dup(pkey);
+ c->pkeys[i].privatekey = EVP_PKEY_up_ref(pkey);
c->key = &(c->pkeys[i]);
return 1;