DH_generate_parameters.pod 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. =pod
  2. =head1 NAME
  3. DH_generate_parameters_ex, DH_generate_parameters,
  4. DH_check, DH_check_params - generate and check Diffie-Hellman
  5. parameters
  6. =head1 SYNOPSIS
  7. #include <openssl/dh.h>
  8. int DH_generate_parameters_ex(DH *dh, int prime_len, int generator, BN_GENCB *cb);
  9. int DH_check(DH *dh, int *codes);
  10. int DH_check_params(DH *dh, int *codes);
  11. Deprecated:
  12. #if OPENSSL_API_COMPAT < 0x00908000L
  13. DH *DH_generate_parameters(int prime_len, int generator,
  14. void (*callback)(int, int, void *), void *cb_arg);
  15. #endif
  16. =head1 DESCRIPTION
  17. DH_generate_parameters_ex() generates Diffie-Hellman parameters that can
  18. be shared among a group of users, and stores them in the provided B<DH>
  19. structure. The pseudo-random number generator must be
  20. seeded prior to calling DH_generate_parameters().
  21. B<prime_len> is the length in bits of the safe prime to be generated.
  22. B<generator> is a small number E<gt> 1, typically 2 or 5.
  23. A callback function may be used to provide feedback about the progress
  24. of the key generation. If B<cb> is not B<NULL>, it will be
  25. called as described in L<BN_generate_prime(3)> while a random prime
  26. number is generated, and when a prime has been found, B<BN_GENCB_call(cb, 3, 0)>
  27. is called. See L<BN_generate_prime(3)> for information on
  28. the BN_GENCB_call() function.
  29. DH_check_params() confirms that the B<p> and B<g> are likely enough to
  30. be valid.
  31. This is a lightweight check, if a more thorough check is needed, use
  32. DH_check().
  33. The value of B<*codes> is updated with any problems found.
  34. If B<*codes> is zero then no problems were found, otherwise the
  35. following bits may be set:
  36. =over 4
  37. =item DH_CHECK_P_NOT_PRIME
  38. The parameter B<p> has been determined to not being an odd prime.
  39. Note that the lack of this bit doesn't guarantee that B<p> is a
  40. prime.
  41. =item DH_NOT_SUITABLE_GENERATOR
  42. The generator B<g> is not suitable.
  43. Note that the lack of this bit doesn't guarantee that B<g> is
  44. suitable, unless B<p> is known to be a strong prime.
  45. =back
  46. DH_check() confirms that the Diffie-Hellman parameters B<dh> are valid. The
  47. value of B<*codes> is updated with any problems found. If B<*codes> is zero then
  48. no problems were found, otherwise the following bits may be set:
  49. =over 4
  50. =item DH_CHECK_P_NOT_PRIME
  51. The parameter B<p> is not prime.
  52. =item DH_CHECK_P_NOT_SAFE_PRIME
  53. The parameter B<p> is not a safe prime and no B<q> value is present.
  54. =item DH_UNABLE_TO_CHECK_GENERATOR
  55. The generator B<g> cannot be checked for suitability.
  56. =item DH_NOT_SUITABLE_GENERATOR
  57. The generator B<g> is not suitable.
  58. =item DH_CHECK_Q_NOT_PRIME
  59. The parameter B<q> is not prime.
  60. =item DH_CHECK_INVALID_Q_VALUE
  61. The parameter B<q> is invalid.
  62. =item DH_CHECK_INVALID_J_VALUE
  63. The parameter B<j> is invalid.
  64. =back
  65. =head1 RETURN VALUES
  66. DH_generate_parameters_ex(), DH_check() and DH_check_params() return 1
  67. if the check could be performed, 0 otherwise.
  68. DH_generate_parameters() (deprecated) returns a pointer to the DH structure, or
  69. NULL if the parameter generation fails.
  70. The error codes can be obtained by L<ERR_get_error(3)>.
  71. =head1 NOTES
  72. DH_generate_parameters_ex() and DH_generate_parameters() may run for several
  73. hours before finding a suitable prime.
  74. The parameters generated by DH_generate_parameters_ex() and DH_generate_parameters()
  75. are not to be used in signature schemes.
  76. =head1 SEE ALSO
  77. L<DH_new(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>,
  78. L<DH_free(3)>
  79. =head1 COPYRIGHT
  80. Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
  81. Licensed under the OpenSSL license (the "License"). You may not use
  82. this file except in compliance with the License. You can obtain a copy
  83. in the file LICENSE in the source distribution or at
  84. L<https://www.openssl.org/source/license.html>.
  85. =cut