@ -2,6 +2,7 @@
=head1 NAME
EVP_RSA_gen,
RSA_generate_key_ex, RSA_generate_key,
RSA_generate_multi_prime_key - generate RSA key pair
@ -9,6 +10,8 @@ RSA_generate_multi_prime_key - generate RSA key pair
#include <openssl/rsa.h>
EVP_PKEY *EVP_RSA_gen(unsigned int bits);
Deprecated since OpenSSL 3.0, can be hidden entirely by defining
B<OPENSSL_API_COMPAT> with a suitable version value, see
L<openssl_user_macros(7)>:
@ -16,44 +19,42 @@ L<openssl_user_macros(7)>:
int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
int RSA_generate_multi_prime_key(RSA *rsa, int bits, int primes, BIGNUM *e, BN_GENCB *cb);
Deprecated since OpenSSL 0.9.8, can be hidden entirely by defining
B<OPENSSL_API_COMPAT> with a suitable version value, see
L<openssl_user_macros(7)>:
Deprecated since OpenSSL 0.9.8:
RSA *RSA_generate_key(int bits, unsigned long e,
void (*callback)(int, int, void *), void *cb_arg);
=head1 DESCRIPTION
All of the functions described on this page are deprecated.
Applications should instead use L<EVP_PKEY_keygen_init(3)> and
L<EVP_PKEY_keygen(3)>.
EVP_RSA_gen() generates a new RSA key pair with modulus size I<bits>.
All of the functions described below are deprecated.
Applications should instead use EVP_RSA_gen(), L<EVP_PKEY_Q_keygen(3)>, or
L<EVP_PKEY_keygen_init(3)> and L<EVP_PKEY_keygen(3)>.
RSA_generate_key_ex() generates a 2-prime RSA key pair and stores it in the
B<RSA> structure provided in B<rsa>. The pseudo-random number generator must
be seeded prior to calling RSA_generate_key_ex().
B<RSA> structure provided in I<rsa>.
RSA_generate_multi_prime_key() generates a multi-prime RSA key pair and stores
it in the B<RSA> structure provided in B<rsa>. The number of primes is given by
the B<primes> parameter. The random number generator must be seeded when
calling RSA_generate_multi_prime_key().
it in the B<RSA> structure provided in I<rsa>. The number of primes is given by
the I<primes> parameter.
If the automatic seeding or reseeding of the OpenSSL CSPRNG fails due to
external circumstances (see L<RAND(7)>), the operation will fail.
The modulus size will be of length B <bits>, the number of primes to form the
modulus will be B<primes>, and the public exponent will be B <e>. Key sizes
with B <num> E<lt> 1024 should be considered insecure. The exponent is an odd
The modulus size will be of length I <bits>, the number of primes to form the
modulus will be I<primes>, and the public exponent will be I <e>. Key sizes
with I <num> E<lt> 1024 should be considered insecure. The exponent is an odd
number, typically 3, 17 or 65537.
In order to maintain adequate security level, the maximum number of permitted
B <primes> depends on modulus bit length:
I <primes> depends on modulus bit length:
<1024 | >=1024 | >=4096 | >=8192
------+--------+--------+-------
2 | 3 | 4 | 5
A callback function may be used to provide feedback about the
progress of the key generation. If B<cb> is not B<NULL> , it
progress of the key generation. If I<cb> is not NULL , it
will be called as follows using the BN_GENCB_call() function
described on the L<BN_generate_prime(3)> page.
@ -71,42 +72,44 @@ described in L<BN_generate_prime(3)>.
=item *
When the n-th randomly generated prime is rejected as not
suitable for the key, B <BN_GENCB_call(cb, 2, n)> is called.
suitable for the key, I <BN_GENCB_call(cb, 2, n)> is called.
=item *
When a random p has been found with p-1 relatively prime to B <e>,
it is called as B <BN_GENCB_call(cb, 3, 0)>.
When a random p has been found with p-1 relatively prime to I <e>,
it is called as I <BN_GENCB_call(cb, 3, 0)>.
=back
The process is then repeated for prime q and other primes (if any)
with B<BN_GENCB_call(cb, 3, i)> where B <i> indicates the i-th prime.
with I<BN_GENCB_call(cb, 3, i)> where I <i> indicates the i-th prime.
=head1 RETURN VALUES
EVP_RSA_gen() returns an I<EVP_PKEY> or NULL on failure.
RSA_generate_multi_prime_key() returns 1 on success or 0 on error.
RSA_generate_key_ex() returns 1 on success or 0 on error.
The error codes can be obtained by L<ERR_get_error(3)>.
RSA_generate_key() returns a pointer to the RSA structure or
B< NULL> if the key generation fails.
NULL if the key generation fails.
=head1 BUGS
B <BN_GENCB_call(cb, 2, x)> is used with two different meanings.
I <BN_GENCB_call(cb, 2, x)> is used with two different meanings.
=head1 SEE ALSO
L<ERR_get_error(3)>, L<RAND_bytes(3)>, L<BN_generate_prime(3)>,
L<RAND(7)>
L<EVP_PKEY_Q_keygen(3)>
L<BN_generate_prime(3)>, L<ERR_get_error(3)>,
L<RAND_bytes(3)>, L<RAND(7)>
=head1 HISTORY
All of these functions were deprecated in OpenSSL 3.0.
RSA_generate_key() was deprecated in OpenSSL 0.9.8; use
RSA_generate_key_ex() instead.
EVP_RSA_gen() was added in OpenSSL 3.0.
All other functions described here were deprecated in OpenSSL 3.0.
For replacement see L<EVP_PKEY-RSA(7)>.
=head1 COPYRIGHT