ddn.net.ssh.packet_gcm
AES-GCM packet protection for the SSH transport (RFC 5647).
Wire construction per RFC 5647 section 7: the packet length travels in the clear as additional authenticated data, the plaintext (padding length, payload, padding, a multiple of 16 bytes) is encrypted with AES-GCM, and the 16-byte tag is appended. The nonce is a 4-byte fixed field from the key exchange plus a big-endian 64-bit invocation counter that increments after every packet.
Tag verification happens before any plaintext exists: the reader collects the whole packet before calling the AEAD.
Types 4
Raised for protected-packet violations: bad lengths, counter exhaustion, or authentication failures.
this(string msg, string file = __FILE__, size_t line = __LINE__)Constructs a protected-packet exception.GCM framing parameters: AES block size and tag length.
Protected packet writer.
Produces wire packets from payloads: random GCM padding, plaintext length as AAD, per-packet nonce from the invocation counter.
private GCM!AES aead_private CryptoRandom rng_private ubyte[12] iv_private uint sequenceNumber_private bool wiped_uint sequenceNumber() @property const pure nothrow @nogcReturns: the sequence number of the next packet to be written.ubyte[] protect(const(ubyte)[] payload)Frames and protects one payload.void setSequence(uint value) pure nothrow @nogc @safeSets the sequence counter explicitly (continuity across rekey).this(const(ubyte)[] key, in ubyte[12] iv, CryptoRandom rng)Constructs a writer from derived key material.Incremental protected packet reader.
Collects the plaintext length, then ciphertext and tag, then authenticates and decrypts in one AEAD call.
private GCM!AES aead_private ubyte[12] iv_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.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 authenticated packet is buffered.ubyte[] take()Takes the next authenticated packet's payload.void setSequence(uint value) pure nothrow @nogc @safeSets the sequence counter explicitly (continuity across rekey).this(const(ubyte)[] key, in ubyte[12] iv)Constructs a reader from derived key material.