[#OSSL_HPKE_encap]
= OSSL&lowbar;HPKE&lowbar;encap
:mrdocs:

Encapsulate to a recipient public key and derive sender HPKE secrets&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
OSSL&lowbar;HPKE&lowbar;encap(
    xref:OSSL_HPKE_CTX.adoc[OSSL&lowbar;HPKE&lowbar;CTX]* ctx,
    unsigned char* enc,
    size&lowbar;t* enclen,
    unsigned char const* pub,
    size&lowbar;t publen,
    unsigned char const* info,
    size&lowbar;t infolen);
----

== Return Value

1 on success, or 0 on error&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *ctx*
| Sender HPKE context (only one successful call allowed per context)&period;
| *enc*
| Destination for the encapsulated public value&semi; on input &ast;`enclen` is capacity&period;
| *enclen*
| In&sol;out length of `enc` (updated with bytes written)&period;
| *pub*
| Recipient public key octets for the suite&apos;s KEM&period;
| *publen*
| Length of `pub` in bytes&period;
| *info*
| Optional application info bound into key schedule, or NULL if `infolen` is 0&period;
| *infolen*
| Length of `info` in bytes (must not exceed OSSL&lowbar;HPKE&lowbar;MAX&lowbar;INFOLEN)&period;
|===


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