#include
void RSA_set_default_method(const RSA_METHOD *meth);
RSA_METHOD *RSA_get_default_method(void);
int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
RSA_METHOD *RSA_get_method(const RSA *rsa);
RSA_METHOD *RSA_PKCS1_SSLeay(void);
RSA_METHOD *RSA_null_method(void);
int RSA_flags(const RSA *rsa);
RSA *RSA_new_method(RSA_METHOD *method);
Initially, the default RSA_METHOD is the OpenSSL internal implementation, as returned by _R_S_A___P_K_C_S_1___S_S_L_e_a_y_(_).
_R_S_A___s_e_t___d_e_f_a_u_l_t___m_e_t_h_o_d_(_) makes mmeetthh the default method for all RSA structures created later. NNBB: This is true only whilst no ENGINE has been set as a default for RSA, so this function is no longer recommended.
_R_S_A___g_e_t___d_e_f_a_u_l_t___m_e_t_h_o_d_(_) returns a pointer to the current default RSA_METHOD. However, the meaningfulness of this result is dependent on whether the ENGINE API is being used, so this function is no longer recommended.
_R_S_A___s_e_t___m_e_t_h_o_d_(_) selects mmeetthh to perform all operations using the key rrssaa. This will replace the RSA_METHOD used by the RSA key and if the previous method was supplied by an ENGINE, the handle to that ENGINE will be released during the change. It is possible to have RSA keys that only work with certain RSA_METHOD implementations (eg. from an ENGINE module that supports embedded hardware-protected keys), and in such cases attempting to change the RSA_METHOD for the key can have unexpected results.
_R_S_A___g_e_t___m_e_t_h_o_d_(_) returns a pointer to the RSA_METHOD being used by rrssaa. This method may or may not be supplied by an ENGINE implementation, but if it is, the return value can only be guaranteed to be valid as long as the RSA key itself is valid and does not have its implementation changed by _R_S_A___s_e_t___m_e_t_h_o_d_(_).
_R_S_A___f_l_a_g_s_(_) returns the ffllaaggss that are set for rrssaa's current RSA_METHOD. See the BUGS section.
_R_S_A___n_e_w___m_e_t_h_o_d_(_) allocates and initializes an RSA structure so that eennggiinnee will be used for the RSA operations. If eennggiinnee is NULL, the default ENGINE for RSA operations is used, and if no default ENGINE is set, the RSA_METHOD controlled by _R_S_A___s_e_t___d_e_f_a_u_l_t___m_e_t_h_o_d_(_) is used.
_R_S_A___f_l_a_g_s_(_) returns the ffllaaggss that are set for rrssaa's current method.
_R_S_A___n_e_w___m_e_t_h_o_d_(_) allocates and initializes an RRSSAA structure so that mmeetthhoodd will be used for the RSA operations. If mmeetthhoodd is NNUULLLL, the default method is used.
typedef struct rsa_meth_st { /* name of the implementation */ const char *name;
/* encrypt */ int (*rsa_pub_enc)(int flen, unsigned char *from, unsigned char *to, RSA *rsa, int padding);
/* verify arbitrary data */ int (*rsa_pub_dec)(int flen, unsigned char *from, unsigned char *to, RSA *rsa, int padding);
/* sign arbitrary data */ int (*rsa_priv_enc)(int flen, unsigned char *from, unsigned char *to, RSA *rsa, int padding);
/* decrypt */ int (*rsa_priv_dec)(int flen, unsigned char *from, unsigned char *to, RSA *rsa, int padding);
/* compute r0 = r0 ^ I mod rsa->n (May be NULL for some implementations) */ int (*rsa_mod_exp)(BIGNUM *r0, BIGNUM *I, RSA *rsa);
/* compute r = a ^ p mod m (May be NULL for some implementations) */ int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
/* called at RSA_new */ int (*init)(RSA *rsa);
/* called at RSA_free */ int (*finish)(RSA *rsa);
/* RSA_FLAG_EXT_PKEY - rsa_mod_exp is called for private key * operations, even if p,q,dmp1,dmq1,iqmp * are NULL * RSA_FLAG_SIGN_VER - enable rsa_sign and rsa_verify * RSA_METHOD_FLAG_NO_CHECK - don't check pub/private match */ int flags;
char *app_data; /* ?? */
/* sign. For backward compatibility, this is used only * if (flags & RSA_FLAG_SIGN_VER) */ int (*rsa_sign)(int type, unsigned char *m, unsigned int m_len, unsigned char *sigret, unsigned int *siglen, RSA *rsa);
/* verify. For backward compatibility, this is used only * if (flags & RSA_FLAG_SIGN_VER) */ int (*rsa_verify)(int type, unsigned char *m, unsigned int m_len, unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
} RSA_METHOD;
_R_S_A___s_e_t___d_e_f_a_u_l_t___m_e_t_h_o_d_(_) returns no value.
_R_S_A___s_e_t___m_e_t_h_o_d_(_) returns a pointer to the old RSA_METHOD implementation that was replaced. However, this return value should probably be ignored because if it was supplied by an ENGINE, the pointer could be invalidated at any time if the ENGINE is unloaded (in fact it could be unloaded as a result of the _R_S_A___s_e_t___m_e_t_h_o_d_(_) function releasing its handle to the ENGINE). For this reason, the return type may be replaced with a vvooiidd declaration in a future release.
_R_S_A___n_e_w___m_e_t_h_o_d_(_) returns NULL and sets an error code that can be obtained by _E_R_R___g_e_t___e_r_r_o_r(3) if the allocation fails. Otherwise it returns a pointer to the newly allocated structure.
_R_S_A___s_e_t___d_e_f_a_u_l_t___o_p_e_n_s_s_l___m_e_t_h_o_d_(_) and _R_S_A___g_e_t___d_e_f_a_u_l_t___o_p_e_n_s_s_l___m_e_t_h_o_d_(_) replaced _R_S_A___s_e_t___d_e_f_a_u_l_t___m_e_t_h_o_d_(_) and _R_S_A___g_e_t___d_e_f_a_u_l_t___m_e_t_h_o_d_(_) respectively, and _R_S_A___s_e_t___m_e_t_h_o_d_(_) and _R_S_A___n_e_w___m_e_t_h_o_d_(_) were altered to use EENNGGIINNEEs rather than RRSSAA__MMEETTHHOODDs during development of the engine version of OpenSSL 0.9.6. For 0.9.7, the handling of defaults in the ENGINE API was restructured so that this change was reversed, and behaviour of the other functions resembled more closely the previous behaviour. The behaviour of defaults in the ENGINE API now transparently overrides the behaviour of defaults in the RSA API without requiring changing these function prototypes.