RSA_generate_key.pod 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #if OPENSSL_API_COMPAT < 0x00908000L
  9. RSA *RSA_generate_key(int num, unsigned long e,
  10. void (*callback)(int, int, void *), void *cb_arg);
  11. #endif
  12. =head1 DESCRIPTION
  13. RSA_generate_key_ex() generates a key pair and stores it in the B<RSA>
  14. structure provided in B<rsa>. The pseudo-random number generator must
  15. be seeded prior to calling RSA_generate_key_ex().
  16. The modulus size will be of length B<bits>, and the public exponent will be
  17. B<e>. Key sizes with B<num> E<lt> 1024 should be considered insecure.
  18. The exponent is an odd number, typically 3, 17 or 65537.
  19. A callback function may be used to provide feedback about the
  20. progress of the key generation. If B<cb> is not B<NULL>, it
  21. will be called as follows using the BN_GENCB_call() function
  22. described on the L<BN_generate_prime(3)> page.
  23. =over 2
  24. =item *
  25. While a random prime number is generated, it is called as
  26. described in L<BN_generate_prime(3)>.
  27. =item *
  28. When the n-th randomly generated prime is rejected as not
  29. suitable for the key, B<BN_GENCB_call(cb, 2, n)> is called.
  30. =item *
  31. When a random p has been found with p-1 relatively prime to B<e>,
  32. it is called as B<BN_GENCB_call(cb, 3, 0)>.
  33. =back
  34. The process is then repeated for prime q with B<BN_GENCB_call(cb, 3, 1)>.
  35. RSA_generate_key() is deprecated (new applications should use
  36. RSA_generate_key_ex() instead). RSA_generate_key() works in the same way as
  37. RSA_generate_key_ex() except it uses "old style" call backs. See
  38. L<BN_generate_prime(3)> for further details.
  39. =head1 RETURN VALUE
  40. RSA_generate_key_ex() returns 1 on success or 0 on error.
  41. RSA_generate_key() returns the key on success or B<NULL> on error.
  42. The error codes can be obtained by L<ERR_get_error(3)>.
  43. =head1 BUGS
  44. B<BN_GENCB_call(cb, 2, x)> is used with two different meanings.
  45. RSA_generate_key() goes into an infinite loop for illegal input values.
  46. =head1 SEE ALSO
  47. L<ERR_get_error(3)>, L<RAND_bytes(3)>,
  48. L<RSA_generate_key(3)>, L<BN_generate_prime(3)>
  49. =head1 COPYRIGHT
  50. Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
  51. Licensed under the OpenSSL license (the "License"). You may not use
  52. this file except in compliance with the License. You can obtain a copy
  53. in the file LICENSE in the source distribution or at
  54. L<https://www.openssl.org/source/license.html>.
  55. =cut