summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/evp/p_lib.c
diff options
context:
space:
mode:
authortb <tb@openbsd.org>2018-02-17 13:47:35 +0000
committertb <tb@openbsd.org>2018-02-17 13:47:35 +0000
commitf08abba079dae83ad95b35691473b9253691c43b (patch)
tree7675b221c057cf2bcd2431d48a775c6e985b0d5d /lib/libcrypto/evp/p_lib.c
parent- Add descriptions for the new functions ifcreate() and vifscreate() (diff)
downloadwireguard-openbsd-f08abba079dae83ad95b35691473b9253691c43b.tar.xz
wireguard-openbsd-f08abba079dae83ad95b35691473b9253691c43b.zip
Provide further parts of the OpenSSL 1.1 API: {DH,DSA}_get0_{key,pqg}(),
EVP_PKEY_get0_{DH,DSA,RSA}(), RSA_{g,s}et0_key(). ok jsing
Diffstat (limited to 'lib/libcrypto/evp/p_lib.c')
-rw-r--r--lib/libcrypto/evp/p_lib.c67
1 files changed, 48 insertions, 19 deletions
diff --git a/lib/libcrypto/evp/p_lib.c b/lib/libcrypto/evp/p_lib.c
index e001755ef18..3cd1bf3b348 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.18 2018/02/14 16:40:42 jsing Exp $ */
+/* $OpenBSD: p_lib.c,v 1.19 2018/02/17 13:47:36 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -286,13 +286,14 @@ EVP_PKEY_get0(EVP_PKEY *pkey)
}
#ifndef OPENSSL_NO_RSA
-int
-EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key)
+RSA *
+EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
{
- int ret = EVP_PKEY_assign_RSA(pkey, key);
- if (ret)
- RSA_up_ref(key);
- return ret;
+ if (pkey->type != EVP_PKEY_RSA) {
+ EVPerror(EVP_R_EXPECTING_AN_RSA_KEY);
+ return NULL;
+ }
+ return pkey->pkey.rsa;
}
RSA *
@@ -305,17 +306,27 @@ EVP_PKEY_get1_RSA(EVP_PKEY *pkey)
RSA_up_ref(pkey->pkey.rsa);
return pkey->pkey.rsa;
}
-#endif
-#ifndef OPENSSL_NO_DSA
int
-EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key)
+EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key)
{
- int ret = EVP_PKEY_assign_DSA(pkey, key);
+ int ret = EVP_PKEY_assign_RSA(pkey, key);
if (ret)
- DSA_up_ref(key);
+ RSA_up_ref(key);
return ret;
}
+#endif
+
+#ifndef OPENSSL_NO_DSA
+DSA *
+EVP_PKEY_get0_DSA(EVP_PKEY *pkey)
+{
+ if (pkey->type != EVP_PKEY_DSA) {
+ EVPerror(EVP_R_EXPECTING_A_DSA_KEY);
+ return NULL;
+ }
+ return pkey->pkey.dsa;
+}
DSA *
EVP_PKEY_get1_DSA(EVP_PKEY *pkey)
@@ -327,6 +338,15 @@ EVP_PKEY_get1_DSA(EVP_PKEY *pkey)
DSA_up_ref(pkey->pkey.dsa);
return pkey->pkey.dsa;
}
+
+int
+EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key)
+{
+ int ret = EVP_PKEY_assign_DSA(pkey, key);
+ if (ret)
+ DSA_up_ref(key);
+ return ret;
+}
#endif
#ifndef OPENSSL_NO_EC
@@ -354,14 +374,14 @@ EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
#ifndef OPENSSL_NO_DH
-
-int
-EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)
+DH *
+EVP_PKEY_get0_DH(EVP_PKEY *pkey)
{
- int ret = EVP_PKEY_assign_DH(pkey, key);
- if (ret)
- DH_up_ref(key);
- return ret;
+ if (pkey->type != EVP_PKEY_DH) {
+ EVPerror(EVP_R_EXPECTING_A_DH_KEY);
+ return NULL;
+ }
+ return pkey->pkey.dh;
}
DH *
@@ -374,6 +394,15 @@ EVP_PKEY_get1_DH(EVP_PKEY *pkey)
DH_up_ref(pkey->pkey.dh);
return pkey->pkey.dh;
}
+
+int
+EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)
+{
+ int ret = EVP_PKEY_assign_DH(pkey, key);
+ if (ret)
+ DH_up_ref(key);
+ return ret;
+}
#endif
int