Aegis128x2State

AEGIS-128x2 encryption/decryption state.

Manages the lifecycle of an aegis128x2_state object in a @nogc and @trusted context.

Constructors

this
this(const(ubyte)[] key, const(ubyte)[] nonce, const(ubyte)[] ad)

Initializes the AEGIS-128x2 state with the provided key, nonce, and associated data.

Destructor

~this
~this()

Destructor to clean up the state.

Postblit

this(this)
this(this)

Disabled copy constructor to prevent state duplication.

Members

Functions

decryptDetachedFinal
int decryptDetachedFinal(ubyte[] plaintext, size_t* written, const(ubyte)[] mac, size_t maclen)

Finalizes decryption in detached mode, verifying the MAC and producing final plaintext.

decryptDetachedUpdate
int decryptDetachedUpdate(ubyte[] plaintext, size_t* written, const(ubyte)[] ciphertext)

Decrypts a ciphertext chunk, producing plaintext.

encryptDetachedFinal
int encryptDetachedFinal(ubyte[] ciphertext, size_t* written, ubyte[] mac, size_t maclen)

Finalizes encryption in detached mode, producing the final ciphertext and MAC.

encryptUpdate
int encryptUpdate(ubyte[] ciphertext, size_t* written, const(ubyte)[] message)

Encrypts a message chunk, producing ciphertext.

Examples

ubyte[16] key = [0x01, 0x02, ..., 0x10];
ubyte[16] nonce = [0x00, 0x01, ..., 0x0F];
ubyte[] ad = [0x41, 0x42, 0x43]; // Associated data
ubyte[] message = [0x48, 0x65, 0x6C, 0x6C, 0x6F]; // "Hello"
ubyte[128] ciphertext;
ubyte[16] mac;
size_t written;

auto state = Aegis128x2State(key, nonce, ad);
state.encryptUpdate(ciphertext[], &written, message);
state.encryptDetachedFinal(ciphertext[written .. $], &written, mac[], 16);

Meta