EVP_PKEY_set_type.3ossl - Man Page

functions to change the EVP_PKEY type

Synopsis

 #include <openssl/evp.h>

 int EVP_PKEY_set_type(EVP_PKEY *pkey, int type);
 int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);
 int EVP_PKEY_set_type_by_keymgmt(EVP_PKEY *pkey, EVP_KEYMGMT *keymgmt);

Description

All the functions described here behave the same in so far that they clear all the previous key data and methods from pkey, and reset it to be of the type of key given by the different arguments.  If pkey is NULL, these functions will still return the same return values as if it wasn't.

EVP_PKEY_set_type() initialises pkey to contain an internal legacy key.  When doing this, it finds a EVP_PKEY_ASN1_METHOD(3) corresponding to type, and associates pkey with the findings. It is an error if no EVP_PKEY_ASN1_METHOD(3) could be found for type.

EVP_PKEY_set_type_str() initialises pkey to contain an internal legacy key. When doing this, it finds a EVP_PKEY_ASN1_METHOD(3) corresponding to str that has then length len, and associates pkey with the findings. It is an error if no EVP_PKEY_ASN1_METHOD(3) could be found for type.

For both EVP_PKEY_set_type() and EVP_PKEY_set_type_str(), pkey gets a numeric type, which can be retrieved with EVP_PKEY_get_id(3).  This numeric type is taken from the EVP_PKEY_ASN1_METHOD(3) that was found, and is equal to or closely related to type in the case of EVP_PKEY_set_type(), or related to str in the case of EVP_PKEY_set_type_str().

EVP_PKEY_set_type_by_keymgmt() initialises pkey to contain an internal provider side key.  When doing this, it associates pkey with keymgmt.  For keys initialised like this, the numeric type retrieved with EVP_PKEY_get_id(3) will always be EVP_PKEY_NONE.

Return Values

All functions described here return 1 if successful, or 0 on error.

See Also

EVP_PKEY_assign(3), EVP_PKEY_get_id(3), EVP_PKEY_get0_RSA(3), EVP_PKEY_copy_parameters(3), EVP_PKEY_ASN1_METHOD(3), EVP_KEYMGMT(3)

Referenced By

EVP_PKEY_ASN1_METHOD.3ossl(3).

The man pages EVP_PKEY_set_type_by_keymgmt.3ossl(3) and EVP_PKEY_set_type_str.3ossl(3) are aliases of EVP_PKEY_set_type.3ossl(3).

2024-09-12 3.2.2 OpenSSL