EVP_PKEY_CTX_GET0_PKEY(3SSL)

πŸ’– EVP_PKEY_CTX_GET0_PKEY πŸ’–

okay bestie so you're in the OpenSSL 3SSL manual, section 3, and today's hyperfixation is EVP_PKEY_CTX_get0_pkey and EVP_PKEY_CTX_get0_peerkey β€” the two lil functions for peeking at the EVP_PKEY that's vibing inside your EVP_PKEY_CTX. they're getters. they literally just look. no cap. πŸŽ€


✨ 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);

🌸 DESCRIPTION 🌸

EVP_PKEY_CTX_get0_pkey() is how you go get the EVP_PKEY that's attached to a given EVP_PKEY_CTX ctx. and like, which EVP_PKEY is it? it's the one you used to make that EVP_PKEY_CTX in the first place, using either EVP_PKEY_CTX_new(3) or EVP_PKEY_CTX_new_from_pkey(3). so it's giving "the origin story key". 🌱

EVP_PKEY_CTX_get0_peerkey() is the other one β€” it grabs the peer EVP_PKEY attached to the given EVP_PKEY_CTX ctx. and the peer key it hands you is the one that got set with either EVP_PKEY_derive_set_peer(3) or EVP_PKEY_derive_set_peer_ex(3). it's giving "the plus-one key". 🫢


πŸ‘‘ 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.
⚠️ bestie listen. the returned EVP_PKEY objects are owned by the EVP_PKEY_CTX. so do not go freeing them yourself, okay?? that's not your key to free. let the ctx handle it. πŸ’€

these functions do not touch the EVP_PKEY reference count. they are merely getter functions, and they should be treated as such. that's it. that's the whole personality. it's giving "look, don't touch". periodt. πŸ’…


πŸ”— 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>.


<div align="center">✨ Version 4.0.3 β€” dated 2026-09-29 β€” and that's the EVP_PKEY_CTX_GET0_PKEY(3SSL) page, bestie πŸ’– go forth and getter responsibly πŸ¦‹πŸŽ€</div>

okay love u bye, drink water, and remember: getters don't own anything, that's the whole lesson 🌈⭐

πŸ“¦ where this page comes from