ddn.crypto.mac.poly1305

Poly1305 Message Authentication Code (RFC 8439).

Side-Channel Status: The accumulator arithmetic runs on fixed 26-bit limbs with a fully unrolled, branch-free block function, so the operation sequence does not depend on the key or the message.

Types 1

classPoly1305 : MAC

Poly1305 Implementation.

One-time authenticator. Requires a 32-byte key (r, s).

The state is kept as five 26-bit limbs (the classic fixed-width representation): the block multiply is an unrolled fixed sequence of multiply-accumulate and carry steps with no data-dependent branches, unlike the previous BigInt-based implementation whose timing followed the values it processed.

Warning: The key (r, s) MUST NOT be reused for different messages. Typically, this key is derived from a master key and a nonce (e.g., in ChaCha20-Poly1305).

Fields
private uint[5] _r
private uint[5] _h
private uint[4] _s
private ubyte[16] _buffer
private size_t _leftover
private bool _initialized
Methods
void initialize(SecretKey key)Initializes (or re-initializes) the Poly1305 MAC with the given key.
void initialize(const(ubyte)[] key)
size_t size() @property const
void reset()
MAC update(const(ubyte)[] input)
ubyte[] finish()
void wipe() nothrow @nogc @trustedZeroizes the key and all accumulator state in place.
private void processBlock(const(ubyte)[] block, bool hibit)Processes one 16-byte block into the accumulator.
private uint load32(const(ubyte)[] b, size_t off) static pure @safe @nogc nothrow
private void store32(ref ubyte[] b, size_t off, uint v) static pure @safe @nogc nothrow
Constructors
this(Key key)Constructs a Poly1305 MAC with the given key.
Destructors

Functions 1

private fnubyte[] hexToBytes(string hex) pure @safe