|
ProtoCore v0.0.2
Deterministic, zero-heap network stack for embedded targets
|
SSH client-to-server decompression: a resumable, context-takeover INFLATE (no heap). More...
Go to the source code of this file.
SSH client-to-server decompression: a resumable, context-takeover INFLATE (no heap).
The complement of ssh_zlib (server-to-client DEFLATE). SSH zlib / zlib@openssh.com (RFC 4253 sec 6.2) keep one zlib stream alive per direction for the whole session - a persistent 32 KB sliding window carried across packets ("context takeover"), flushed at each packet boundary. OpenSSH compresses its outbound (our inbound, client-to-server) traffic with Z_PARTIAL_FLUSH, which ends each packet at a DEFLATE block boundary but NOT on a byte boundary: the last bits of a packet spill into the next packet's first byte. Decoding it therefore needs a resumable inflate that carries the bit position and the window across ssh_inflate_packet() calls.
The engine keeps that state small by only ever decoding complete DEFLATE blocks: after each feed it retains the few un-decoded tail bytes (the incomplete flush block) plus the bit offset into the first of them, and re-decodes from that boundary when the next packet arrives - so there is no mid-block Huffman-table or symbol state to persist. Back-references read from a caller-supplied 32768-byte circular window (SSH_INFLATE_WINDOW), which holds up to 32 KB of prior output so a match can reach into earlier packets. All state and buffers are caller-owned; the codec allocates nothing.
Definition in file ssh_inflate.h.