2
0

DSA_generate_parameters.pod 3.8 KB

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