From 040132e1df7651e2b1ab7074759481599b02651a Mon Sep 17 00:00:00 2001 From: tb <> Date: Sun, 18 Feb 2018 12:51:31 +0000 Subject: Provide DH_set0_pqg. ok jsing --- src/lib/libcrypto/Symbols.list | 1 + src/lib/libcrypto/dh/dh.h | 3 ++- src/lib/libcrypto/dh/dh_lib.c | 24 +++++++++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) (limited to 'src') 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 DH_get_ex_new_index DH_new DH_new_method +DH_set0_pqg DH_set_default_method DH_set_ex_data DH_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 @@ -/* $OpenBSD: dh.h,v 1.19 2018/02/17 13:47:36 tb Exp $ */ +/* $OpenBSD: dh.h,v 1.20 2018/02/18 12:51:31 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -190,6 +190,7 @@ void *DH_get_ex_data(DH *d, int idx); void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); +int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key); /* 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 @@ -/* $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) { -- cgit v1.2.3-55-g6feb