summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2018-02-20 18:05:29 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2018-02-20 18:05:29 +0000
commitc0a40d85b27d22d8ad7dce0144e592228d717b06 (patch)
treebeae95fb22dd760e68401e881c54e5f58283cc9f /lib
parentb948a385ced3f29195f2a8cffe8cd0897eb7f0aa (diff)
Provide EVP_PKEY_get0_EC_KEY() and 'if (ret)' vs 'if (ret != 0)' cosmetics.
ok jsing
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/Symbols.list1
-rw-r--r--lib/libcrypto/evp/evp.h5
-rw-r--r--lib/libcrypto/evp/p_lib.c31
3 files changed, 24 insertions, 13 deletions
diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list
index 885d5fb111d..39ef6bf4305 100644
--- a/lib/libcrypto/Symbols.list
+++ b/lib/libcrypto/Symbols.list
@@ -1388,6 +1388,7 @@ EVP_PKEY_free
EVP_PKEY_get0
EVP_PKEY_get0_DH
EVP_PKEY_get0_DSA
+EVP_PKEY_get0_EC_KEY
EVP_PKEY_get0_RSA
EVP_PKEY_get0_asn1
EVP_PKEY_get1_DH
diff --git a/lib/libcrypto/evp/evp.h b/lib/libcrypto/evp/evp.h
index aec6fa4249a..e12e771cc5f 100644
--- a/lib/libcrypto/evp/evp.h
+++ b/lib/libcrypto/evp/evp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: evp.h,v 1.57 2018/02/17 16:54:08 jsing Exp $ */
+/* $OpenBSD: evp.h,v 1.58 2018/02/20 18:05:28 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -893,8 +893,9 @@ int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);
#endif
#ifndef OPENSSL_NO_EC
struct ec_key_st;
-int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);
+struct ec_key_st *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey);
struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
+int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);
#endif
#ifndef OPENSSL_NO_GOST
struct gost_key_st;
diff --git a/lib/libcrypto/evp/p_lib.c b/lib/libcrypto/evp/p_lib.c
index 3cd1bf3b348..811fe0c86d6 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.19 2018/02/17 13:47:36 tb Exp $ */
+/* $OpenBSD: p_lib.c,v 1.20 2018/02/20 18:05:28 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -311,7 +311,7 @@ int
EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key)
{
int ret = EVP_PKEY_assign_RSA(pkey, key);
- if (ret)
+ if (ret != 0)
RSA_up_ref(key);
return ret;
}
@@ -343,21 +343,21 @@ int
EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key)
{
int ret = EVP_PKEY_assign_DSA(pkey, key);
- if (ret)
+ if (ret != 0)
DSA_up_ref(key);
return ret;
}
#endif
#ifndef OPENSSL_NO_EC
-
-int
-EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key)
+EC_KEY *
+EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
{
- int ret = EVP_PKEY_assign_EC_KEY(pkey, key);
- if (ret)
- EC_KEY_up_ref(key);
- return ret;
+ if (pkey->type != EVP_PKEY_EC) {
+ EVPerror(EVP_R_EXPECTING_A_EC_KEY);
+ return NULL;
+ }
+ return pkey->pkey.ec;
}
EC_KEY *
@@ -370,6 +370,15 @@ EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
EC_KEY_up_ref(pkey->pkey.ec);
return pkey->pkey.ec;
}
+
+int
+EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key)
+{
+ int ret = EVP_PKEY_assign_EC_KEY(pkey, key);
+ if (ret != 0)
+ EC_KEY_up_ref(key);
+ return ret;
+}
#endif
@@ -399,7 +408,7 @@ int
EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)
{
int ret = EVP_PKEY_assign_DH(pkey, key);
- if (ret)
+ if (ret != 0)
DH_up_ref(key);
return ret;
}