


@deftypefun {int} {gnutls_hpke_decap} (gnutls_hpke_context_t @var{ctx}, const gnutls_datum_t * @var{info}, const gnutls_datum_t * @var{enc}, const gnutls_privkey_t @var{receiver_privkey}, const gnutls_pubkey_t @var{sender_pubkey}, const gnutls_datum_t * @var{psk}, const gnutls_datum_t * @var{psk_id})
@var{ctx}: The HPKE context to use for decapsulation.

@var{info}: The application-specific information that was included in the key schedule (optional).

@var{enc}: A pointer to a gnutls_datum_t structure containing the encapsulated key received from the sender.

@var{receiver_privkey}: The receiver's private key to use for decapsulation.

@var{sender_pubkey}: The sender's public key for AuthDecap operation (optional).

@var{psk}: The pre-shared key (optional).

@var{psk_id}: The pre-shared key identifier (optional).

This function performs the decapsulation operation of HPKE. It
takes the encapsulated key ( @code{enc} ) received from the sender and uses
it along with the receiver's private key to derive the shared
secret. It then uses this shared secret along with any provided
application-specific information ( @code{info} ) to set up the necessary
keys and nonces in the HPKE context for subsequent sealing and
opening operations.

This function must be used once per HPKE context and before any
calls to @code{gnutls_hpke_open()} .

 @code{enc} should be the same encapsulated key that was generated by
@code{gnutls_hpke_encap()}  on the sender's side.

 @code{receiver_privkey} must be a valid private key that is compatible
with the KEM algorithm specified in the HPKE context and that
corresponds to the receiver's public key used during encapsulation.

For @code{GNUTLS_HPKE_MODE_AUTH}  or @code{GNUTLS_HPKE_MODE_AUTH_PSK} ,
 @code{sender_pubkey} must be a valid public key that can be used for
authentication. For @code{GNUTLS_HPKE_MODE_PSK}  or
@code{GNUTLS_HPKE_MODE_AUTH_PSK} , a pre-shared key ( @code{psk} ) and its
identifier ( @code{psk_id} ) must be supplied.

@strong{Returns:} 0 on success, or a negative error code on failure

@strong{Since:} 3.8.13
@end deftypefun
