summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/rsa/rsa_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/rsa/rsa_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/rsa/rsa_lib.c')
-rw-r--r--lib/libcrypto/rsa/rsa_lib.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/lib/libcrypto/rsa/rsa_lib.c b/lib/libcrypto/rsa/rsa_lib.c
index 31ea418427a..2a73364e702 100644
--- a/lib/libcrypto/rsa/rsa_lib.c
+++ b/lib/libcrypto/rsa/rsa_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsa_lib.c,v 1.31 2017/01/29 17:49:23 beck Exp $ */
+/* $OpenBSD: rsa_lib.c,v 1.32 2018/02/17 13:47:36 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -256,3 +256,36 @@ RSA_get_ex_data(const RSA *r, int idx)
{
return CRYPTO_get_ex_data(&r->ex_data, idx);
}
+
+int
+RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d)
+{
+ if ((r->n == NULL && n == NULL) || (r->e == NULL && e == NULL))
+ return 0;
+
+ if (n != NULL) {
+ BN_free(r->n);
+ r->n = n;
+ }
+ if (e != NULL) {
+ BN_free(r->e);
+ r->e = e;
+ }
+ if (d != NULL) {
+ BN_free(r->d);
+ r->d = d;
+ }
+
+ return 1;
+}
+
+void
+RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
+{
+ if (n != NULL)
+ *n = r->n;
+ if (e != NULL)
+ *e = r->e;
+ if (d != NULL)
+ *d = r->d;
+}