DH_generate_parameters.pod 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. =pod
  2. =head1 NAME
  3. DH_generate_parameters, DH_check - generate and check Diffie-Hellman parameters
  4. =head1 SYNOPSIS
  5. #include <openssl/dh.h>
  6. DH *DH_generate_parameters(int prime_len, int generator,
  7. void (*callback)(int, int, void *), void *cb_arg);
  8. int DH_check(DH *dh, int *codes);
  9. =head1 DESCRIPTION
  10. DH_generate_parameters() generates Diffie-Hellman parameters that can
  11. be shared among a group of users, and returns them in a newly
  12. allocated B<DH> structure. The pseudo-random number generator must be
  13. seeded prior to calling DH_generate_parameters().
  14. B<prime_len> is the length in bits of the safe prime to be generated.
  15. B<generator> is a small number E<gt> 1, typically 2 or 5.
  16. A callback function may be used to provide feedback about the progress
  17. of the key generation. If B<callback> is not B<NULL>, it will be
  18. called as described in L<BN_generate_prime(3)|BN_generate_prime(3)> while a random prime
  19. number is generated, and when a prime has been found, B<callback(3,
  20. 0, cb_arg)> is called.
  21. DH_check() validates Diffie-Hellman parameters. It checks that B<p> is
  22. a safe prime, and that B<g> is a suitable generator. In the case of an
  23. error, the bit flags DH_CHECK_P_NOT_SAFE_PRIME or
  24. DH_NOT_SUITABLE_GENERATOR are set in B<*codes>.
  25. DH_UNABLE_TO_CHECK_GENERATOR is set if the generator cannot be
  26. checked, i.e. it does not equal 2 or 5.
  27. =head1 RETURN VALUES
  28. DH_generate_parameters() returns a pointer to the DH structure, or
  29. NULL if the parameter generation fails. The error codes can be
  30. obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
  31. DH_check() returns 1 if the check could be performed, 0 otherwise.
  32. =head1 NOTES
  33. DH_generate_parameters() may run for several hours before finding a
  34. suitable prime.
  35. The parameters generated by DH_generate_parameters() are not to be
  36. used in signature schemes.
  37. =head1 BUGS
  38. If B<generator> is not 2 or 5, B<dh-E<gt>g>=B<generator> is not
  39. a usable generator.
  40. =head1 SEE ALSO
  41. L<dh(3)|dh(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>,
  42. L<DH_free(3)|DH_free(3)>
  43. =head1 HISTORY
  44. DH_check() is available in all versions of SSLeay and OpenSSL.
  45. The B<cb_arg> argument to DH_generate_parameters() was added in SSLeay 0.9.0.
  46. In versions before OpenSSL 0.9.5, DH_CHECK_P_NOT_STRONG_PRIME is used
  47. instead of DH_CHECK_P_NOT_SAFE_PRIME.
  48. =cut