LIBRESSL-EVP_PKEY_CTX_GET_OPERATION(3)
π
EVP_PKEY_CTX_get_operation β inspect EVP_PKEY_CTX objects
okay so bestie, this is from the libcrypto library (that's the libcrypto manpage tag up top, iykyk) and it's literally just two little peekaboo functions that let you look inside an EVP_PKEY_CTX and see what it's up to. No cap, that's the whole vibe. π
β¨ 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 π¦
πΈ EVP_PKEY_CTX_get_operation()
She tells you which initialization function has been called on ctx β like, if any. If nothing's been set up yet you just get EVP_PKEY_OP_UNDEFINED and that's totally fine, she's just chillin'. π
Here's the full tea, one bullet per row of the table so nothing gets lost:
EVP_PKEY_OP_DECRYPTβ initialized withEVP_PKEY_decrypt_init(3)β e.g. for RSA, SM2EVP_PKEY_OP_DERIVEβ initialized withEVP_PKEY_derive_init(3)β e.g. for HKDFEVP_PKEY_OP_ENCRYPTβ initialized withEVP_PKEY_encrypt_init(3)β e.g. for RSA, SM2EVP_PKEY_OP_KEYGENβ initialized withEVP_PKEY_keygen_init(3)β e.g. for almost allEVP_PKEY_OP_PARAMGENβ initialized withEVP_PKEY_paramgen_init(3)β e.g. for DH, DSA, ECEVP_PKEY_OP_SIGNβ initialized withEVP_PKEY_sign_init(3)β e.g. for DSA,EC,RSA,SM2EVP_PKEY_OP_SIGNβ initialized withEVP_DigestSignInit(3)β e.g. for ED25519EVP_PKEY_OP_SIGNCTXβ initialized withEVP_DigestSignInit(3)β e.g. for CMAC, HMACEVP_PKEY_OP_UNDEFINEDβ not initialized β e.g. NONEEVP_PKEY_OP_VERIFYβ initialized withEVP_PKEY_verify_init(3)β e.g. for DSA,EC,RSA,SM2EVP_PKEY_OP_VERIFYβ initialized withEVP_DigestVerifyInit(3)β e.g. for ED25519EVP_PKEY_OP_VERIFYCTXβ initialized withEVP_DigestVerifyInit(3)β e.g. for no built-inEVP_PKEY_OP_VERIFYRECOVERβ initialized withEVP_PKEY_verify_recover_init(3)β e.g. for RSA
That rightmost column is just examples of algorithms where those return values can show up β it's giving "here's a vibe, not a rule". π«Ά So for example: if EVP_PKEY_base_id(3) returns EVP_PKEY_HKDF, then calling EVP_PKEY_CTX_get_operation() on an EVP_PKEY_CTX using that key may return EVP_PKEY_OP_DERIVE. Slay.
π§ the SIGNCTX / VERIFYCTX distinction (this matters, bestie)
If the return value is EVP_PKEY_OP_SIGNCTX or EVP_PKEY_OP_VERIFYCTX, then 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. That's the whole difference, don't sleep on it. π
π when you get EVP_PKEY_OP_UNDEFINED
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. Baby's brand new, hasn't picked a lane yet. π±
π the masks
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 | ENCRYPT
EVP_PKEY_OP_TYPE_GEN KEYGEN | PARAMGEN
EVP_PKEY_OP_TYPE_NOGEN CRYPT | DERIVE | SIG
EVP_PKEY_OP_TYPE_SIG SIGN | SIGNCTX | VERIFY | VERIFYCTX |
VERIFYRECOVER
Group-chat energy: CRYPT is the encrypt/decrypt girlies, GEN is the keygen/paramgen girlies, NOGEN is everyone else who isn't generating, and SIG is the whole signing squad. π
π₯ RETURN VALUES π₯
EVP_PKEY_CTX_get_operation()returns one of the single-bitEVP_PKEY_OP_*constants, orEVP_PKEY_OP_UNDEFINEDifctxis not initialized. No ambiguity, one bit, periodt. β¨EVP_PKEY_CTX_get0_pkey()returns an internal pointer to theEVP_PKEYobject used byctx, without incrementing its reference count. β οΈ Read that again bestie β it's a borrowed pointer, you don't own it, don't go freeing it, that's not your main character moment.
π SEE ALSO π
evp(3), EVP_PKEY_base_id(3), EVP_PKEY_CTX_ctrl(3), EVP_PKEY_CTX_new(3), EVP_PKEY_new(3)
π 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. Veterans fr fr, they've been serving looks since forever. π
kisses, bestie π β this drop is from the Debian build, dated June 8, 2025, and the page itself is EVP_PKEY_CTX_GET_OPERATION(3). go forth and inspect those contexts, you absolute icon π¦β¨
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom: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