RSA_generate_key.pod 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. =pod
  2. =head1 NAME
  3. RSA_generate_key - generate RSA key pair
  4. =head1 SYNOPSIS
  5. #include <openssl/rsa.h>
  6. RSA *RSA_generate_key(int num, unsigned long e,
  7. void (*callback)(int,int,void *), void *cb_arg);
  8. =head1 DESCRIPTION
  9. RSA_generate_key() generates a key pair and returns it in a newly
  10. allocated B<RSA> structure. The pseudo-random number generator must
  11. be seeded prior to calling RSA_generate_key().
  12. The modulus size will be B<num> bits, and the public exponent will be
  13. B<e>. Key sizes with B<num> E<lt> 1024 should be considered insecure.
  14. The exponent is an odd number, typically 3, 17 or 65537.
  15. A callback function may be used to provide feedback about the
  16. progress of the key generation. If B<callback> is not B<NULL>, it
  17. will be called as follows:
  18. =over 4
  19. =item *
  20. While a random prime number is generated, it is called as
  21. described in L<BN_generate_prime(3)|BN_generate_prime(3)>.
  22. =item *
  23. When the n-th randomly generated prime is rejected as not
  24. suitable for the key, B<callback(2, n, cb_arg)> is called.
  25. =item *
  26. When a random p has been found with p-1 relatively prime to B<e>,
  27. it is called as B<callback(3, 0, cb_arg)>.
  28. =back
  29. The process is then repeated for prime q with B<callback(3, 1, cb_arg)>.
  30. =head1 RETURN VALUE
  31. If key generation fails, RSA_generate_key() returns B<NULL>; the
  32. error codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
  33. =head1 BUGS
  34. B<callback(2, x, cb_arg)> is used with two different meanings.
  35. RSA_generate_key() goes into an infinite loop for illegal input values.
  36. =head1 SEE ALSO
  37. L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>,
  38. L<RSA_free(3)|RSA_free(3)>
  39. =head1 HISTORY
  40. The B<cb_arg> argument was added in SSLeay 0.9.0.
  41. =cut