EVP_PKEY_CTX_GET_OPERATION(3ssl)

πŸ“¦ version 4.1.0, in opensuse-leap 16.0

πŸ’– 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:

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 | 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

🌈 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