Fix DH_get_nid() so that it does not cache values.
authorShane Lontis <shane.lontis@oracle.com>
Mon, 20 Apr 2020 01:07:38 +0000 (11:07 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Mon, 20 Apr 2020 01:07:38 +0000 (11:07 +1000)
commit738ee1819e3bb94723701fb505ce2971afe47a9b
tree2fd8588534087594f2371060c20bc6890d39a33a
parent9e537cd2ad01b172f2700a670e9269075078a426
Fix DH_get_nid() so that it does not cache values.

DH_set0_pqg() is now responsible for caching the nid, q and length.

DH with or without named safe prime groups now default to using the maximum private key length (BN_num_bits(q) - 1)
when generating a DH private key. The code is now shared between fips and non fips mode for DH key generation.

The OSSL_PKEY_PARAM_DH_PRIV_LEN parameter can be used during keygen to override the maximum private key length to be
in the range (2 * strength ... bits(q) - 1). Where the strength depends on the length of p.

Added q = (p - 1) / 2 safe prime BIGNUMS so that the code is data driven (To simplify adding new names).
The BIGNUMS were code generated.

Fix error in documented return value for DH_get_nid

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11562)
19 files changed:
crypto/bn/bn_dh.c
crypto/dh/dh_ameth.c
crypto/dh/dh_group_params.c
crypto/dh/dh_key.c
crypto/dh/dh_lib.c
crypto/dh/dh_local.h
crypto/dsa/dsa_key.c
crypto/ffc/ffc_key_generate.c
doc/man3/DH_get0_pqg.pod
doc/man3/DH_new_by_nid.pod
include/crypto/bn_dh.h
include/crypto/dh.h
include/internal/ffc.h
include/openssl/core_names.h
include/openssl/dh.h
providers/implementations/keymgmt/dh_kmgmt.c
test/evp_pkey_provided_test.c
test/ffc_internal_test.c
test/recipes/15-test_gendh.t