gnutls_hpke_encap(3)

NAME
gnutls_hpke_encap - API function

SYNOPSIS
#include <gnutls/hpke.h>

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

ARGUMENTS

gnutls_hpke_context_t ctx
    The HPKE context to use for encapsulation.

const gnutls_datum_t * info
    The application-specific information to be included in the key schedule (optional).

gnutls_datum_t * enc
    A pointer to a gnutls_datum_t structure where the encapsulated key will be stored.

const gnutls_pubkey_t receiver_pubkey
    The receiver's public key to use for encapsulation.

const gnutls_privkey_t sender_privkey
    The sender's private key needed for AuthEncap operation (optional).

const gnutls_datum_t * psk
    The pre-shared key (optional).

const gnutls_datum_t * psk_id
    The pre-shared key identifier (optional).

DESCRIPTION
This function performs the encapsulation operation of HPKE. It generates an encapsulated key ( enc ) 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 (GNUTLS_HPKE_ROLE_SENDER) for encapsulation.

This function must be used once per HPKE context and before any calls to gnutls_hpke_seal().

The function will allocate memory for enc , and the caller is responsible for freeing this memory using gnutls_free() when it is no longer needed.

 receiver_pubkey must be a valid public key that is compatible with the KEM algorithm specified in the HPKE context.

For GNUTLS_HPKE_MODE_AUTH or GNUTLS_HPKE_MODE_AUTH_PSK,
 sender_privkey must be a valid private key that can be used for authentication. For GNUTLS_HPKE_MODE_PSK or GNUTLS_HPKE_MODE_AUTH_PSK, a pre-shared key ( psk ) and its identifier ( psk_id ) must be supplied.

RETURNS
0 on success, or a negative error code on failure

SINCE
3.8.13

REPORTING BUGS
Report bugs to <bugs@gnutls.org>.
Home page: https://www.gnutls.org

COPYRIGHT
Copyright © 2001-2023 Free Software Foundation, Inc., and others.
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.

SEE ALSO
The full documentation for gnutls is maintained as a Texinfo manual. If the /usr/share/doc/gnutls/ directory does not contain the HTML form visit

https://www.gnutls.org/manual/