[#EVP_PKEY_decapsulate]
= EVP&lowbar;PKEY&lowbar;decapsulate
:mrdocs:

Decapsulate a shared secret from a KEM ciphertext using a context from EVP&lowbar;PKEY&lowbar;decapsulate&lowbar;init()&period;

== Synopsis

Declared in `&lt;openssl&sol;evp&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
EVP&lowbar;PKEY&lowbar;decapsulate(
    xref:EVP_PKEY_CTX.adoc[EVP&lowbar;PKEY&lowbar;CTX]* ctx,
    unsigned char* unwrapped,
    size&lowbar;t* unwrappedlen,
    unsigned char const* wrapped,
    size&lowbar;t wrappedlen);
----

== Return Value

1 on success, or a non&hyphen;positive value on failure&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *ctx*
| Decapsulation context holding the private key&period;
| *unwrapped*
| Buffer for the recovered shared secret, or NULL to query size via `unwrappedlen&period;`
| *unwrappedlen*
| On entry, capacity of `unwrapped` when non&hyphen;NULL&semi; on return, bytes written or required&period;
| *wrapped*
| Encapsulation ciphertext bytes&period;
| *wrappedlen*
| Length of `wrapped` in bytes&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
