AEGIS-128L

Purpose

AEGIS-128Larrow-up-right is an AES-based authenticated encryption with associated data (AEAD) scheme that was a CAESAR competitionarrow-up-right finalist. It encrypts a plaintext message using a 128-bit key and nonce (number used only once) whilst calculating a 256-bit tag over the plaintext and associated data.

The associated data is useful for authenticating file headers, version numbers, timestamps, counters, and so on. It can be used to prevent confused deputy attacksarrow-up-right and replay attacksarrow-up-right. It is not encrypted nor part of the ciphertext. It must be reproduceable or stored somewhere for decryption to be possible.

Decryption involves verifying the tag for the given inputs, which detects tampering and incorrect parameters. If verification fails, an error is returned. Otherwise, the plaintext is returned.

triangle-exclamation
circle-check

Usage

Encrypt

Fills a span with ciphertext and an appended tag computed from a plaintext message, nonce, key, and optional associated data.

AEGIS128L.Encrypt(Span<byte> ciphertext, ReadOnlySpan<byte> plaintext, ReadOnlySpan<byte> nonce, ReadOnlySpan<byte> key, ReadOnlySpan<byte> associatedData = default)

Exceptions

ArgumentOutOfRangeExceptionarrow-up-right

ciphertext has a length not equal to plaintext.Length + TagSize.

ArgumentOutOfRangeExceptionarrow-up-right

nonce has a length not equal to NonceSize.

ArgumentOutOfRangeExceptionarrow-up-right

key has a length not equal to KeySize.

CryptographicExceptionarrow-up-right

Encryption failed.

Decrypt

Verifies that the tag appended to the ciphertext is correct for the given inputs. If verification fails, an exception is thrown. Otherwise, it fills a span with the decrypted ciphertext.

Exceptions

ArgumentOutOfRangeExceptionarrow-up-right

plaintext has a length not equal to ciphertext.Length - TagSize.

ArgumentOutOfRangeExceptionarrow-up-right

ciphertext has a length less than TagSize.

ArgumentOutOfRangeExceptionarrow-up-right

nonce has a length not equal to NonceSize.

ArgumentOutOfRangeExceptionarrow-up-right

key has a length not equal to KeySize.

CryptographicExceptionarrow-up-right

Invalid authentication tag for the given inputs.

Constants

These are used for validation and/or save you defining your own constants.

Notes

triangle-exclamation
triangle-exclamation
circle-exclamation
circle-exclamation
circle-exclamation
circle-check
circle-check
circle-check
circle-info

AEGIS-128L was originallyarrow-up-right specified to use a 128-bit tag. This is currently not supported in libsodium. Similarly, AEGIS-128 from the CAESAR competitionarrow-up-right is not supported nor part of the Internet-Draftarrow-up-right.

Last updated