1DH_GENERATE_PARAMETERS(3ossl) OpenSSL DH_GENERATE_PARAMETERS(3ossl)
2
3
4
6 DH_generate_parameters_ex, DH_generate_parameters, DH_check,
7 DH_check_params, DH_check_ex, DH_check_params_ex, DH_check_pub_key_ex -
8 generate and check Diffie-Hellman parameters
9
11 #include <openssl/dh.h>
12
13 The following functions have been deprecated since OpenSSL 3.0, and can
14 be hidden entirely by defining OPENSSL_API_COMPAT with a suitable
15 version value, see openssl_user_macros(7):
16
17 int DH_generate_parameters_ex(DH *dh, int prime_len, int generator, BN_GENCB *cb);
18
19 int DH_check(DH *dh, int *codes);
20 int DH_check_params(DH *dh, int *codes);
21
22 int DH_check_ex(const DH *dh);
23 int DH_check_params_ex(const DH *dh);
24 int DH_check_pub_key_ex(const DH *dh, const BIGNUM *pub_key);
25
26 The following functions have been deprecated since OpenSSL 0.9.8, and
27 can be hidden entirely by defining OPENSSL_API_COMPAT with a suitable
28 version value, see openssl_user_macros(7):
29
30 DH *DH_generate_parameters(int prime_len, int generator,
31 void (*callback)(int, int, void *), void *cb_arg);
32
34 All of the functions described on this page are deprecated.
35 Applications should instead use EVP_PKEY_check(3),
36 EVP_PKEY_public_check(3), EVP_PKEY_private_check(3) and
37 EVP_PKEY_param_check(3).
38
39 DH_generate_parameters_ex() generates Diffie-Hellman parameters that
40 can be shared among a group of users, and stores them in the provided
41 DH structure. The pseudo-random number generator must be seeded before
42 calling it. The parameters generated by DH_generate_parameters_ex()
43 should not be used in signature schemes.
44
45 prime_len is the length in bits of the safe prime to be generated.
46 generator is a small number > 1, typically 2 or 5.
47
48 A callback function may be used to provide feedback about the progress
49 of the key generation. If cb is not NULL, it will be called as
50 described in BN_generate_prime(3) while a random prime number is
51 generated, and when a prime has been found, BN_GENCB_call(cb, 3, 0) is
52 called. See BN_generate_prime_ex(3) for information on the
53 BN_GENCB_call() function.
54
55 DH_generate_parameters() is similar to DH_generate_prime_ex() but
56 expects an old-style callback function; see BN_generate_prime(3) for
57 information on the old-style callback.
58
59 DH_check_params() confirms that the p and g are likely enough to be
60 valid. This is a lightweight check, if a more thorough check is
61 needed, use DH_check(). The value of *codes is updated with any
62 problems found. If *codes is zero then no problems were found,
63 otherwise the following bits may be set:
64
65 DH_CHECK_P_NOT_PRIME
66 The parameter p has been determined to not being an odd prime.
67 Note that the lack of this bit doesn't guarantee that p is a prime.
68
69 DH_NOT_SUITABLE_GENERATOR
70 The generator g is not suitable. Note that the lack of this bit
71 doesn't guarantee that g is suitable, unless p is known to be a
72 strong prime.
73
74 DH_MODULUS_TOO_SMALL
75 The modulus is too small.
76
77 DH_MODULUS_TOO_LARGE
78 The modulus is too large.
79
80 DH_check() confirms that the Diffie-Hellman parameters dh are valid.
81 The value of *codes is updated with any problems found. If *codes is
82 zero then no problems were found, otherwise the following bits may be
83 set:
84
85 DH_CHECK_P_NOT_PRIME
86 The parameter p is not prime.
87
88 DH_CHECK_P_NOT_SAFE_PRIME
89 The parameter p is not a safe prime and no q value is present.
90
91 DH_UNABLE_TO_CHECK_GENERATOR
92 The generator g cannot be checked for suitability.
93
94 DH_NOT_SUITABLE_GENERATOR
95 The generator g is not suitable.
96
97 DH_CHECK_Q_NOT_PRIME
98 The parameter q is not prime.
99
100 DH_CHECK_INVALID_Q_VALUE
101 The parameter q is invalid.
102
103 DH_CHECK_INVALID_J_VALUE
104 The parameter j is invalid.
105
106 DH_check_ex(), DH_check_params() and DH_check_pub_key_ex() are similar
107 to DH_check() and DH_check_params() respectively, but the error reasons
108 are added to the thread's error queue instead of provided as return
109 values from the function.
110
112 DH_generate_parameters_ex(), DH_check() and DH_check_params() return 1
113 if the check could be performed, 0 otherwise.
114
115 DH_generate_parameters() returns a pointer to the DH structure or NULL
116 if the parameter generation fails.
117
118 DH_check_ex(), DH_check_params() and DH_check_pub_key_ex() return 1 if
119 the check is successful, 0 for failed.
120
121 The error codes can be obtained by ERR_get_error(3).
122
124 DH_new(3), ERR_get_error(3), RAND_bytes(3), DH_free(3)
125
127 All of these functions were deprecated in OpenSSL 3.0.
128
129 DH_generate_parameters() was deprecated in OpenSSL 0.9.8; use
130 DH_generate_parameters_ex() instead.
131
133 Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
134
135 Licensed under the Apache License 2.0 (the "License"). You may not use
136 this file except in compliance with the License. You can obtain a copy
137 in the file LICENSE in the source distribution or at
138 <https://www.openssl.org/source/license.html>.
139
140
141
1423.0.5 2022-07-05 DH_GENERATE_PARAMETERS(3ossl)