Sortix cross-nightly manual
This manual documents Sortix cross-nightly. You can instead view this document in the latest official manual.
NAME
EVP_AEAD_CTX_new, EVP_AEAD_CTX_free, EVP_AEAD_CTX_init, EVP_AEAD_CTX_cleanup, EVP_AEAD_CTX_open, EVP_AEAD_CTX_seal, EVP_AEAD_key_length, EVP_AEAD_max_overhead, EVP_AEAD_max_tag_len, EVP_AEAD_nonce_length, EVP_aead_aes_128_gcm, EVP_aead_aes_256_gcm, EVP_aead_chacha20_poly1305, EVP_aead_xchacha20_poly1305 — authenticated encryption with additional dataSYNOPSIS
#include <openssl/evp.h>EVP_AEAD_CTX_new(void);
EVP_AEAD_CTX_free(EVP_AEAD_CTX *ctx);
EVP_AEAD_CTX_init(EVP_AEAD_CTX *ctx, const EVP_AEAD *aead, const unsigned char *key, size_t key_len, size_t tag_len, ENGINE *impl);
EVP_AEAD_CTX_cleanup(EVP_AEAD_CTX *ctx);
EVP_AEAD_CTX_open(const EVP_AEAD_CTX *ctx, unsigned char *out, size_t *out_len, size_t max_out_len, const unsigned char *nonce, size_t nonce_len, const unsigned char *in, size_t in_len, const unsigned char *ad, size_t ad_len);
EVP_AEAD_CTX_seal(const EVP_AEAD_CTX *ctx, unsigned char *out, size_t *out_len, size_t max_out_len, const unsigned char *nonce, size_t nonce_len, const unsigned char *in, size_t in_len, const unsigned char *ad, size_t ad_len);
EVP_AEAD_key_length(const EVP_AEAD *aead);
EVP_AEAD_max_overhead(const EVP_AEAD *aead);
EVP_AEAD_max_tag_len(const EVP_AEAD *aead);
EVP_AEAD_nonce_length(const EVP_AEAD *aead);
EVP_aead_aes_128_gcm(void);
EVP_aead_aes_256_gcm(void);
EVP_aead_chacha20_poly1305(void);
EVP_aead_xchacha20_poly1305(void);
DESCRIPTION
AEAD (Authenticated Encryption with Additional Data) couples confidentiality and integrity in a single primitive. AEAD algorithms take a key and can then seal and open individual messages. Each message has a unique, per-message nonce and, optionally, additional data which is authenticated but not included in the output.- EVP_aead_aes_128_gcm()
- AES-128 in Galois Counter Mode, using a key_len of 16 bytes and a nonce_len of 12 bytes.
- EVP_aead_aes_256_gcm()
- AES-256 in Galois Counter Mode, using a key_len of 32 bytes and a nonce_len of 12 bytes.
- EVP_aead_chacha20_poly1305()
- ChaCha20 with a Poly1305 authenticator, using a key_len of 32 bytes and a nonce_len of 12 bytes. The constant EVP_CHACHAPOLY_TLS_TAG_LEN specifies the length of the authentication tag in bytes and has a value of 16.
- EVP_aead_xchacha20_poly1305()
- XChaCha20 with a Poly1305 authenticator, using a key_len of 32 bytes and a nonce_len of 24 bytes.
RETURN VALUES
EVP_AEAD_CTX_new() returns the new EVP_AEAD_CTX object on success; otherwise NULL is returned and errno is set to ENOMEM.EXAMPLES
Encrypt a string using ChaCha20-Poly1305:const EVP_AEAD *aead = EVP_aead_chacha20_poly1305(); static const unsigned char nonce[32] = {0}; size_t buf_len, nonce_len; EVP_AEAD_CTX *ctx; ctx = EVP_AEAD_CTX_new(); EVP_AEAD_CTX_init(ctx, aead, key32, EVP_AEAD_key_length(aead), EVP_AEAD_DEFAULT_TAG_LENGTH, NULL); nonce_len = EVP_AEAD_nonce_length(aead); EVP_AEAD_CTX_seal(ctx, out, &out_len, BUFSIZE, nonce, nonce_len, in, in_len, NULL, 0); EVP_AEAD_CTX_free(ctx);