xref: /freebsd/crypto/openssl/doc/man3/DSA_generate_parameters.pod (revision a8089ea5aee578e08acab2438e82fc9a9ae50ed8)
1=pod
2
3=head1 NAME
4
5DSA_generate_parameters_ex, DSA_generate_parameters - generate DSA parameters
6
7=head1 SYNOPSIS
8
9 #include <openssl/dsa.h>
10
11The following functions have been deprecated since OpenSSL 3.0, and can be
12hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
13see L<openssl_user_macros(7)>:
14
15 int DSA_generate_parameters_ex(DSA *dsa, int bits,
16                                const unsigned char *seed, int seed_len,
17                                int *counter_ret, unsigned long *h_ret,
18                                BN_GENCB *cb);
19
20The following functions have been deprecated since OpenSSL 0.9.8, and can be
21hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
22see L<openssl_user_macros(7)>:
23
24 DSA *DSA_generate_parameters(int bits, unsigned char *seed, int seed_len,
25                              int *counter_ret, unsigned long *h_ret,
26                              void (*callback)(int, int, void *), void *cb_arg);
27
28=head1 DESCRIPTION
29
30All of the functions described on this page are deprecated.
31Applications should instead use L<EVP_PKEY_paramgen_init(3)> and
32L<EVP_PKEY_keygen(3)> as described in L<EVP_PKEY-DSA(7)>.
33
34DSA_generate_parameters_ex() generates primes p and q and a generator g
35for use in the DSA and stores the result in B<dsa>.
36
37B<bits> is the length of the prime p to be generated.
38For lengths under 2048 bits, the length of q is 160 bits; for lengths
39greater than or equal to 2048 bits, the length of q is set to 256 bits.
40
41If B<seed> is NULL, the primes will be generated at random.
42If B<seed_len> is less than the length of q, an error is returned.
43
44DSA_generate_parameters_ex() places the iteration count in
45*B<counter_ret> and a counter used for finding a generator in
46*B<h_ret>, unless these are B<NULL>.
47
48A callback function may be used to provide feedback about the progress
49of the key generation. If B<cb> is not B<NULL>, it will be
50called as shown below. For information on the BN_GENCB structure and the
51BN_GENCB_call function discussed below, refer to
52L<BN_generate_prime(3)>.
53
54DSA_generate_parameters() is similar to DSA_generate_parameters_ex() but
55expects an old-style callback function; see
56L<BN_generate_prime(3)> for information on the old-style callback.
57
58=over 2
59
60=item *
61
62When a candidate for q is generated, B<BN_GENCB_call(cb, 0, m++)> is called
63(m is 0 for the first candidate).
64
65=item *
66
67When a candidate for q has passed a test by trial division,
68B<BN_GENCB_call(cb, 1, -1)> is called.
69While a candidate for q is tested by Miller-Rabin primality tests,
70B<BN_GENCB_call(cb, 1, i)> is called in the outer loop
71(once for each witness that confirms that the candidate may be prime);
72i is the loop counter (starting at 0).
73
74=item *
75
76When a prime q has been found, B<BN_GENCB_call(cb, 2, 0)> and
77B<BN_GENCB_call(cb, 3, 0)> are called.
78
79=item *
80
81Before a candidate for p (other than the first) is generated and tested,
82B<BN_GENCB_call(cb, 0, counter)> is called.
83
84=item *
85
86When a candidate for p has passed the test by trial division,
87B<BN_GENCB_call(cb, 1, -1)> is called.
88While it is tested by the Miller-Rabin primality test,
89B<BN_GENCB_call(cb, 1, i)> is called in the outer loop
90(once for each witness that confirms that the candidate may be prime).
91i is the loop counter (starting at 0).
92
93=item *
94
95When p has been found, B<BN_GENCB_call(cb, 2, 1)> is called.
96
97=item *
98
99When the generator has been found, B<BN_GENCB_call(cb, 3, 1)> is called.
100
101=back
102
103=head1 RETURN VALUES
104
105DSA_generate_parameters_ex() returns a 1 on success, or 0 otherwise.
106The error codes can be obtained by L<ERR_get_error(3)>.
107
108DSA_generate_parameters() returns a pointer to the DSA structure or
109B<NULL> if the parameter generation fails.
110
111=head1 BUGS
112
113Seed lengths greater than 20 are not supported.
114
115=head1 SEE ALSO
116
117L<DSA_new(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>,
118L<DSA_free(3)>, L<BN_generate_prime(3)>
119
120=head1 HISTORY
121
122DSA_generate_parameters_ex() was deprecated in OpenSSL 3.0.
123
124DSA_generate_parameters() was deprecated in OpenSSL 0.9.8; use
125DSA_generate_parameters_ex() instead.
126
127=head1 COPYRIGHT
128
129Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.
130
131Licensed under the Apache License 2.0 (the "License").  You may not use
132this file except in compliance with the License.  You can obtain a copy
133in the file LICENSE in the source distribution or at
134L<https://www.openssl.org/source/license.html>.
135
136=cut
137