summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2018-02-14 16:40:43 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2018-02-14 16:40:43 +0000
commit241fcbffc5547baaedbeceacaf37d2bb41803747 (patch)
tree516d240f98fb9edefe3e70a9042e52ca6cea1c87
parent6a444cf3ecc1c0ecbf1e87eccc492625d69a95e6 (diff)
Provide EVP_PKEY_up_ref().
-rw-r--r--lib/libcrypto/Symbols.list1
-rw-r--r--lib/libcrypto/evp/evp.h3
-rw-r--r--lib/libcrypto/evp/p_lib.c9
3 files changed, 11 insertions, 2 deletions
diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list
index 0c437dc75f3..1cafdf06b4c 100644
--- a/lib/libcrypto/Symbols.list
+++ b/lib/libcrypto/Symbols.list
@@ -1388,6 +1388,7 @@ EVP_PKEY_sign
EVP_PKEY_sign_init
EVP_PKEY_size
EVP_PKEY_type
+EVP_PKEY_up_ref
EVP_PKEY_verify
EVP_PKEY_verify_init
EVP_PKEY_verify_recover
diff --git a/lib/libcrypto/evp/evp.h b/lib/libcrypto/evp/evp.h
index 853abe6b8ec..09df7db64bd 100644
--- a/lib/libcrypto/evp/evp.h
+++ b/lib/libcrypto/evp/evp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: evp.h,v 1.53 2017/08/28 17:48:02 jsing Exp $ */
+/* $OpenBSD: evp.h,v 1.54 2018/02/14 16:40:42 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -894,6 +894,7 @@ struct gost_key_st;
EVP_PKEY *EVP_PKEY_new(void);
void EVP_PKEY_free(EVP_PKEY *pkey);
+int EVP_PKEY_up_ref(EVP_PKEY *pkey);
EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
long length);
diff --git a/lib/libcrypto/evp/p_lib.c b/lib/libcrypto/evp/p_lib.c
index 0d4cd26d45b..e001755ef18 100644
--- a/lib/libcrypto/evp/p_lib.c
+++ b/lib/libcrypto/evp/p_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: p_lib.c,v 1.17 2017/01/29 17:49:23 beck Exp $ */
+/* $OpenBSD: p_lib.c,v 1.18 2018/02/14 16:40:42 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -204,6 +204,13 @@ EVP_PKEY_new(void)
return (ret);
}
+int
+EVP_PKEY_up_ref(EVP_PKEY *pkey)
+{
+ int refs = CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
+ return ((refs > 1) ? 1 : 0);
+}
+
/* Setup a public key ASN1 method and ENGINE from a NID or a string.
* If pkey is NULL just return 1 or 0 if the algorithm exists.
*/