EVP_PKEY_CTX_GET0_PKEY(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… EVP_PKEY_CTX_GET0_PKEY πŸ’…

okay so this is a page from the OpenSSL manual, bestie β€” specifically the 3ossl corner of it β€” and it's about the two lil getter functions that let you peek at the EVP_PKEY hanging out inside an EVP_PKEY_CTX. no cap, that's the whole vibe.


✨ NAME ✨

EVP_PKEY_CTX_get0_pkey, EVP_PKEY_CTX_get0_peerkey β€” functions for accessing the EVP_PKEY associated with an EVP_PKEY_CTX


πŸŽ€ SYNOPSIS πŸŽ€

#include <openssl/evp.h>

EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);
EVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);

like, that's it. two one-liners. we love a concise icon. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

EVP_PKEY_CTX_get0_pkey()

EVP_PKEY_CTX_get0_pkey() is used to access the EVP_PKEY associated with the given EVP_PKEY_CTX ctx.

and the EVP_PKEY you get back? it's the exact one that was used for creating the EVP_PKEY_CTX, via either EVP_PKEY_CTX_new(3) or EVP_PKEY_CTX_new_from_pkey(3). so it's not a copy, not a lookalike, it's the key. main character energy, truly. πŸ’–

EVP_PKEY_CTX_get0_peerkey()

EVP_PKEY_CTX_get0_peerkey() is used to access the peer EVP_PKEY associated with the given EVP_PKEY_CTX ctx.

and the peer EVP_PKEY you obtain is the one that was set using either EVP_PKEY_derive_set_peer(3) or EVP_PKEY_derive_set_peer_ex(3). iykyk β€” the peer key is the other person in the convo, and you can only see them if somebody actually set them. 🫢


πŸ’€ RETURN VALUES πŸ’€

  • EVP_PKEY_CTX_get0_pkey() β€” returns the EVP_PKEY associated with the EVP_PKEY_CTX, or NULL if it is not set.
  • EVP_PKEY_CTX_get0_peerkey() β€” returns the peer EVP_PKEY associated with the EVP_PKEY_CTX, or NULL if it is not set.
⚠️ okay important one, bestie β€” the returned EVP_PKEY objects are owned by the EVP_PKEY_CTX, and therefore should not explicitly be freed by the caller. not me watching you try to EVP_PKEY_free() something you don't own 😭 put it down. it's not yours. it never was. πŸ™ˆ

also, these functions do not affect the EVP_PKEY reference count. they merely act as getter functions, and should be treated as such. the way that they're just... getters. no side effects. no refcount shenanigans. respectfully iconic. ✨


🌈 SEE ALSO 🌈


Copyright 2022-2023 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 <https://www.openssl.org/source/license.html>.


okay that's the whole page, periodt. πŸ’… and for the cute sign-off: this is OpenSSL 3.5.6, dated 2026-04-07, filed under EVP_PKEY_CTX_GET0_PKEY(3ossl) β€” go be a getter, not a freezer. πŸ§šβ€β™€οΈπŸ“

πŸ“¦ where this page comes from