From: tb Date: Sun, 18 Feb 2018 12:51:31 +0000 (+0000) Subject: Provide DH_set0_pqg. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8216844adf5354a75b9d41677ddc0835dbdcdc23;p=openbsd Provide DH_set0_pqg. ok jsing --- diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index 79b2e946dc0..ab4c8593d7e 100644 --- a/lib/libcrypto/Symbols.list +++ b/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/lib/libcrypto/dh/dh.h b/lib/libcrypto/dh/dh.h index 61c7d6c873d..e5daa2cbdd6 100644 --- a/lib/libcrypto/dh/dh.h +++ b/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/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) {