From 7550320a00ea03391c36509169eab314de57fa35 Mon Sep 17 00:00:00 2001 From: jsing Date: Wed, 14 Feb 2018 16:40:42 +0000 Subject: [PATCH] Provide EVP_PKEY_up_ref(). --- lib/libcrypto/Symbols.list | 1 + lib/libcrypto/evp/evp.h | 3 ++- lib/libcrypto/evp/p_lib.c | 9 ++++++++- 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. */ -- 2.20.1