wire / wire-format / ssh-binary-packet
An SSH (RFC 4253) binary packet: 4-byte packet length (big-endian, not including the length field itself or MAC), 1 byte padding length, payload (max 32768 bytes, typically 35000 with extensions), random padding (4-255 bytes, total packet length multiple of cipher block size or 8), then an optional MAC (if not using AEAD).
aka: SSH binary packet protocol
spec: RFC 4253 (SSH Transport Layer)
An SSH (RFC 4253) binary packet: 4-byte packet length (big-endian, not including the length field itself or MAC), 1 byte padding length, payload (max 32768 bytes, typically 35000 with extensions), random padding (4-255 bytes, total packet length multiple of cipher block size or 8), then an optional MAC (if not using AEAD).
| field | size | meaning |
|---|---|---|
| Packet length | 4 bytes | Length of (padding length + payload + padding) in bytes, big-endian. Does not include itself or the MAC. |
| Padding length | 1 byte | Number of padding bytes (4-255, or 0 with AEAD ciphers). |
| Payload | variable | The SSH message (key exchange, service request, user auth, channel data, ...). |
| Random padding | = padding length | Random bytes to fill to a block boundary; also hides message length. |
| MAC | variable | Message authentication code (HMAC-SHA1/SHA2) over sequence number + unencrypted packet; omitted with AEAD (chacha20-poly1305, aes-gcm). |
example:
00 00 00 0c 05 0a 01 00 00 00 04 74 65 73 74 00 00 00 00
Packet length 12, padding 5, payload = SSH_MSG_KEXINIT-ish (shortened)
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/ssh-binary-packet
or /wire-format/ssh-binary-packet.json