DSA_generate_parameters.pod 4.3 KB

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