EVP\_PKEY\_SET\_TYPE(3ossl) OpenSSL EVP\_PKEY\_SET\_TYPE(3ossl)

# [NAME](#NAME)

EVP\_PKEY\_set\_type, EVP\_PKEY\_set\_type\_str, EVP\_PKEY\_set\_type\_by\_keymgmt - functions to change the EVP\_PKEY type

# [SYNOPSIS](#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](#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. It is an error if no legacy implementations could be found for *type*.

**EVP\_PKEY\_set\_type\_str()** initialises *pkey* to contain an internal legacy key. It is an error if no legacy implementation 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)](/man/os/openssl-4.0/EVP_PKEY_get_id.3). This numeric type is taken from the internal legacy implementation 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)](/man/os/openssl-4.0/EVP_PKEY_get_id.3) will always be **EVP\_PKEY\_NONE**.

# [RETURN VALUES](#RETURN_VALUES)

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

# [SEE ALSO](#SEE_ALSO)

[**EVP\_PKEY\_assign**(3)](/man/os/openssl-4.0/EVP_PKEY_assign.3), [**EVP\_PKEY\_get\_id**(3)](/man/os/openssl-4.0/EVP_PKEY_get_id.3), [**EVP\_PKEY\_get0\_RSA**(3)](/man/os/openssl-4.0/EVP_PKEY_get0_RSA.3), [**EVP\_PKEY\_copy\_parameters**(3)](/man/os/openssl-4.0/EVP_PKEY_copy_parameters.3), [**EVP\_KEYMGMT**(3)](/man/os/openssl-4.0/EVP_KEYMGMT.3)

# [COPYRIGHT](#COPYRIGHT)

Copyright 2020-2026 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at &lt;https://www.openssl.org/source/license.html&gt;.

2026-09-29 4.0.3

---

Document: EVP_PKEY_set_type(3ossl) from openssl-4.0 4.0.3-r8 (Chainguard OS)
