EVP_PKEY_CTX_GET0_PKEY(3ossl)
π EVP_PKEY_CTX_GET0_PKEY π
okay bestie, welcome to the OpenSSL manual, section 3ossl β yes this is a real man page and yes it's about two tiny getter functions that are lowkey the backbone of your whole key-derivation setup. let's get into it π¦
β¨ NAME β¨
EVP_PKEY_CTX_get0_pkey, EVP_PKEY_CTX_get0_peerkey β functions for accessing the EVP_PKEY associated with an EVP_PKEY_CTX
like. that's the whole job. they get the key. iconic behaviour honestly π
β¨ 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);
look at them. two little functions. so much power. π
β¨ DESCRIPTION β¨
EVP_PKEY_CTX_get0_pkey() πΈ
this one is used to access the EVP_PKEY associated with the given EVP_PKEY_CTX ctx. and like, which EVP_PKEY is it? it's the one you used to create the EVP_PKEY_CTX in the first place β either through EVP_PKEY_CTX_new(3) or through EVP_PKEY_CTX_new_from_pkey(3). so it's giving "hey remember that key you walked in with? here it is again." main character energy fr fr β¨
EVP_PKEY_CTX_get0_peerkey() π«Ά
and this one is for the peer EVP_PKEY associated with the given EVP_PKEY_CTX ctx. the peer key you get back is the one that was set using either EVP_PKEY_derive_set_peer(3) or EVP_PKEY_derive_set_peer_ex(3). so it's the other party's key β your plus-one, your duet partner, the one you're deriving a shared secret with π
β¨ RETURN VALUES β¨
EVP_PKEY_CTX_get0_pkey()returns theEVP_PKEYassociated with theEVP_PKEY_CTX, orNULLif it is not set. πEVP_PKEY_CTX_get0_peerkey()returns the peerEVP_PKEYassociated with theEVP_PKEY_CTX, orNULLif it is not set. π
π¨ bestie listen up, this is the important part: the returnedEVP_PKEYobjects are owned by theEVP_PKEY_CTX, and therefore should not explicitly be freed by the caller. do notEVP_PKEY_free()them. do not pass go. the ctx is the parent, you are just visiting. π
and one more thing, no cap: these functions do not affect the EVP_PKEY reference count. they merely act as getter functions, and should be treated as such. no refcount bump, no ownership transfer, just a lil peek. get0 in the name is literally telling you that β zero refs added, zero drama π
β¨ SEE ALSO β¨
EVP_PKEY_CTX_new(3)EVP_PKEY_CTX_new_from_pkey(3)EVP_PKEY_derive_set_peer(3)EVP_PKEY_derive_set_peer_ex(3)
go read those next, iykyk π
β¨ COPYRIGHT β¨
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>.
and that's the whole page, bestie!! π this was OpenSSL 3.5.9, dated 2026-09-29, from the EVP_PKEY_CTX_GET0_PKEY(3ossl) manual β now go forth and get those keys (without freeing them, please, i'm begging π). mwah πβ¨
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms