d2i_PrivateKey(3) OpenSSL d2i_PrivateKey(3) NNAAMMEE d2i_Private_key, d2i_AutoPrivateKey, i2d_PrivateKey - decode and encode functions for reading and saving EVP_PKEY structures. SSYYNNOOPPSSIISS #include EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, long length); EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, long length); int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); DDEESSCCRRIIPPTTIIOONN _d_2_i___P_r_i_v_a_t_e_K_e_y_(_) decodes a private key using algorithm ttyyppee. It attempts to use any key specific format or PKCS#8 unencrypted Pri- vateKeyInfo format. The ttyyppee parameter should be a public key algorithm constant such as EEVVPP__PPKKEEYY__RRSSAA. An error occurs if the decoded key does not match ttyyppee. _d_2_i___A_u_t_o_P_r_i_v_a_t_e_K_e_y_(_) is similar to _d_2_i___P_r_i_v_a_t_e_K_e_y_(_) except it attempts to automatically detect the private key format. _i_2_d___P_r_i_v_a_t_e_K_e_y_(_) encodes kkeeyy. It uses a key specific format or, if none is defined for that key type, PKCS#8 unencrypted PrivateKeyInfo format. These functions are similar to the _d_2_i___X_5_0_9_(_) functions, and you should refer to that page for a detailed description (see _d_2_i___X_5_0_9(3)). NNOOTTEESS All these functions use DER format and unencrypted keys. Applications wishing to encrypt or decrypt private keys should use other functions such as _d_2_i___P_K_C_8_P_r_i_v_a_t_e_K_e_y_(_) instead. If the **aa is not NULL when calling _d_2_i___P_r_i_v_a_t_e_K_e_y_(_) or _d_2_i___A_u_t_o_P_r_i_- _v_a_t_e_K_e_y_(_) (i.e. an existing structure is being reused) and the key for- mat is PKCS#8 then **aa will be freed and replaced on a successful call. RREETTUURRNN VVAALLUUEESS _d_2_i___P_r_i_v_a_t_e_K_e_y_(_) and _d_2_i___A_u_t_o_P_r_i_v_a_t_e_K_e_y_(_) return a valid EEVVPP__KKEEYY struc- ture or NNUULLLL if an error occurs. The error code can be obtained by calling _E_R_R___g_e_t___e_r_r_o_r(3). _i_2_d___P_r_i_v_a_t_e_K_e_y_(_) returns the number of bytes successfully encoded or a negative value if an error occurs. The error code can be obtained by calling _E_R_R___g_e_t___e_r_r_o_r(3). SSEEEE AALLSSOO _c_r_y_p_t_o(3), _d_2_i___P_K_C_S_8_P_r_i_v_a_t_e_K_e_y(3) 1.0.1u 2016-09-22 d2i_PrivateKey(3)