EVP_PKEY_SET1_RSA(3SSL)
π
EVP_PKEY_SET1_RSA β the OpenSSL EVP_PKEY_SET1_RSA(3SSL) page, bestie edition
okay so first things first, hi, welcome to the OpenSSL manual page EVP_PKEY_SET1_RSA(3SSL). This one is all about the EVP_PKEY assignment functions β the little crew of getters, setters and assigners that (historically) shuttle keys in and out of an EVP_PKEY. A bunch of them are deprecated in 3.0 and I'm gonna be so real with you about which ones. π«Ά
β¨ NAME β¨
EVP_PKEY_set1_RSA, EVP_PKEY_set1_DSA, EVP_PKEY_set1_DH, EVP_PKEY_set1_EC_KEY, EVP_PKEY_get1_RSA, EVP_PKEY_get1_DSA, EVP_PKEY_get1_DH, EVP_PKEY_get1_EC_KEY, EVP_PKEY_get0_RSA, EVP_PKEY_get0_DSA, EVP_PKEY_get0_DH, EVP_PKEY_get0_EC_KEY, EVP_PKEY_assign_RSA, EVP_PKEY_assign_DSA, EVP_PKEY_assign_DH, EVP_PKEY_assign_EC_KEY, EVP_PKEY_assign_POLY1305, EVP_PKEY_assign_SIPHASH, EVP_PKEY_get0_hmac, EVP_PKEY_get0_poly1305, EVP_PKEY_get0_siphash, EVP_PKEY_get0, EVP_PKEY_type, EVP_PKEY_get_id, EVP_PKEY_get_base_id, EVP_PKEY_set1_engine, EVP_PKEY_get0_engine, EVP_PKEY_id, EVP_PKEY_base_id β the EVP_PKEY assignment functions, iykyk π«
πΈ SYNOPSIS πΈ
#include <openssl/evp.h>
int EVP_PKEY_get_id(const EVP_PKEY *pkey);
int EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
int EVP_PKEY_type(int type);
#define EVP_PKEY_id EVP_PKEY_get_id
#define EVP_PKEY_base_id EVP_PKEY_get_base_id
sooo the next batch are all deprecated since OpenSSL 3.0, and you can hide them entirely by defining OPENSSL_API_COMPAT with a suitable version value β check openssl_user_macros(7) for that. β¨
int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key);
int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key);
int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key);
int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key);
RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
DSA *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len);
const unsigned char *EVP_PKEY_get0_poly1305(const EVP_PKEY *pkey, size_t *len);
const unsigned char *EVP_PKEY_get0_siphash(const EVP_PKEY *pkey, size_t *len);
const RSA *EVP_PKEY_get0_RSA(const EVP_PKEY *pkey);
const DSA *EVP_PKEY_get0_DSA(const EVP_PKEY *pkey);
const DH *EVP_PKEY_get0_DH(const EVP_PKEY *pkey);
const EC_KEY *EVP_PKEY_get0_EC_KEY(const EVP_PKEY *pkey);
void *EVP_PKEY_get0(const EVP_PKEY *pkey);
int EVP_PKEY_assign_RSA(EVP_PKEY *pkey, RSA *key);
int EVP_PKEY_assign_DSA(EVP_PKEY *pkey, DSA *key);
int EVP_PKEY_assign_DH(EVP_PKEY *pkey, DH *key);
int EVP_PKEY_assign_EC_KEY(EVP_PKEY *pkey, EC_KEY *key);
int EVP_PKEY_assign_POLY1305(EVP_PKEY *pkey, ASN1_OCTET_STRING *key);
int EVP_PKEY_assign_SIPHASH(EVP_PKEY *pkey, ASN1_OCTET_STRING *key);
ENGINE *EVP_PKEY_get0_engine(const EVP_PKEY *pkey);
int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *engine);
π¦ DESCRIPTION π¦
okay so let's start with the type-checkers, they're the chill ones. π
EVP_PKEY_get_base_id() returns the type of pkey. Like, an RSA key will return EVP_PKEY_RSA. simple as that, no cap.
EVP_PKEY_get_id() returns the actual NID associated with pkey β but only if the pkey type isn't implemented just in a provider(7). Historically, keys using the same algorithm could use different NIDs. Example time: an RSA key could use the NIDs corresponding to the NIDs NID_rsaEncryption (equivalent to EVP_PKEY_RSA) or NID_rsa (equivalent to EVP_PKEY_RSA2). The use of alternative non-standard NIDs is now rare, so EVP_PKEY_RSA2 et al are not often seen in practice. And heads up: EVP_PKEY_get_id() returns -1 (EVP_PKEY_KEYMGMT) if the pkey is only implemented in a provider(7). π
EVP_PKEY_type() returns the underlying type of the NID type. For example, EVP_PKEY_type(EVP_PKEY_RSA2) will return EVP_PKEY_RSA. love that for us.
π the set1 girlies
EVP_PKEY_set1_RSA(), EVP_PKEY_set1_DSA(), EVP_PKEY_set1_DH() and EVP_PKEY_set1_EC_KEY() set the key referenced by pkey to key.
β οΈ These functions are deprecated. Applications should instead use EVP_PKEY_fromdata(3). periodt.
π the assign girlies
EVP_PKEY_assign_RSA(), EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH(), EVP_PKEY_assign_EC_KEY(), EVP_PKEY_assign_POLY1305() and EVP_PKEY_assign_SIPHASH() set the referenced key to key β however, these use the supplied key internally, and so key will be freed when the parent pkey is freed. π (that's the whole personality of assign vs set1, bestie, write it down)
β οΈ These macros are deprecated. Applications should instead read anEVP_PKEYdirectly using theOSSL_DECODERAPIs (seeOSSL_DECODER_CTX_new_for_pkey(3)), or construct anEVP_PKEYfrom data usingEVP_PKEY_fromdata(3).
πΈ the get1 girlies
EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and EVP_PKEY_get1_EC_KEY() return the referenced key in pkey, or NULL if the key is not of the correct type.
The returned key must be freed after use. π
β οΈ These functions are deprecated. Applications should instead use theEVP_PKEYdirectly where possible. If access to the low level key parameters is required, then applications should useEVP_PKEY_get_params(3)and other similar functions. To write anEVP_PKEYout, use theOSSL_ENCODERAPIs (seeOSSL_ENCODER_CTX_new_for_pkey(3)).
π§ the get0 girlies
EVP_PKEY_get0_hmac(), EVP_PKEY_get0_poly1305(), EVP_PKEY_get0_siphash(), EVP_PKEY_get0_RSA(), EVP_PKEY_get0_DSA(), EVP_PKEY_get0_DH() and EVP_PKEY_get0_EC_KEY() return the referenced key in pkey, or NULL if the key is not of the correct type.
The reference count of the returned key is not incremented, and so the key must not be freed after use. π (yes, the opposite of the get1 girlies, do not mix them up)
β οΈ These functions are deprecated. Applications should instead use theEVP_PKEYdirectly where possible. If access to the low level key parameters is required, then applications should useEVP_PKEY_get_params(3)and other similar functions. To write anEVP_PKEYout, use theOSSL_ENCODERAPIs (seeOSSL_ENCODER_CTX_new_for_pkey(3)).
EVP_PKEY_get0() returns a pointer to the legacy key, or NULL if the key is not legacy.
π the provider cache lore (this part is important, fr fr)
Note that if an EVP_PKEY was not constructed using one of the deprecated functions such as EVP_PKEY_set1_RSA(), EVP_PKEY_set1_DSA(), EVP_PKEY_set1_DH() or EVP_PKEY_set1_EC_KEY(), or via the similarly named EVP_PKEY_assign macros described above, then the internal key will be managed by a provider (see provider(7)).
In that case, the key returned by EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH(), EVP_PKEY_get1_EC_KEY(), EVP_PKEY_get0_hmac(), EVP_PKEY_get0_poly1305(), EVP_PKEY_get0_siphash(), EVP_PKEY_get0_RSA(), EVP_PKEY_get0_DSA(), EVP_PKEY_get0_DH() or EVP_PKEY_get0_EC_KEY() will be a cached copy of the provider's key.
so like. π« Subsequent updates to the provider's key will not be reflected back in the cached copy, and updates made by an application to the returned key will not be reflected back in the provider's key. it literally goes one way, it's giving read-only situationship.
And subsequent calls to EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and EVP_PKEY_get1_EC_KEY() will always return the cached copy returned by the first call. same copy every time, no questions.
π the engine girlies
EVP_PKEY_get0_engine() returns a reference to the ENGINE handling pkey.
β οΈ This function is deprecated. Applications should use providers instead of engines (see provider(7) for details).
EVP_PKEY_set1_engine() sets the ENGINE handling pkey to engine. It must be called after the key algorithm and components are set up. If engine does not include an EVP_PKEY_METHOD for pkey, an error occurs. π¨
β οΈ This function is deprecated. Applications should use providers instead of engines (see provider(7) for details).
π COPYRIGHT π
okay bestie, legal era, but make it cute β¨
Copyright 2002-2023 The OpenSSL Project Authors. All Rights Reserved.
so the whole thing is licensed under the Apache License 2.0 (that's "the License" btw) π and like, you may not use this file except in compliance with the License β no cap, that's the vibe check you gotta pass π
you can grab a copy of the License in the file LICENSE in the source distribution, or literally just go here:
https://www.openssl.org/source/license.html
that's the whole legal bit, bestie β short, sweet, and fully slaying π
and that's a wrap on EVP_PKEY_SET1_RSA(3SSL)! π«Ά this lil masterpiece is from OpenSSL 3.5.7, dated 2026-06-09 β go forth and reference-count responsibly, mwah πβ¨
π¦ where this page comes from
- debian trixie: libssl-doc 3.5.7-1~deb13u2 Β· Apache-2.0
- debian trixie: libssl-doc 3.5.7-1~deb13u3 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms