ddn.net.ssh.packet

SSH binary packet protocol (RFC 4253 section 6).

Cleartext framing used before the first key exchange completes: a packet is a uint32 length, a padding-length byte, the payload, and random padding. Assembly is incremental and bounded; every length is validated before any buffer growth, and sequence numbers advance per direction and never reset.

The protected (AEAD) framing lands with the packet-protection task and plugs into the same reader/writer interfaces.

Types 4

Packet-layer limits from the support matrix.

packetMax = 35000Maximum accepted total packet length
payloadMin = 32768Minimum payload every implementation must accept
paddingMax = 255Maximum padding bytes in one packet
paddingMin = 4Minimum padding bytes
blockSize = 8Cipher block size for alignment purposes (stream-safe default)
classSshPacketException : Exception

Raised for packet-layer violations: bad lengths, bad padding, or assembly overruns.

Constructors
this(string msg, string file = __FILE__, size_t line = __LINE__)Constructs a packet-layer exception.

Incremental cleartext packet assembler.

Feed transport bytes as they arrive; a complete, validated packet surfaces through take.

Fields
private ubyte[] buffer_
private uint sequenceNumber_
Methods
uint sequenceNumber() @property const pure nothrow @nogcReturns: the sequence number of the next packet to be assembled.
bool packetReady() @property const pure nothrow @nogc @safeReturns: whether a full packet is buffered and ready.
void feed(const(ubyte)[] data) @safeFeeds received bytes into the assembler.
ubyte[] take() @safeTakes the next completed packet payload.
const(ubyte)[] pending() @property const pure nothrow @nogcReturns: bytes buffered so far that are not yet a full packet.
void resetSequence() pure nothrow @nogc @safeResets the sequence counter (strict KEX after NEWKEYS).
private void validateHeader() @safe
private uint totalLength(const(ubyte)[] header) static pure nothrow @nogc @safe
private uint readUint32BE(const(ubyte)[] b) static pure nothrow @nogc @safe

Cleartext packet writer: pads and frames payloads.

Fields
private uint sequenceNumber_
private CryptoRandom rng_
Methods
uint sequenceNumber() @property const pure nothrow @nogcReturns: the sequence number of the next packet to be written.
void resetSequence() pure nothrow @nogc @safeResets the sequence counter (strict KEX after NEWKEYS).
ubyte[] frame(const(ubyte)[] payload) @trustedFrames one payload as a complete cleartext packet.
private void writeUint32BE(ubyte[] b, uint v) static pure nothrow @nogc @safe
Constructors
this(CryptoRandom rng)Constructs a writer.