159191Skris=pod
259191Skris
359191Skris=head1 NAME
459191Skris
559191SkrisRSA_generate_key - generate RSA key pair
659191Skris
759191Skris=head1 SYNOPSIS
859191Skris
959191Skris #include <openssl/rsa.h>
1059191Skris
1159191Skris RSA *RSA_generate_key(int num, unsigned long e,
1259191Skris    void (*callback)(int,int,void *), void *cb_arg);
1359191Skris
1459191Skris=head1 DESCRIPTION
1559191Skris
1659191SkrisRSA_generate_key() generates a key pair and returns it in a newly
1759191Skrisallocated B<RSA> structure. The pseudo-random number generator must
1859191Skrisbe seeded prior to calling RSA_generate_key().
1959191Skris
2059191SkrisThe modulus size will be B<num> bits, and the public exponent will be
2159191SkrisB<e>. Key sizes with B<num> E<lt> 1024 should be considered insecure.
22100928SnectarThe exponent is an odd number, typically 3, 17 or 65537.
2359191Skris
2459191SkrisA callback function may be used to provide feedback about the
2559191Skrisprogress of the key generation. If B<callback> is not B<NULL>, it
2659191Skriswill be called as follows:
2759191Skris
2859191Skris=over 4
2959191Skris
3059191Skris=item *
3159191Skris
3259191SkrisWhile a random prime number is generated, it is called as
3359191Skrisdescribed in L<BN_generate_prime(3)|BN_generate_prime(3)>.
3459191Skris
3559191Skris=item *
3659191Skris
3759191SkrisWhen the n-th randomly generated prime is rejected as not
3859191Skrissuitable for the key, B<callback(2, n, cb_arg)> is called.
3959191Skris
4059191Skris=item *
4159191Skris
4259191SkrisWhen a random p has been found with p-1 relatively prime to B<e>,
4359191Skrisit is called as B<callback(3, 0, cb_arg)>.
4459191Skris
4559191Skris=back
4659191Skris
4759191SkrisThe process is then repeated for prime q with B<callback(3, 1, cb_arg)>.
4859191Skris
4959191Skris=head1 RETURN VALUE
5059191Skris
5159191SkrisIf key generation fails, RSA_generate_key() returns B<NULL>; the
5259191Skriserror codes can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
5359191Skris
5459191Skris=head1 BUGS
5559191Skris
5659191SkrisB<callback(2, x, cb_arg)> is used with two different meanings.
5759191Skris
5859191SkrisRSA_generate_key() goes into an infinite loop for illegal input values.
5959191Skris
6059191Skris=head1 SEE ALSO
6159191Skris
62109998SmarkmL<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>,
63109998SmarkmL<RSA_free(3)|RSA_free(3)>
6459191Skris
6559191Skris=head1 HISTORY
6659191Skris
6759191SkrisThe B<cb_arg> argument was added in SSLeay 0.9.0.
6859191Skris
6959191Skris=cut
70