xref: /freebsd/secure/lib/libcrypto/man/man3/DH_generate_parameters.3 (revision 1da7f3f6f72b2245e458fc7195733268ae4a1136)
Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)

Standard preamble:
========================================================================
..
..
.. Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. \*(C+ will
give a nicer C++. Capital omega is used to do unbreakable dashes and
therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
nothing in troff, for use with C<>.
.tr \(*W- . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.

If the F register is >0, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.

Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] .\} . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents . \" corrections for vroff . \" for low resolution devices (crt and lpr) \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} ========================================================================

Title "DH_GENERATE_PARAMETERS 3ossl"
DH_GENERATE_PARAMETERS 3ossl "2023-09-19" "3.0.11" "OpenSSL"
For nroff, turn off justification. Always turn off hyphenation; it makes
way too many mistakes in technical documents.
"NAME"
DH_generate_parameters_ex, DH_generate_parameters, DH_check, DH_check_params, DH_check_ex, DH_check_params_ex, DH_check_pub_key_ex \- generate and check Diffie-Hellman parameters
"SYNOPSIS"
Header "SYNOPSIS" .Vb 1 #include <openssl/dh.h> .Ve

The following functions have been deprecated since OpenSSL 3.0, and can be hidden entirely by defining \s-1OPENSSL_API_COMPAT\s0 with a suitable version value, see openssl_user_macros\|(7):

.Vb 1 int DH_generate_parameters_ex(DH *dh, int prime_len, int generator, BN_GENCB *cb); \& int DH_check(DH *dh, int *codes); int DH_check_params(DH *dh, int *codes); \& int DH_check_ex(const DH *dh); int DH_check_params_ex(const DH *dh); int DH_check_pub_key_ex(const DH *dh, const BIGNUM *pub_key); .Ve

The following functions have been deprecated since OpenSSL 0.9.8, and can be hidden entirely by defining \s-1OPENSSL_API_COMPAT\s0 with a suitable version value, see openssl_user_macros\|(7):

.Vb 2 DH *DH_generate_parameters(int prime_len, int generator, void (*callback)(int, int, void *), void *cb_arg); .Ve

"DESCRIPTION"
Header "DESCRIPTION" All of the functions described on this page are deprecated. Applications should instead use EVP_PKEY_check\|(3), \fBEVP_PKEY_public_check\|(3), EVP_PKEY_private_check\|(3) and \fBEVP_PKEY_param_check\|(3).

\fBDH_generate_parameters_ex() generates Diffie-Hellman parameters that can be shared among a group of users, and stores them in the provided \s-1DH\s0 structure. The pseudo-random number generator must be seeded before calling it. The parameters generated by DH_generate_parameters_ex() should not be used in signature schemes.

\fBprime_len is the length in bits of the safe prime to be generated. \fBgenerator is a small number > 1, typically 2 or 5.

A callback function may be used to provide feedback about the progress of the key generation. If cb is not \s-1NULL\s0, it will be called as described in BN_generate_prime\|(3) while a random prime number is generated, and when a prime has been found, BN_GENCB_call(cb, 3, 0) is called. See BN_generate_prime_ex\|(3) for information on the BN_GENCB_call() function.

\fBDH_generate_parameters() is similar to DH_generate_prime_ex() but expects an old-style callback function; see \fBBN_generate_prime\|(3) for information on the old-style callback.

\fBDH_check_params() confirms that the p and g are likely enough to be valid. This is a lightweight check, if a more thorough check is needed, use \fBDH_check(). The value of *codes is updated with any problems found. If *codes is zero then no problems were found, otherwise the following bits may be set:

"\s-1DH_CHECK_P_NOT_PRIME\s0" 4
Item "DH_CHECK_P_NOT_PRIME" The parameter p has been determined to not being an odd prime. Note that the lack of this bit doesn't guarantee that p is a prime.
"\s-1DH_NOT_SUITABLE_GENERATOR\s0" 4
Item "DH_NOT_SUITABLE_GENERATOR" The generator g is not suitable. Note that the lack of this bit doesn't guarantee that g is suitable, unless p is known to be a strong prime.
"\s-1DH_MODULUS_TOO_SMALL\s0" 4
Item "DH_MODULUS_TOO_SMALL" The modulus is too small.
"\s-1DH_MODULUS_TOO_LARGE\s0" 4
Item "DH_MODULUS_TOO_LARGE" The modulus is too large.

\fBDH_check() confirms that the Diffie-Hellman parameters dh are valid. The value of *codes is updated with any problems found. If *codes is zero then no problems were found, otherwise the following bits may be set:

"\s-1DH_CHECK_P_NOT_PRIME\s0" 4
Item "DH_CHECK_P_NOT_PRIME" The parameter p is not prime.
"\s-1DH_CHECK_P_NOT_SAFE_PRIME\s0" 4
Item "DH_CHECK_P_NOT_SAFE_PRIME" The parameter p is not a safe prime and no q value is present.
"\s-1DH_UNABLE_TO_CHECK_GENERATOR\s0" 4
Item "DH_UNABLE_TO_CHECK_GENERATOR" The generator g cannot be checked for suitability.
"\s-1DH_NOT_SUITABLE_GENERATOR\s0" 4
Item "DH_NOT_SUITABLE_GENERATOR" The generator g is not suitable.
"\s-1DH_CHECK_Q_NOT_PRIME\s0" 4
Item "DH_CHECK_Q_NOT_PRIME" The parameter q is not prime.
"\s-1DH_CHECK_INVALID_Q_VALUE\s0" 4
Item "DH_CHECK_INVALID_Q_VALUE" The parameter q is invalid.
"\s-1DH_CHECK_INVALID_J_VALUE\s0" 4
Item "DH_CHECK_INVALID_J_VALUE" The parameter j is invalid.

\fBDH_check_ex(), DH_check_params() and DH_check_pub_key_ex() are similar to \fBDH_check() and DH_check_params() respectively, but the error reasons are added to the thread's error queue instead of provided as return values from the function.

"RETURN VALUES"
Header "RETURN VALUES" \fBDH_generate_parameters_ex(), DH_check() and DH_check_params() return 1 if the check could be performed, 0 otherwise.

\fBDH_generate_parameters() returns a pointer to the \s-1DH\s0 structure or \s-1NULL\s0 if the parameter generation fails.

\fBDH_check_ex(), DH_check_params() and DH_check_pub_key_ex() return 1 if the check is successful, 0 for failed.

The error codes can be obtained by ERR_get_error\|(3).

"SEE ALSO"
Header "SEE ALSO" \fBDH_new\|(3), ERR_get_error\|(3), RAND_bytes\|(3), \fBDH_free\|(3)
"HISTORY"
Header "HISTORY" All of these functions were deprecated in OpenSSL 3.0.

\fBDH_generate_parameters() was deprecated in OpenSSL 0.9.8; use \fBDH_generate_parameters_ex() instead.

"COPYRIGHT"
Header "COPYRIGHT" Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use this file except in compliance with the License. You can obtain a copy in the file \s-1LICENSE\s0 in the source distribution or at <https://www.openssl.org/source/license.html>.