---
name: "EVP_PKEY_CTX_get0_pkey"
section: "3ssl"
platform: "linux"
package: "openssl"
version: "3.6.5-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/EVP_PKEY_CTX_get0_pkey"
---

# EVP\_PKEY\_CTX\_get0\_pkey(3ssl)

functions for accessing the EVP\_PKEY associated with an EVP\_PKEY\_CTX

## 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);
```

## DESCRIPTION

**EVP\_PKEY\_CTX\_get0\_pkey()** is used to access the **EVP\_PKEY** associated with the given **EVP\_PKEY\_CTX** *ctx*. The **EVP\_PKEY** obtained is the one used for creating the **EVP\_PKEY\_CTX** using either **EVP\_PKEY\_CTX\_new**(3) or **EVP\_PKEY\_CTX\_new\_from\_pkey**(3).

**EVP\_PKEY\_CTX\_get0\_peerkey()** is used to access the peer **EVP\_PKEY** associated with the given **EVP\_PKEY\_CTX** *ctx*. The peer **EVP\_PKEY** obtained is the one set using either **EVP\_PKEY\_derive\_set\_peer**(3) or **EVP\_PKEY\_derive\_set\_peer\_ex**(3).

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

The returned EVP\_PKEY objects are owned by the EVP\_PKEY\_CTX, and therefore should not explicitly be freed by the caller.

These functions do not affect the EVP\_PKEY reference count. They merely act as getter functions, and should be treated as such.

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

## 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\>.
