ddn.net.ssh.packet_etm
Encrypt-then-MAC SSH packet protection for AES-CTR with hmac-sha2-256-etm@openssh.com and hmac-sha2-512-etm@openssh.com.
OpenSSH layout: the packet length travels in the clear; the packet body (padding length, payload, random padding) is encrypted with a continuous AES-CTR stream per direction, and the MAC covers the packet sequence number, the clear length, and the ciphertext. The reader verifies the MAC before any decryption, so unauthenticated plaintext never exists.
Types 5
Raised for encrypt-then-MAC packet violations: bad lengths, padding, or authentication failures.
this(string msg, string file = __FILE__, size_t line = __LINE__)Constructs an encrypt-then-MAC exception.MAC algorithms supported by the encrypt-then-MAC layout.
Encrypt-then-MAC framing parameters.
Encrypt-then-MAC packet writer.
Produces length || ciphertext || MAC wire packets. The CTR stream continues across packets for one key; the sequence number enters every MAC.
private CTR!AES cipher_private HMAC mac_private size_t macSize_private CryptoRandom rng_private uint sequenceNumber_private bool wiped_uint sequenceNumber() @property const pure nothrow @nogcReturns: the sequence number of the next packet to be written.void setSequence(uint value) pure nothrow @nogc @safeSets the sequence number explicitly (continuity across rekey).ubyte[] protect(const(ubyte)[] payload)Frames, encrypts, and authenticates one payload.ubyte[] computeMac(uint packetLength,
const(ubyte)[] ciphertext)this(const(ubyte)[] cipherKey, in ubyte[16] iv, const(ubyte)[] macKey,
EtMMac mac, CryptoRandom rng)Constructs a writer from derived key material.Incremental encrypt-then-MAC packet reader.
Collects the clear length and ciphertext, verifies the MAC first, then decrypts and validates padding. Nothing unauthenticated is ever returned.
private CTR!AES cipher_private HMAC mac_private size_t macSize_private ubyte[] buffer_private uint sequenceNumber_private bool wiped_uint sequenceNumber() @property const pure nothrow @nogcReturns: the sequence number of the next packet to be read.void setSequence(uint value) pure nothrow @nogc @safeSets the sequence number explicitly (continuity across rekey).size_t bytesNeeded() @property const pure nothrow @nogc @safeReturns: how many more wire bytes the current packet still needs, or 0 when a full packet is buffered.bool packetReady() @property const pure nothrow @nogc @safeReturns: whether a complete packet is buffered.ubyte[] take()Takes the next authenticated packet's payload.ubyte[] computeMac(uint packetLength,
const(ubyte)[] ciphertext)