summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/dh/dh_lib.c
diff options
context:
space:
mode:
authortb <>2018-02-18 14:58:12 +0000
committertb <>2018-02-18 14:58:12 +0000
commitf45fe1036a32cd14875d1619aab61bc0753012a3 (patch)
tree2f49be312f3f68a1760dd001d14bafc0a40e6123 /src/lib/libcrypto/dh/dh_lib.c
parent9423d420e1df8c8d890d97c34da30188d2d378f5 (diff)
downloadopenbsd-f45fe1036a32cd14875d1619aab61bc0753012a3.tar.gz
openbsd-f45fe1036a32cd14875d1619aab61bc0753012a3.tar.bz2
openbsd-f45fe1036a32cd14875d1619aab61bc0753012a3.zip
Provide {DH,DSA}_set0_key(). Requested by sthen.
ok jsing
Diffstat (limited to 'src/lib/libcrypto/dh/dh_lib.c')
-rw-r--r--src/lib/libcrypto/dh/dh_lib.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/lib/libcrypto/dh/dh_lib.c b/src/lib/libcrypto/dh/dh_lib.c
index 31857727e2..bb2ca426a0 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.24 2018/02/18 12:51:31 tb Exp $ */ 1/* $OpenBSD: dh_lib.c,v 1.25 2018/02/18 14:58:12 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 *
@@ -281,3 +281,22 @@ DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key)
281 if (priv_key != NULL) 281 if (priv_key != NULL)
282 *priv_key = dh->priv_key; 282 *priv_key = dh->priv_key;
283} 283}
284
285int
286DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key)
287{
288 if ((dh->pub_key == NULL && pub_key == NULL) ||
289 (dh->priv_key == NULL && priv_key == NULL))
290 return 0;
291
292 if (pub_key != NULL) {
293 BN_free(dh->pub_key);
294 dh->pub_key = pub_key;
295 }
296 if (priv_key != NULL) {
297 BN_free(dh->priv_key);
298 dh->priv_key = priv_key;
299 }
300
301 return 1;
302}