EVP_PKEY_CTX_GET_OPERATION(3ssl)
π NAME π
okay bestie, this is the EVP_PKEY_CTX_get_operation(3) page from the Library Functions Manual β and it's lowkey all about inspecting EVP_PKEY_CTX objects. The main characters are EVP_PKEY_CTX_get_operation and EVP_PKEY_CTX_get0_pkey. periodt π
β¨ SYNOPSIS β¨
#include <openssl/evp.h>
int
EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);
EVP_PKEY *
EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);
π¦ DESCRIPTION π¦
So EVP_PKEY_CTX_get_operation() literally finds out which initialization function has been called on ctx, if any. It's giving "vibe check for your context" energy. Here's the iconic little mapping, same facts, no cap:
EVP_PKEY_OP_DECRYPTβ initialized withEVP_PKEY_decrypt_init(3); e.g. forRSA,SM2EVP_PKEY_OP_DERIVEβ initialized withEVP_PKEY_derive_init(3); e.g. forHKDFEVP_PKEY_OP_ENCRYPTβ initialized withEVP_PKEY_encrypt_init(3); e.g. forRSA,SM2EVP_PKEY_OP_KEYGENβ initialized withEVP_PKEY_keygen_init(3); e.g. foralmost allEVP_PKEY_OP_PARAMGENβ initialized withEVP_PKEY_paramgen_init(3); e.g. forDH,DSA,ECEVP_PKEY_OP_SIGNβ initialized withEVP_PKEY_sign_init(3); e.g. forDSA,EC,RSA,SM2EVP_PKEY_OP_SIGNβ initialized withEVP_DigestSignInit(3); e.g. forED25519EVP_PKEY_OP_SIGNCTXβ initialized withEVP_DigestSignInit(3); e.g. forCMAC,HMACEVP_PKEY_OP_UNDEFINEDβ not initialized; e.g. forNONEEVP_PKEY_OP_VERIFYβ initialized withEVP_PKEY_verify_init(3); e.g. forDSA,EC,RSA,SM2EVP_PKEY_OP_VERIFYβ initialized withEVP_DigestVerifyInit(3); e.g. forED25519EVP_PKEY_OP_VERIFYCTXβ initialized withEVP_DigestVerifyInit(3); e.g. forno built-inEVP_PKEY_OP_VERIFYRECOVERβ initialized withEVP_PKEY_verify_recover_init(3); e.g. forRSA
That rightmost column is just showing examples of algorithms the return values can occur for. So for example, if EVP_PKEY_base_id(3) returns EVP_PKEY_HKDF, then calling EVP_PKEY_CTX_get_operation() on a EVP_PKEY_CTX using that key may return EVP_PKEY_OP_DERIVE. iykyk π
If the return value is EVP_PKEY_OP_SIGNCTX or EVP_PKEY_OP_VERIFYCTX, the ctx supports EVP_DigestSignUpdate(3) or EVP_DigestVerifyUpdate(3), respectively. If the return value is EVP_PKEY_OP_SIGN or EVP_PKEY_OP_VERIFY, it does not, and only one-shot signing or verification is supported. not me double-checking that distinction but yes bestie, it matters π
The return value EVP_PKEY_OP_UNDEFINED can for example occur if the ctx was freshly returned from EVP_PKEY_CTX_new(3) or EVP_PKEY_CTX_new_id(3) and not yet initialized. fresh-out-the-box energy, but make it undefined β¨
The following masks are defined as the logical OR of two or more of the above EVP_PKEY_OP_* bits:
EVP_PKEY_OP_TYPE_CRYPTβDECRYPT | ENCRYPTEVP_PKEY_OP_TYPE_GENβKEYGEN | PARAMGENEVP_PKEY_OP_TYPE_NOGENβCRYPT | DERIVE | SIGEVP_PKEY_OP_TYPE_SIGβSIGN | SIGNCTX | VERIFY | VERIFYCTX | VERIFYRECOVER
π RETURN VALUES π
EVP_PKEY_CTX_get_operation() returns one of the single-bit EVP_PKEY_OP_* constants or EVP_PKEY_OP_UNDEFINED if ctx is not initialized. simple as that, no drama π
EVP_PKEY_CTX_get0_pkey() returns an internal pointer to the EVP_PKEY object used by ctx, without incrementing its reference count. like borrowing your bestie's charger β you get access, but you don't get to claim it's yours π₯
π§ SEE ALSO π§
π HISTORY π
EVP_PKEY_CTX_get_operation() and EVP_PKEY_CTX_get0_pkey() first appeared in OpenSSL 1.0.0 and have been available since OpenBSD 4.9. vintage but still iconic, fr fr β
this cutie page is from Debian, dated September 12, 2023, and the footer calls it EVP_PKEY_CTX_GET_OPERATION(3). byeee bestie, go inspect those contexts responsibly π
π«Ά
π¦ where this page comes from
- opensuse-leap 16.0: libressl-devel-doc 4.1.0-bp160.1.1 Β· OpenSSL
- Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms