xref: /freebsd-src/crypto/openssl/doc/man3/DH_generate_parameters.pod (revision e71b70530d95c4f34d8bdbd78d1242df1ba4a945)
1*e71b7053SJung-uk Kim=pod
2*e71b7053SJung-uk Kim
3*e71b7053SJung-uk Kim=head1 NAME
4*e71b7053SJung-uk Kim
5*e71b7053SJung-uk KimDH_generate_parameters_ex, DH_generate_parameters,
6*e71b7053SJung-uk KimDH_check, DH_check_params,
7*e71b7053SJung-uk KimDH_check_ex, DH_check_params_ex, DH_check_pub_key_ex
8*e71b7053SJung-uk Kim- generate and check Diffie-Hellman
9*e71b7053SJung-uk Kimparameters
10*e71b7053SJung-uk Kim
11*e71b7053SJung-uk Kim=head1 SYNOPSIS
12*e71b7053SJung-uk Kim
13*e71b7053SJung-uk Kim #include <openssl/dh.h>
14*e71b7053SJung-uk Kim
15*e71b7053SJung-uk Kim int DH_generate_parameters_ex(DH *dh, int prime_len, int generator, BN_GENCB *cb);
16*e71b7053SJung-uk Kim
17*e71b7053SJung-uk Kim int DH_check(DH *dh, int *codes);
18*e71b7053SJung-uk Kim int DH_check_params(DH *dh, int *codes);
19*e71b7053SJung-uk Kim
20*e71b7053SJung-uk Kim int DH_check_ex(const DH *dh);
21*e71b7053SJung-uk Kim int DH_check_params_ex(const DH *dh);
22*e71b7053SJung-uk Kim int DH_check_pub_key_ex(const DH *dh, const BIGNUM *pub_key);
23*e71b7053SJung-uk Kim
24*e71b7053SJung-uk KimDeprecated:
25*e71b7053SJung-uk Kim
26*e71b7053SJung-uk Kim #if OPENSSL_API_COMPAT < 0x00908000L
27*e71b7053SJung-uk Kim DH *DH_generate_parameters(int prime_len, int generator,
28*e71b7053SJung-uk Kim                            void (*callback)(int, int, void *), void *cb_arg);
29*e71b7053SJung-uk Kim #endif
30*e71b7053SJung-uk Kim
31*e71b7053SJung-uk Kim=head1 DESCRIPTION
32*e71b7053SJung-uk Kim
33*e71b7053SJung-uk KimDH_generate_parameters_ex() generates Diffie-Hellman parameters that can
34*e71b7053SJung-uk Kimbe shared among a group of users, and stores them in the provided B<DH>
35*e71b7053SJung-uk Kimstructure. The pseudo-random number generator must be
36*e71b7053SJung-uk Kimseeded before calling it.
37*e71b7053SJung-uk KimThe parameters generated by DH_generate_parameters_ex() should not be used in
38*e71b7053SJung-uk Kimsignature schemes.
39*e71b7053SJung-uk Kim
40*e71b7053SJung-uk KimB<prime_len> is the length in bits of the safe prime to be generated.
41*e71b7053SJung-uk KimB<generator> is a small number E<gt> 1, typically 2 or 5.
42*e71b7053SJung-uk Kim
43*e71b7053SJung-uk KimA callback function may be used to provide feedback about the progress
44*e71b7053SJung-uk Kimof the key generation. If B<cb> is not B<NULL>, it will be
45*e71b7053SJung-uk Kimcalled as described in L<BN_generate_prime(3)> while a random prime
46*e71b7053SJung-uk Kimnumber is generated, and when a prime has been found, B<BN_GENCB_call(cb, 3, 0)>
47*e71b7053SJung-uk Kimis called. See L<BN_generate_prime_ex(3)> for information on
48*e71b7053SJung-uk Kimthe BN_GENCB_call() function.
49*e71b7053SJung-uk Kim
50*e71b7053SJung-uk KimDH_generate_parameters() is similar to DH_generate_prime_ex() but
51*e71b7053SJung-uk Kimexpects an old-style callback function; see
52*e71b7053SJung-uk KimL<BN_generate_prime(3)> for information on the old-style callback.
53*e71b7053SJung-uk Kim
54*e71b7053SJung-uk KimDH_check_params() confirms that the B<p> and B<g> are likely enough to
55*e71b7053SJung-uk Kimbe valid.
56*e71b7053SJung-uk KimThis is a lightweight check, if a more thorough check is needed, use
57*e71b7053SJung-uk KimDH_check().
58*e71b7053SJung-uk KimThe value of B<*codes> is updated with any problems found.
59*e71b7053SJung-uk KimIf B<*codes> is zero then no problems were found, otherwise the
60*e71b7053SJung-uk Kimfollowing bits may be set:
61*e71b7053SJung-uk Kim
62*e71b7053SJung-uk Kim=over 4
63*e71b7053SJung-uk Kim
64*e71b7053SJung-uk Kim=item DH_CHECK_P_NOT_PRIME
65*e71b7053SJung-uk Kim
66*e71b7053SJung-uk KimThe parameter B<p> has been determined to not being an odd prime.
67*e71b7053SJung-uk KimNote that the lack of this bit doesn't guarantee that B<p> is a
68*e71b7053SJung-uk Kimprime.
69*e71b7053SJung-uk Kim
70*e71b7053SJung-uk Kim=item DH_NOT_SUITABLE_GENERATOR
71*e71b7053SJung-uk Kim
72*e71b7053SJung-uk KimThe generator B<g> is not suitable.
73*e71b7053SJung-uk KimNote that the lack of this bit doesn't guarantee that B<g> is
74*e71b7053SJung-uk Kimsuitable, unless B<p> is known to be a strong prime.
75*e71b7053SJung-uk Kim
76*e71b7053SJung-uk Kim=back
77*e71b7053SJung-uk Kim
78*e71b7053SJung-uk KimDH_check() confirms that the Diffie-Hellman parameters B<dh> are valid. The
79*e71b7053SJung-uk Kimvalue of B<*codes> is updated with any problems found. If B<*codes> is zero then
80*e71b7053SJung-uk Kimno problems were found, otherwise the following bits may be set:
81*e71b7053SJung-uk Kim
82*e71b7053SJung-uk Kim=over 4
83*e71b7053SJung-uk Kim
84*e71b7053SJung-uk Kim=item DH_CHECK_P_NOT_PRIME
85*e71b7053SJung-uk Kim
86*e71b7053SJung-uk KimThe parameter B<p> is not prime.
87*e71b7053SJung-uk Kim
88*e71b7053SJung-uk Kim=item DH_CHECK_P_NOT_SAFE_PRIME
89*e71b7053SJung-uk Kim
90*e71b7053SJung-uk KimThe parameter B<p> is not a safe prime and no B<q> value is present.
91*e71b7053SJung-uk Kim
92*e71b7053SJung-uk Kim=item DH_UNABLE_TO_CHECK_GENERATOR
93*e71b7053SJung-uk Kim
94*e71b7053SJung-uk KimThe generator B<g> cannot be checked for suitability.
95*e71b7053SJung-uk Kim
96*e71b7053SJung-uk Kim=item DH_NOT_SUITABLE_GENERATOR
97*e71b7053SJung-uk Kim
98*e71b7053SJung-uk KimThe generator B<g> is not suitable.
99*e71b7053SJung-uk Kim
100*e71b7053SJung-uk Kim=item DH_CHECK_Q_NOT_PRIME
101*e71b7053SJung-uk Kim
102*e71b7053SJung-uk KimThe parameter B<q> is not prime.
103*e71b7053SJung-uk Kim
104*e71b7053SJung-uk Kim=item DH_CHECK_INVALID_Q_VALUE
105*e71b7053SJung-uk Kim
106*e71b7053SJung-uk KimThe parameter B<q> is invalid.
107*e71b7053SJung-uk Kim
108*e71b7053SJung-uk Kim=item DH_CHECK_INVALID_J_VALUE
109*e71b7053SJung-uk Kim
110*e71b7053SJung-uk KimThe parameter B<j> is invalid.
111*e71b7053SJung-uk Kim
112*e71b7053SJung-uk Kim=back
113*e71b7053SJung-uk Kim
114*e71b7053SJung-uk KimDH_check_ex(), DH_check_params() and DH_check_pub_key_ex() are similar to
115*e71b7053SJung-uk KimDH_check() and DH_check_params() respectively, but the error reasons are added
116*e71b7053SJung-uk Kimto the thread's error queue instead of provided as return values from the
117*e71b7053SJung-uk Kimfunction.
118*e71b7053SJung-uk Kim
119*e71b7053SJung-uk Kim=head1 RETURN VALUES
120*e71b7053SJung-uk Kim
121*e71b7053SJung-uk KimDH_generate_parameters_ex(), DH_check() and DH_check_params() return 1
122*e71b7053SJung-uk Kimif the check could be performed, 0 otherwise.
123*e71b7053SJung-uk Kim
124*e71b7053SJung-uk KimDH_generate_parameters() returns a pointer to the DH structure or NULL if
125*e71b7053SJung-uk Kimthe parameter generation fails.
126*e71b7053SJung-uk Kim
127*e71b7053SJung-uk KimDH_check_ex(), DH_check_params() and DH_check_pub_key_ex() return 1 if the
128*e71b7053SJung-uk Kimcheck is successful, 0 for failed.
129*e71b7053SJung-uk Kim
130*e71b7053SJung-uk KimThe error codes can be obtained by L<ERR_get_error(3)>.
131*e71b7053SJung-uk Kim
132*e71b7053SJung-uk Kim=head1 SEE ALSO
133*e71b7053SJung-uk Kim
134*e71b7053SJung-uk KimL<DH_new(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>,
135*e71b7053SJung-uk KimL<DH_free(3)>
136*e71b7053SJung-uk Kim
137*e71b7053SJung-uk Kim=head1 HISTORY
138*e71b7053SJung-uk Kim
139*e71b7053SJung-uk KimDH_generate_parameters() was deprecated in OpenSSL 0.9.8; use
140*e71b7053SJung-uk KimDH_generate_parameters_ex() instead.
141*e71b7053SJung-uk Kim
142*e71b7053SJung-uk Kim=head1 COPYRIGHT
143*e71b7053SJung-uk Kim
144*e71b7053SJung-uk KimCopyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
145*e71b7053SJung-uk Kim
146*e71b7053SJung-uk KimLicensed under the OpenSSL license (the "License").  You may not use
147*e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
148*e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
149*e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
150*e71b7053SJung-uk Kim
151*e71b7053SJung-uk Kim=cut
152