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