xref: /freebsd-src/crypto/openssl/doc/man3/DSA_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 KimDSA_generate_parameters_ex, DSA_generate_parameters - generate DSA parameters
6*e71b7053SJung-uk Kim
7*e71b7053SJung-uk Kim=head1 SYNOPSIS
8*e71b7053SJung-uk Kim
9*e71b7053SJung-uk Kim #include <openssl/dsa.h>
10*e71b7053SJung-uk Kim
11*e71b7053SJung-uk Kim int DSA_generate_parameters_ex(DSA *dsa, int bits,
12*e71b7053SJung-uk Kim                                const unsigned char *seed, int seed_len,
13*e71b7053SJung-uk Kim                                int *counter_ret, unsigned long *h_ret,
14*e71b7053SJung-uk Kim                                BN_GENCB *cb);
15*e71b7053SJung-uk Kim
16*e71b7053SJung-uk KimDeprecated:
17*e71b7053SJung-uk Kim
18*e71b7053SJung-uk Kim #if OPENSSL_API_COMPAT < 0x00908000L
19*e71b7053SJung-uk Kim DSA *DSA_generate_parameters(int bits, unsigned char *seed, int seed_len,
20*e71b7053SJung-uk Kim                              int *counter_ret, unsigned long *h_ret,
21*e71b7053SJung-uk Kim                              void (*callback)(int, int, void *), void *cb_arg);
22*e71b7053SJung-uk Kim #endif
23*e71b7053SJung-uk Kim
24*e71b7053SJung-uk Kim=head1 DESCRIPTION
25*e71b7053SJung-uk Kim
26*e71b7053SJung-uk KimDSA_generate_parameters_ex() generates primes p and q and a generator g
27*e71b7053SJung-uk Kimfor use in the DSA and stores the result in B<dsa>.
28*e71b7053SJung-uk Kim
29*e71b7053SJung-uk KimB<bits> is the length of the prime p to be generated.
30*e71b7053SJung-uk KimFor lengths under 2048 bits, the length of q is 160 bits; for lengths
31*e71b7053SJung-uk Kimgreater than or equal to 2048 bits, the length of q is set to 256 bits.
32*e71b7053SJung-uk Kim
33*e71b7053SJung-uk KimIf B<seed> is NULL, the primes will be generated at random.
34*e71b7053SJung-uk KimIf B<seed_len> is less than the length of q, an error is returned.
35*e71b7053SJung-uk Kim
36*e71b7053SJung-uk KimDSA_generate_parameters_ex() places the iteration count in
37*e71b7053SJung-uk Kim*B<counter_ret> and a counter used for finding a generator in
38*e71b7053SJung-uk Kim*B<h_ret>, unless these are B<NULL>.
39*e71b7053SJung-uk Kim
40*e71b7053SJung-uk KimA callback function may be used to provide feedback about the progress
41*e71b7053SJung-uk Kimof the key generation. If B<cb> is not B<NULL>, it will be
42*e71b7053SJung-uk Kimcalled as shown below. For information on the BN_GENCB structure and the
43*e71b7053SJung-uk KimBN_GENCB_call function discussed below, refer to
44*e71b7053SJung-uk KimL<BN_generate_prime(3)>.
45*e71b7053SJung-uk Kim
46*e71b7053SJung-uk KimDSA_generate_prime() is similar to DSA_generate_prime_ex() but
47*e71b7053SJung-uk Kimexpects an old-style callback function; see
48*e71b7053SJung-uk KimL<BN_generate_prime(3)> for information on the old-style callback.
49*e71b7053SJung-uk Kim
50*e71b7053SJung-uk Kim=over 2
51*e71b7053SJung-uk Kim
52*e71b7053SJung-uk Kim=item *
53*e71b7053SJung-uk Kim
54*e71b7053SJung-uk KimWhen a candidate for q is generated, B<BN_GENCB_call(cb, 0, m++)> is called
55*e71b7053SJung-uk Kim(m is 0 for the first candidate).
56*e71b7053SJung-uk Kim
57*e71b7053SJung-uk Kim=item *
58*e71b7053SJung-uk Kim
59*e71b7053SJung-uk KimWhen a candidate for q has passed a test by trial division,
60*e71b7053SJung-uk KimB<BN_GENCB_call(cb, 1, -1)> is called.
61*e71b7053SJung-uk KimWhile a candidate for q is tested by Miller-Rabin primality tests,
62*e71b7053SJung-uk KimB<BN_GENCB_call(cb, 1, i)> is called in the outer loop
63*e71b7053SJung-uk Kim(once for each witness that confirms that the candidate may be prime);
64*e71b7053SJung-uk Kimi is the loop counter (starting at 0).
65*e71b7053SJung-uk Kim
66*e71b7053SJung-uk Kim=item *
67*e71b7053SJung-uk Kim
68*e71b7053SJung-uk KimWhen a prime q has been found, B<BN_GENCB_call(cb, 2, 0)> and
69*e71b7053SJung-uk KimB<BN_GENCB_call(cb, 3, 0)> are called.
70*e71b7053SJung-uk Kim
71*e71b7053SJung-uk Kim=item *
72*e71b7053SJung-uk Kim
73*e71b7053SJung-uk KimBefore a candidate for p (other than the first) is generated and tested,
74*e71b7053SJung-uk KimB<BN_GENCB_call(cb, 0, counter)> is called.
75*e71b7053SJung-uk Kim
76*e71b7053SJung-uk Kim=item *
77*e71b7053SJung-uk Kim
78*e71b7053SJung-uk KimWhen a candidate for p has passed the test by trial division,
79*e71b7053SJung-uk KimB<BN_GENCB_call(cb, 1, -1)> is called.
80*e71b7053SJung-uk KimWhile it is tested by the Miller-Rabin primality test,
81*e71b7053SJung-uk KimB<BN_GENCB_call(cb, 1, i)> is called in the outer loop
82*e71b7053SJung-uk Kim(once for each witness that confirms that the candidate may be prime).
83*e71b7053SJung-uk Kimi is the loop counter (starting at 0).
84*e71b7053SJung-uk Kim
85*e71b7053SJung-uk Kim=item *
86*e71b7053SJung-uk Kim
87*e71b7053SJung-uk KimWhen p has been found, B<BN_GENCB_call(cb, 2, 1)> is called.
88*e71b7053SJung-uk Kim
89*e71b7053SJung-uk Kim=item *
90*e71b7053SJung-uk Kim
91*e71b7053SJung-uk KimWhen the generator has been found, B<BN_GENCB_call(cb, 3, 1)> is called.
92*e71b7053SJung-uk Kim
93*e71b7053SJung-uk Kim=back
94*e71b7053SJung-uk Kim
95*e71b7053SJung-uk Kim=head1 RETURN VALUES
96*e71b7053SJung-uk Kim
97*e71b7053SJung-uk KimDSA_generate_parameters_ex() returns a 1 on success, or 0 otherwise.
98*e71b7053SJung-uk KimThe error codes can be obtained by L<ERR_get_error(3)>.
99*e71b7053SJung-uk Kim
100*e71b7053SJung-uk KimDSA_generate_parameters() returns a pointer to the DSA structure or
101*e71b7053SJung-uk KimB<NULL> if the parameter generation fails.
102*e71b7053SJung-uk Kim
103*e71b7053SJung-uk Kim=head1 BUGS
104*e71b7053SJung-uk Kim
105*e71b7053SJung-uk KimSeed lengths greater than 20 are not supported.
106*e71b7053SJung-uk Kim
107*e71b7053SJung-uk Kim=head1 SEE ALSO
108*e71b7053SJung-uk Kim
109*e71b7053SJung-uk KimL<DSA_new(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>,
110*e71b7053SJung-uk KimL<DSA_free(3)>, L<BN_generate_prime(3)>
111*e71b7053SJung-uk Kim
112*e71b7053SJung-uk Kim=head1 HISTORY
113*e71b7053SJung-uk Kim
114*e71b7053SJung-uk KimDSA_generate_parameters() was deprecated in OpenSSL 0.9.8; use
115*e71b7053SJung-uk KimDSA_generate_parameters_ex() instead.
116*e71b7053SJung-uk Kim
117*e71b7053SJung-uk Kim=head1 COPYRIGHT
118*e71b7053SJung-uk Kim
119*e71b7053SJung-uk KimCopyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
120*e71b7053SJung-uk Kim
121*e71b7053SJung-uk KimLicensed under the OpenSSL license (the "License").  You may not use
122*e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
123*e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
124*e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
125*e71b7053SJung-uk Kim
126*e71b7053SJung-uk Kim=cut
127