From 1f814fdc3f1d1d90cbcbff70c5aadcf9da362c34 Mon Sep 17 00:00:00 2001 From: tb <> Date: Mon, 27 Jun 2022 12:31:38 +0000 Subject: Prepare to provide DH_security_bits() ok beck jsing --- src/lib/libcrypto/dh/dh_lib.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/lib/libcrypto/dh/dh_lib.c') 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 @@ -/* $OpenBSD: dh_lib.c,v 1.36 2022/01/07 09:27:13 tb Exp $ */ +/* $OpenBSD: dh_lib.c,v 1.37 2022/06/27 12:31:38 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -245,6 +245,19 @@ DH_bits(const DH *dh) return BN_num_bits(dh->p); } +int +DH_security_bits(const DH *dh) +{ + int N = -1; + + if (dh->q != NULL) + N = BN_num_bits(dh->q); + else if (dh->length > 0) + N = dh->length; + + return BN_security_bits(BN_num_bits(dh->p), N); +} + ENGINE * DH_get0_engine(DH *dh) { -- cgit v1.2.3-55-g6feb