DSA_generate_parameters.pod 3.7 KB

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