RSA_generate_key 3 2003-07-24 0.9.9-dev OpenSSL
NAME
RSA_generate_key - generate RSA key pair
LIBRARY
libcrypto, -lcrypto
SYNOPSIS
#include
RSA *RSA_generate_key(int num, unsigned long e,
void (*callback)(int,int,void *), void *cb_arg);
DESCRIPTION
_R_S_A___g_e_n_e_r_a_t_e___k_e_y_(_) generates a key pair and returns it in a newly
allocated RRSSAA structure. The pseudo-random number generator must
be seeded prior to calling _R_S_A___g_e_n_e_r_a_t_e___k_e_y_(_).
The modulus size will be nnuumm bits, and the public exponent will be
ee. Key sizes with nnuumm < 1024 should be considered insecure.
The exponent is an odd number, typically 3, 17 or 65537.
A callback function may be used to provide feedback about the
progress of the key generation. If ccaallllbbaacckk is not NNUULLLL, it
will be called as follows:
-
·
While a random prime number is generated, it is called as
-
described in _B_N___g_e_n_e_r_a_t_e___p_r_i_m_e(3).
-
·
When the n-th randomly generated prime is rejected as not
-
suitable for the key, ccaallllbbaacckk((22,, nn,, ccbb__aarrgg)) is called.
-
·
When a random p has been found with p-1 relatively prime to ee,
-
it is called as ccaallllbbaacckk((33,, 00,, ccbb__aarrgg)).
The process is then repeated for prime q with ccaallllbbaacckk((33,, 11,, ccbb__aarrgg)).
RETURN VALUE
If key generation fails, _R_S_A___g_e_n_e_r_a_t_e___k_e_y_(_) returns NNUULLLL; the
error codes can be obtained by _E_R_R___g_e_t___e_r_r_o_r(3).
BUGS
ccaallllbbaacckk((22,, xx,, ccbb__aarrgg)) is used with two different meanings.
_R_S_A___g_e_n_e_r_a_t_e___k_e_y_(_) goes into an infinite loop for illegal input values.
SEE ALSO
_E_R_R___g_e_t___e_r_r_o_r(3), _o_p_e_n_s_s_l___r_a_n_d(3), _o_p_e_n_s_s_l___r_s_a(3),
_R_S_A___f_r_e_e(3)
HISTORY
The ccbb__aarrgg argument was added in SSLeay 0.9.0.