2
0

RSA_generate_key.pod 2.2 KB

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