From: tb Date: Wed, 5 Jan 2022 20:30:16 +0000 (+0000) Subject: Prepare to provide DH_get0_{p,q,g,{priv,pub}_key}() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d742c600f2cb136c48cd652209a0552f7a1e93cb;p=openbsd Prepare to provide DH_get0_{p,q,g,{priv,pub}_key}() These are accessors that allow getting one specific DH member. They are less error prone than the current getters DH_get0_{pqg,key}(). They are used by many ports and will also be used in base for this reason. Who can remember whether the pub_key or the priv_key goes first in DH_get0_key()? ok inoguchi jsing --- diff --git a/lib/libcrypto/dh/dh.h b/lib/libcrypto/dh/dh.h index f569f3f7c34..8e57c191c42 100644 --- a/lib/libcrypto/dh/dh.h +++ b/lib/libcrypto/dh/dh.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dh.h,v 1.26 2021/11/29 19:34:51 tb Exp $ */ +/* $OpenBSD: dh.h,v 1.27 2022/01/05 20:30:16 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -199,6 +199,13 @@ void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, 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); int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key); +#if defined(LIBRESSL_OPAQUE_DH) || defined(LIBRESSL_CRYPTO_INTERNAL) +const BIGNUM *DH_get0_p(const DH *dh); +const BIGNUM *DH_get0_q(const DH *dh); +const BIGNUM *DH_get0_g(const DH *dh); +const BIGNUM *DH_get0_priv_key(const DH *dh); +const BIGNUM *DH_get0_pub_key(const DH *dh); +#endif void DH_clear_flags(DH *dh, int flags); int DH_test_flags(const DH *dh, int flags); void DH_set_flags(DH *dh, int flags); diff --git a/lib/libcrypto/dh/dh_lib.c b/lib/libcrypto/dh/dh_lib.c index a66ed1f5bf0..58f01b6e6af 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.33 2021/11/23 09:53:45 tb Exp $ */ +/* $OpenBSD: dh_lib.c,v 1.34 2022/01/05 20:30:16 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -307,6 +307,36 @@ DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key) return 1; } +const BIGNUM * +DH_get0_p(const DH *dh) +{ + return dh->p; +} + +const BIGNUM * +DH_get0_q(const DH *dh) +{ + return dh->q; +} + +const BIGNUM * +DH_get0_g(const DH *dh) +{ + return dh->g; +} + +const BIGNUM * +DH_get0_priv_key(const DH *dh) +{ + return dh->priv_key; +} + +const BIGNUM * +DH_get0_pub_key(const DH *dh) +{ + return dh->pub_key; +} + void DH_clear_flags(DH *dh, int flags) {