.\" DO NOT MODIFY THIS FILE! It was generated by gdoc. .TH "gnutls_hpke_encap" 3 "3.8.13" "gnutls" "gnutls" .SH NAME gnutls_hpke_encap \- API function .SH SYNOPSIS .B #include .sp .BI "int gnutls_hpke_encap(gnutls_hpke_context_t " ctx ", const gnutls_datum_t * " info ", gnutls_datum_t * " enc ", const gnutls_pubkey_t " receiver_pubkey ", const gnutls_privkey_t " sender_privkey ", const gnutls_datum_t * " psk ", const gnutls_datum_t * " psk_id ");" .SH ARGUMENTS .IP "gnutls_hpke_context_t ctx" 12 The HPKE context to use for encapsulation. .IP "const gnutls_datum_t * info" 12 The application\-specific information to be included in the key schedule (optional). .IP "gnutls_datum_t * enc" 12 A pointer to a gnutls_datum_t structure where the encapsulated key will be stored. .IP "const gnutls_pubkey_t receiver_pubkey" 12 The receiver's public key to use for encapsulation. .IP "const gnutls_privkey_t sender_privkey" 12 The sender's private key needed for AuthEncap operation (optional). .IP "const gnutls_datum_t * psk" 12 The pre\-shared key (optional). .IP "const gnutls_datum_t * psk_id" 12 The pre\-shared key identifier (optional). .SH "DESCRIPTION" This function performs the encapsulation operation of HPKE. It generates an encapsulated key ( \fIenc\fP ) that can be sent to the receiver, who can then use it to derive the shared secret. The function checks that the context is properly initialized and that the provided parameters are valid. It also checks that the context is in the correct role (\fBGNUTLS_HPKE_ROLE_SENDER\fP) for encapsulation. This function must be used once per HPKE context and before any calls to \fBgnutls_hpke_seal()\fP. The function will allocate memory for \fIenc\fP , and the caller is responsible for freeing this memory using \fBgnutls_free()\fP when it is no longer needed. \fIreceiver_pubkey\fP must be a valid public key that is compatible with the KEM algorithm specified in the HPKE context. For \fBGNUTLS_HPKE_MODE_AUTH\fP or \fBGNUTLS_HPKE_MODE_AUTH_PSK\fP, \fIsender_privkey\fP must be a valid private key that can be used for authentication. For \fBGNUTLS_HPKE_MODE_PSK\fP or \fBGNUTLS_HPKE_MODE_AUTH_PSK\fP, a pre\-shared key ( \fIpsk\fP ) and its identifier ( \fIpsk_id\fP ) must be supplied. .SH "RETURNS" 0 on success, or a negative error code on failure .SH "SINCE" 3.8.13 .SH "REPORTING BUGS" Report bugs to . .br Home page: https://www.gnutls.org .SH COPYRIGHT Copyright \(co 2001-2023 Free Software Foundation, Inc., and others. .br Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. .SH "SEE ALSO" The full documentation for .B gnutls is maintained as a Texinfo manual. If the /usr/share/doc/gnutls/ directory does not contain the HTML form visit .B .IP https://www.gnutls.org/manual/ .PP