summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/dh/dh_lib.c
diff options
context:
space:
mode:
authortb <tb@openbsd.org>2018-02-18 12:51:31 +0000
committertb <tb@openbsd.org>2018-02-18 12:51:31 +0000
commit8216844adf5354a75b9d41677ddc0835dbdcdc23 (patch)
tree6470022ac149cc47841f606d20682ca570aa65bd /lib/libcrypto/dh/dh_lib.c
parentProvide DSA_set0_pqg. (diff)
downloadwireguard-openbsd-8216844adf5354a75b9d41677ddc0835dbdcdc23.tar.xz
wireguard-openbsd-8216844adf5354a75b9d41677ddc0835dbdcdc23.zip
Provide DH_set0_pqg.
ok jsing
Diffstat (limited to 'lib/libcrypto/dh/dh_lib.c')
-rw-r--r--lib/libcrypto/dh/dh_lib.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/libcrypto/dh/dh_lib.c b/lib/libcrypto/dh/dh_lib.c
index 5a54ca88da8..31857727e22 100644
--- a/lib/libcrypto/dh/dh_lib.c
+++ b/lib/libcrypto/dh/dh_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dh_lib.c,v 1.23 2018/02/17 13:47:36 tb Exp $ */
+/* $OpenBSD: dh_lib.c,v 1.24 2018/02/18 12:51:31 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -251,6 +251,28 @@ DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
*g = dh->g;
}
+int
+DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g)
+{
+ if ((dh->p == NULL && p == NULL) || (dh->g == NULL && g == NULL))
+ return 0;
+
+ if (p != NULL) {
+ BN_free(dh->p);
+ dh->p = p;
+ }
+ if (q != NULL) {
+ BN_free(dh->q);
+ dh->q = q;
+ }
+ if (g != NULL) {
+ BN_free(dh->g);
+ dh->g = g;
+ }
+
+ return 1;
+}
+
void
DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key)
{