AEGIS-128L
Example (combined mode)
#define MESSAGE (const unsigned char *) "test"
#define MESSAGE_LEN 4
#define ADDITIONAL_DATA (const unsigned char *) "123456"
#define ADDITIONAL_DATA_LEN 6
unsigned char nonce[crypto_aead_aegis128l_NPUBBYTES];
unsigned char key[crypto_aead_aegis128l_KEYBYTES];
unsigned char ciphertext[MESSAGE_LEN + crypto_aead_aegis128l_ABYTES];
unsigned long long ciphertext_len;
crypto_aead_aegis128l_keygen(key);
randombytes_buf(nonce, sizeof nonce);
crypto_aead_aegis128l_encrypt(ciphertext, &ciphertext_len,
MESSAGE, MESSAGE_LEN,
ADDITIONAL_DATA, ADDITIONAL_DATA_LEN,
NULL, nonce, key);
unsigned char decrypted[MESSAGE_LEN];
unsigned long long decrypted_len;
if (crypto_aead_aegis128l_decrypt(decrypted, &decrypted_len,
NULL,
ciphertext, ciphertext_len,
ADDITIONAL_DATA,
ADDITIONAL_DATA_LEN,
nonce, key) != 0) {
/* message forged! */
}Combined mode
Detached mode
Constants
Notes
See also
Last updated