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