summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2018-02-18 12:51:31 +0000
committertb <>2018-02-18 12:51:31 +0000
commit040132e1df7651e2b1ab7074759481599b02651a (patch)
treee704ef6b0e578fa1e030aa3ce30ac077387b15d7
parent2a27603f6a635b8a02be8bda599074b176b80ef1 (diff)
downloadopenbsd-040132e1df7651e2b1ab7074759481599b02651a.tar.gz
openbsd-040132e1df7651e2b1ab7074759481599b02651a.tar.bz2
openbsd-040132e1df7651e2b1ab7074759481599b02651a.zip
Provide DH_set0_pqg.
ok jsing
-rw-r--r--src/lib/libcrypto/Symbols.list1
-rw-r--r--src/lib/libcrypto/dh/dh.h3
-rw-r--r--src/lib/libcrypto/dh/dh_lib.c24
3 files changed, 26 insertions, 2 deletions
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list
index 79b2e946dc..ab4c8593d7 100644
--- a/src/lib/libcrypto/Symbols.list
+++ b/src/lib/libcrypto/Symbols.list
@@ -751,6 +751,7 @@ DH_get_ex_data
751DH_get_ex_new_index 751DH_get_ex_new_index
752DH_new 752DH_new
753DH_new_method 753DH_new_method
754DH_set0_pqg
754DH_set_default_method 755DH_set_default_method
755DH_set_ex_data 756DH_set_ex_data
756DH_set_method 757DH_set_method
diff --git a/src/lib/libcrypto/dh/dh.h b/src/lib/libcrypto/dh/dh.h
index 61c7d6c873..e5daa2cbdd 100644
--- a/src/lib/libcrypto/dh/dh.h
+++ b/src/lib/libcrypto/dh/dh.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh.h,v 1.19 2018/02/17 13:47:36 tb Exp $ */ 1/* $OpenBSD: dh.h,v 1.20 2018/02/18 12:51:31 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -190,6 +190,7 @@ void *DH_get_ex_data(DH *d, int idx);
190 190
191void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, 191void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q,
192 const BIGNUM **g); 192 const BIGNUM **g);
193int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g);
193void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key); 194void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key);
194 195
195/* Deprecated version */ 196/* Deprecated version */
diff --git a/src/lib/libcrypto/dh/dh_lib.c b/src/lib/libcrypto/dh/dh_lib.c
index 5a54ca88da..31857727e2 100644
--- a/src/lib/libcrypto/dh/dh_lib.c
+++ b/src/lib/libcrypto/dh/dh_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh_lib.c,v 1.23 2018/02/17 13:47:36 tb Exp $ */ 1/* $OpenBSD: dh_lib.c,v 1.24 2018/02/18 12:51:31 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -251,6 +251,28 @@ DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
251 *g = dh->g; 251 *g = dh->g;
252} 252}
253 253
254int
255DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g)
256{
257 if ((dh->p == NULL && p == NULL) || (dh->g == NULL && g == NULL))
258 return 0;
259
260 if (p != NULL) {
261 BN_free(dh->p);
262 dh->p = p;
263 }
264 if (q != NULL) {
265 BN_free(dh->q);
266 dh->q = q;
267 }
268 if (g != NULL) {
269 BN_free(dh->g);
270 dh->g = g;
271 }
272
273 return 1;
274}
275
254void 276void
255DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key) 277DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key)
256{ 278{