EVP_PKEY_CTX_ctrl(3) OpenSSL EVP_PKEY_CTX_ctrl(3) NNAAMMEE EVP_PKEY_ctrl, EVP_PKEY_ctrl_str - algorithm specific control opera- tions SSYYNNOOPPSSIISS #include int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd, int p1, void *p2); int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value); int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid); #include int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *ctx, int pad); int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int len); int EVP_PKEY_CTX_set_rsa_rsa_keygen_bits(EVP_PKEY_CTX *ctx, int mbits); int EVP_PKEY_CTX_set_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp); #include int EVP_PKEY_CTX_set_dsa_paramgen_bits(EVP_PKEY_CTX *ctx, int nbits); #include int EVP_PKEY_CTX_set_dh_paramgen_prime_len(EVP_PKEY_CTX *ctx, int len); int EVP_PKEY_CTX_set_dh_paramgen_generator(EVP_PKEY_CTX *ctx, int gen); #include int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid); DDEESSCCRRIIPPTTIIOONN The function _E_V_P___P_K_E_Y___C_T_X___c_t_r_l_(_) sends a control operation to the con- text ccttxx. The key type used must match kkeeyyttyyppee if it is not -1. The parameter ooppttyyppee is a mask indicating which operations the control can be applied to. The control command is indicated in ccmmdd and any addi- tional arguments in pp11 and pp22. Applications will not normally call _E_V_P___P_K_E_Y___C_T_X___c_t_r_l_(_) directly but will instead call one of the algorithm specific macros below. The function _E_V_P___P_K_E_Y___c_t_r_l___s_t_r_(_) allows an application to send an algo- rithm specific control operation to a context ccttxx in string form. This is intended to be used for options specified on the command line or in text files. The commands supported are documented in the openssl util- ity command line pages for the option --ppkkeeyyoopptt which is supported by the ppkkeeyyuuttll, ggeennppkkeeyy and rreeqq commands. All the remaining "functions" are implemented as macros. The _E_V_P___P_K_E_Y___C_T_X___s_e_t___s_i_g_n_a_t_u_r_e___m_d_(_) macro sets the message digest type used in a signature. It can be used with any public key algorithm sup- porting signature operations. The macro _E_V_P___P_K_E_Y___C_T_X___s_e_t___r_s_a___p_a_d_d_i_n_g_(_) sets the RSA padding mode for ccttxx. The ppaadd parameter can take the value RSA_PKCS1_PADDING for PKCS#1 padding, RSA_SSLV23_PADDING for SSLv23 padding, RSA_NO_PADDING for no padding, RSA_PKCS1_OAEP_PADDING for OAEP padding (encrypt and decrypt only), RSA_X931_PADDING for X9.31 padding (signature operations only) and RSA_PKCS1_PSS_PADDING (sign and verify only). Two RSA padding modes behave differently if _E_V_P___P_K_E_Y___C_T_X___s_e_t___s_i_g_n_a_- _t_u_r_e___m_d_(_) is used. If this macro is called for PKCS#1 padding the plaintext buffer is an actual digest value and is encapsulated in a DigestInfo structure according to PKCS#1 when signing and this struc- ture is expected (and stripped off) when verifying. If this control is not used with RSA and PKCS#1 padding then the supplied data is used directly and not encapsulated. In the case of X9.31 padding for RSA the algorithm identifier byte is added or checked and removed if this con- trol is called. If it is not called then the first byte of the plain- text buffer is expected to be the algorithm identifier byte. The _E_V_P___P_K_E_Y___C_T_X___s_e_t___r_s_a___p_s_s___s_a_l_t_l_e_n_(_) macro sets the RSA PSS salt length to lleenn as its name implies it is only supported for PSS padding. Two special values are supported: -1 sets the salt length to the digest length. When signing -2 sets the salt length to the maximum permissible value. When verifying -2 causes the salt length to be automatically determined based on the PPSSSS block structure. If this macro is not called a salt length value of -2 is used by default. The _E_V_P___P_K_E_Y___C_T_X___s_e_t___r_s_a___r_s_a___k_e_y_g_e_n___b_i_t_s_(_) macro sets the RSA key length for RSA key genration to bbiittss. If not specified 1024 bits is used. The _E_V_P___P_K_E_Y___C_T_X___s_e_t___r_s_a___k_e_y_g_e_n___p_u_b_e_x_p_(_) macro sets the public exponent value for RSA key generation to ppuubbeexxpp currently it should be an odd integer. The ppuubbeexxpp pointer is used internally by this function so it should not be modified or free after the call. If this macro is not called then 65537 is used. The macro _E_V_P___P_K_E_Y___C_T_X___s_e_t___d_s_a___p_a_r_a_m_g_e_n___b_i_t_s_(_) sets the number of bits used for DSA parameter generation to bbiittss. If not specified 1024 is used. The macro _E_V_P___P_K_E_Y___C_T_X___s_e_t___d_h___p_a_r_a_m_g_e_n___p_r_i_m_e___l_e_n_(_) sets the length of the DH prime parameter pp for DH parameter generation. If this macro is not called then 1024 is used. The _E_V_P___P_K_E_Y___C_T_X___s_e_t___d_h___p_a_r_a_m_g_e_n___g_e_n_e_r_a_t_o_r_(_) macro sets DH generator to ggeenn for DH parameter generation. If not specified 2 is used. The _E_V_P___P_K_E_Y___C_T_X___s_e_t___e_c___p_a_r_a_m_g_e_n___c_u_r_v_e___n_i_d_(_) sets the EC curve for EC parameter generation to nniidd. For EC parameter generation this macro must be called or an error occurs because there is no default curve. RREETTUURRNN VVAALLUUEESS _E_V_P___P_K_E_Y___C_T_X___c_t_r_l_(_) and its macros return a positive value for success and 0 or a negative value for failure. In particular a return value of -2 indicates the operation is not supported by the public key algo- rithm. SSEEEE AALLSSOO _E_V_P___P_K_E_Y___C_T_X___n_e_w(3), _E_V_P___P_K_E_Y___e_n_c_r_y_p_t(3), _E_V_P___P_K_E_Y___d_e_c_r_y_p_t(3), _E_V_P___P_K_E_Y___s_i_g_n(3), _E_V_P___P_K_E_Y___v_e_r_i_f_y(3), _E_V_P___P_K_E_Y___v_e_r_i_f_y___r_e_c_o_v_e_r(3), _E_V_P___P_K_E_Y___d_e_r_i_v_e(3) _E_V_P___P_K_E_Y___k_e_y_g_e_n(3) HHIISSTTOORRYY These functions were first added to OpenSSL 1.0.0. 1.0.1u 2016-09-22 EVP_PKEY_CTX_ctrl(3)