diff options
author | tb <> | 2022-06-27 12:31:38 +0000 |
---|---|---|
committer | tb <> | 2022-06-27 12:31:38 +0000 |
commit | 1f814fdc3f1d1d90cbcbff70c5aadcf9da362c34 (patch) | |
tree | 931e6b745022209240526123ee6e1211a6334fdc /src | |
parent | 480c1f602005c8b8ae31165e5edd93ad31443164 (diff) | |
download | openbsd-1f814fdc3f1d1d90cbcbff70c5aadcf9da362c34.tar.gz openbsd-1f814fdc3f1d1d90cbcbff70c5aadcf9da362c34.tar.bz2 openbsd-1f814fdc3f1d1d90cbcbff70c5aadcf9da362c34.zip |
Prepare to provide DH_security_bits()
ok beck jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/dh/dh.h | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/dh/dh_lib.c | 15 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/lib/libcrypto/dh/dh.h b/src/lib/libcrypto/dh/dh.h index ef10495029..c7f4d3fdd0 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.32 2022/01/14 08:25:44 tb Exp $ */ | 1 | /* $OpenBSD: dh.h,v 1.33 2022/06/27 12:31:38 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 | * |
@@ -143,6 +143,9 @@ int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | |||
143 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); | 143 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); |
144 | int DH_set_ex_data(DH *d, int idx, void *arg); | 144 | int DH_set_ex_data(DH *d, int idx, void *arg); |
145 | void *DH_get_ex_data(DH *d, int idx); | 145 | void *DH_get_ex_data(DH *d, int idx); |
146 | #ifdef LIBRESSL_INTERNAL | ||
147 | int DH_security_bits(const DH *dh); | ||
148 | #endif | ||
146 | 149 | ||
147 | ENGINE *DH_get0_engine(DH *d); | 150 | ENGINE *DH_get0_engine(DH *d); |
148 | void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, | 151 | void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, |
diff --git a/src/lib/libcrypto/dh/dh_lib.c b/src/lib/libcrypto/dh/dh_lib.c index d4d0c9dda3..35a22d1ec8 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.36 2022/01/07 09:27:13 tb Exp $ */ | 1 | /* $OpenBSD: dh_lib.c,v 1.37 2022/06/27 12:31:38 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 | * |
@@ -245,6 +245,19 @@ DH_bits(const DH *dh) | |||
245 | return BN_num_bits(dh->p); | 245 | return BN_num_bits(dh->p); |
246 | } | 246 | } |
247 | 247 | ||
248 | int | ||
249 | DH_security_bits(const DH *dh) | ||
250 | { | ||
251 | int N = -1; | ||
252 | |||
253 | if (dh->q != NULL) | ||
254 | N = BN_num_bits(dh->q); | ||
255 | else if (dh->length > 0) | ||
256 | N = dh->length; | ||
257 | |||
258 | return BN_security_bits(BN_num_bits(dh->p), N); | ||
259 | } | ||
260 | |||
248 | ENGINE * | 261 | ENGINE * |
249 | DH_get0_engine(DH *dh) | 262 | DH_get0_engine(DH *dh) |
250 | { | 263 | { |