diff options
author | tb <> | 2022-01-05 20:30:16 +0000 |
---|---|---|
committer | tb <> | 2022-01-05 20:30:16 +0000 |
commit | b86fb16a7f2ecb74d2fd9c11640ea10f44a18497 (patch) | |
tree | b748d90efbcd3ee528dd36bf85cdae37b207ce00 /src/lib | |
parent | 21c9a0ff72332d0ed2c5b5bd6f41a189b9fc2685 (diff) | |
download | openbsd-b86fb16a7f2ecb74d2fd9c11640ea10f44a18497.tar.gz openbsd-b86fb16a7f2ecb74d2fd9c11640ea10f44a18497.tar.bz2 openbsd-b86fb16a7f2ecb74d2fd9c11640ea10f44a18497.zip |
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
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/dh/dh.h | 9 | ||||
-rw-r--r-- | src/lib/libcrypto/dh/dh_lib.c | 32 |
2 files changed, 39 insertions, 2 deletions
diff --git a/src/lib/libcrypto/dh/dh.h b/src/lib/libcrypto/dh/dh.h index f569f3f7c3..8e57c191c4 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.26 2021/11/29 19:34:51 tb Exp $ */ | 1 | /* $OpenBSD: dh.h,v 1.27 2022/01/05 20:30:16 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 | * |
@@ -199,6 +199,13 @@ void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, | |||
199 | int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); | 199 | int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); |
200 | void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key); | 200 | void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key); |
201 | int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key); | 201 | int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key); |
202 | #if defined(LIBRESSL_OPAQUE_DH) || defined(LIBRESSL_CRYPTO_INTERNAL) | ||
203 | const BIGNUM *DH_get0_p(const DH *dh); | ||
204 | const BIGNUM *DH_get0_q(const DH *dh); | ||
205 | const BIGNUM *DH_get0_g(const DH *dh); | ||
206 | const BIGNUM *DH_get0_priv_key(const DH *dh); | ||
207 | const BIGNUM *DH_get0_pub_key(const DH *dh); | ||
208 | #endif | ||
202 | void DH_clear_flags(DH *dh, int flags); | 209 | void DH_clear_flags(DH *dh, int flags); |
203 | int DH_test_flags(const DH *dh, int flags); | 210 | int DH_test_flags(const DH *dh, int flags); |
204 | void DH_set_flags(DH *dh, int flags); | 211 | void DH_set_flags(DH *dh, int flags); |
diff --git a/src/lib/libcrypto/dh/dh_lib.c b/src/lib/libcrypto/dh/dh_lib.c index a66ed1f5bf..58f01b6e6a 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.33 2021/11/23 09:53:45 tb Exp $ */ | 1 | /* $OpenBSD: dh_lib.c,v 1.34 2022/01/05 20:30:16 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 | * |
@@ -307,6 +307,36 @@ DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key) | |||
307 | return 1; | 307 | return 1; |
308 | } | 308 | } |
309 | 309 | ||
310 | const BIGNUM * | ||
311 | DH_get0_p(const DH *dh) | ||
312 | { | ||
313 | return dh->p; | ||
314 | } | ||
315 | |||
316 | const BIGNUM * | ||
317 | DH_get0_q(const DH *dh) | ||
318 | { | ||
319 | return dh->q; | ||
320 | } | ||
321 | |||
322 | const BIGNUM * | ||
323 | DH_get0_g(const DH *dh) | ||
324 | { | ||
325 | return dh->g; | ||
326 | } | ||
327 | |||
328 | const BIGNUM * | ||
329 | DH_get0_priv_key(const DH *dh) | ||
330 | { | ||
331 | return dh->priv_key; | ||
332 | } | ||
333 | |||
334 | const BIGNUM * | ||
335 | DH_get0_pub_key(const DH *dh) | ||
336 | { | ||
337 | return dh->pub_key; | ||
338 | } | ||
339 | |||
310 | void | 340 | void |
311 | DH_clear_flags(DH *dh, int flags) | 341 | DH_clear_flags(DH *dh, int flags) |
312 | { | 342 | { |