Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

SSH implementation notes

================================================================================
 SSH LAYER IMPLEMENTATION
 Analysis of the StreamSec.SSH.* units (SSH-2.0 transport / auth / connection)
 (StreamSec Security Library for Embarcadero Delphi)
================================================================================

Generated: 2026-06-06
Updated:     2026-10-23  (pointers to test files, which do not ship, are
                          removed, also from the stamps below; section 13,
                          TESTS & INTEROP, now states what the
                          tests verified instead of listing them.)
Corrected:   2026-10-23  (the KEY EXCHANGE table cites RFC 10042 for the
                          ML-KEM hybrids, as section 9 does; a column of the
                          feature matrix is realigned.)
Updated:     2026-10-18  (RFC 9941 sntrup761/X25519 key exchange, including the
                          OpenSSH alias; hybrid ML-KEM citations use RFC 10042.)
Corrected:   2026-09-28  (THERE IS NO DEFAULT ALGORITHM OFFER. Every cipher,
                          MAC and key-exchange selection starts empty, the
                          host-key offer follows the keys the application
                          loads, and only compression starts selected, at
                          "none". Section 3 called its lists "in default
                          preference order", with a "default first choice"
                          and a "shipped default", and section 8's LEGACY
                          ALGORITHMS note described a "default offer" with
                          SHA-1 / CBC fallbacks. None of that existed: the
                          lists are the registered algorithms, in
                          registration order. Both passages are corrected.)
Regenerated: 2026-08-03b (stAESNI gained a Win32 (x86) assembler arm, so 32-bit
                          SSH endpoints on AES-NI CPUs get hardware AES as
                          well; stAESCT now serves only x86 CPUs genuinely
                          lacking the instructions plus non-x86 targets. The
                          CIPHERS note in section 3 is updated accordingly.)
Regenerated: 2026-08-03  (AES IMPLEMENTATION STORY: the aes-* ciphers now resolve
                          to hardware or constant-time software AES instead of the
                          cache-timing-leaky lookup tables. stAESNI gained the
                          SSH-CTR and SSH-GCM cipher classes it predated - so
                          aes*-ctr and aes*-gcm@openssh.com finally get AES-NI on
                          CPUs that have it (Delphi Win64 and, new, FPC on SysV
                          x86-64) - and the NEW stAESCT unit registers a
                          constant-time bitsliced AES exactly where AES-NI is
                          absent (Win32, x64 without the instructions, all
                          non-x86 targets). StreamSec.SSH.Transport and the snip
                          endpoints force-link both units. See the CIPHERS note
                          in section 3.)
Regenerated: 2026-07-20  (CHANNEL CLOSE / EOF SEMANTICS reworked, and the first real
                          subsystem shipped. (1) RFC 4254 sec.5.3 compliance: a peer
                          CHANNEL_CLOSE is now ANSWERED with a CHANNEL_CLOSE (it used
                          to be silently absorbed, leaking a broker slot, whenever the
                          channel had no consumer loop). (2) The stack can now SEND
                          SSH_MSG_CHANNEL_EOF at all - new SendEOF on both channel
                          interfaces + both brokers - and peer EOF is observable
                          without a blocking probe via the new PeerEOF property.
                          (3) TCP half-close: new tAbstractSocket.ShutdownSend
                          (tWinSocket SD_SEND / tPosixSocket SHUT_WR); inbound
                          half-close is unconditional, OUTBOUND is opt-in behind the
                          new gSSHForwardHalfClose global (default False). (4) The
                          subsystem AUTHORIZATION CONTRACT is now documented in-code:
                          SupportsSubSystem applies the per-user grant only "if
                          Assigned(fUsers)", so each subsystem must either carry its
                          own auth layer (Snif/Snip do) or refuse when the grant is
                          unenforceable (SFTP does). (5) StreamSec.SFTP.* added -
                          client + jailed server subsystem, 6 units in StrSecIV370
                          (see section 10 and SFTP.txt). Tested: forwarding and SFTP
                          in-process, OpenSSH sftp + PuTTY psftp interop PASS.
                          All 28 packages Win32 GREEN; the POSIX ShutdownSend path
                          compile-verified for Linux64 with dcclinux64.)
Regenerated: 2026-07-18  (LISTENER BIND FAILURE fixed: the accept-daemon socket is
                          now bound + listening inside tTCPDaemon.Create, so
                          Active := True RAISES (EstSocketError) on a bind/listen
                          failure instead of the daemon thread dying silently with
                          Active stuck True. New published OnError event on
                          TstSSHSocketServer fires if the daemon thread dies LATER
                          (e.g. an in-loop re-listen failure); the SSHDAEMONFAULT
                          test define injects that fault deterministically.
                          Tested GREEN.
                          Section 8 bullet incl. the Windows excluded-port-range
                          ops gotcha; section 7 notes how -R remote-listener bind
                          failures are reported (synchronously, via the protocol).)
Regenerated: 2026-07-13  (server publickey user-auth EXTENDED to EdDSA (ssh-ed25519/
                          ed448) and ECDSA (ecdsa-sha2-nistp256/384/521): verify arms
                          in ClientAuthenticationServer, SSHEcdsaBlobToRaw exported,
                          robust wire-vs-stored match in PublicKeyList (re-derive the
                          canonical wire from the key object), server-sig-algs now
                          advertises the full set. Self-interop GREEN
                          AND real-OpenSSH interop GREEN -
                          OpenSSH_10.3p1 `ssh` -> our server with
                          ed25519/ecdsa256/384/521.
                          Built GREEN: StrSecIV370 Win32/64 + all StrSecIV170-290
                          runtime and DStrSecIV170-290 design pkgs (XE3..Athens).)
Regenerated: 2026-07-13  (unit-by-claim accuracy pass vs the code: fixed the
                          dependency graph (BlockPadding/KeyAgreement/auth-unit/
                          channel edges), the RFC 4250 + Types.pas attribution,
                          the chacha20-poly1305 framing locus (stChaCha20Poly1305,
                          not BlockPadding), session requests (subsystem-only; no
                          exec/shell), the server publickey user-auth set (RSA/DSA/
                          x509 only), and the ML-KEM encaps/decaps roles)
Regenerated: 2026-07-12  (full re-verification against the current StreamSec.SSH.*
                          code: no protocol/unit changes; corrected the weak-cipher
                          note - 3des-cbc / arcfour / blowfish and hmac-md5[-96] are
                          REMOVED entirely, not merely "off by default"; zlib is
                          registered but off unless selected)
Regenerated: 2026-07-07  (no protocol/unit changes since 2026-07-01; test
                          inventory corrected as to where the forwarding
                          matrix and the Snif-over-SSH tests live)

--------------------------------------------------------------------------------
0. SUMMARY
--------------------------------------------------------------------------------

The folder contains ONE modern SSH-2.0 implementation: the "StreamSec.SSH.*"
unit family (29 units). It is the production stack and has REPLACED the older
"stSSH*" framework everywhere (the StrSecIV370 runtime package contains 24
StreamSec.SSH.* units and ZERO stSSH* units). Class names were preserved across
the rename so existing application code is unaffected.

The implementation is a client AND server SSH-2.0 stack covering the three SSH
protocol documents:

    RFC 4253  Transport Layer   (version exchange, KEXINIT, binary packet, rekey)
    RFC 4252  Authentication    (none / password / publickey)
    RFC 4254  Connection        (session channel + subsystem request,
                                 -L/-R TCP/IP port forwarding)

On top of the connection layer sits the first fully-implemented subsystem, SFTP
(StreamSec.SFTP.*, 6 units in StrSecIV370): a protocol-3+5 client AND a jailed
single-identity server subsystem. It is documented in section 10 here and in
detail in SFTP.txt.

It is built on the DSI public-key framework (StreamSec.DSI.* - ECC, EdDSA/CurveEd,
ML-KEM, RSA/IFC, FFC) plus stRandom / stDrbgAesCtr, NOT the legacy stMP* arithmetic
(which does not compile under Delphi 13). The local version banner is
"SSH-2.0-StreamSecTools4.0".

It has been interop-validated against OpenSSH 10.x (sshd / ssh / ssh-keygen),
PuTTY/plink and ssh-audit; the 16-cell port-forwarding role x platform x peer
matrix is all-green. Section 13 states what the tests verified.

This document maps each unit to the relevant RFCs, lists the algorithms that ARE
implemented and the standard SSH features that are NOT, describes the transport /
KEX / auth / connection behaviour, and documents the inter-unit dependencies.


================================================================================
1. UNIT INVENTORY  (StreamSec.SSH.*)
================================================================================

TRANSPORT & NEGOTIATION
  StreamSec.SSH.Transport.pas        Binary packet protocol, version exchange,
                                     KEXINIT algorithm negotiation, rekeying,
                                     strict-KEX (Terrapin) handling.
  StreamSec.SSH.KeyAgreement.pas     Key-exchange methods (DH / ECDH / curve25519
                                     / curve448 / ML-KEM / sntrup761-X25519)
                                     + exchange-hash + the
                                     host-key signature/verify drive.
  StreamSec.SSH.KeyFormat.pas        Host/user key blob encode/decode (ssh-rsa,
                                     ssh-dss, ecdsa-*, ssh-ed25519/ed448).
  StreamSec.SSH.Types.pas            Byte-level wire codec (mpint/string
                                     encode/decode); NOT the msg-number/algo tables.
  StreamSec.SSH.Options.pas          Negotiable algorithm preference lists.
  StreamSec.SSH.Error.pas            SSH disconnect / error codes.

CIPHERS / MAC / COMPRESSION
  StreamSec.SSH.BlockPadding.pas     SSH packet framing: CBC/CTR padding + AES-GCM
                                     AEAD (chacha20-poly1305 is in stChaCha20Poly1305).
  StreamSec.SSH.CipherHelix.pas      Helix stream cipher (legacy/optional).
  StreamSec.SSH.Compression.pas      Compression interface ("none" / "zlib").
  StreamSec.SSH.CompressionZLib.pas  zlib backend.

AUTHENTICATION
  StreamSec.SSH.ClientAuthentication.pas        Client auth driver (password /
                                     publickey), userauth message flow.
  StreamSec.SSH.ClientAuthenticationServer.pas  Server-side userauth driver
                                     (publickey sig check; PBKDF2 pwd in Server.pas).
  StreamSec.SSH.PublicKeyList.pas    authorized-keys-style public-key store.
  StreamSec.SSH.PkixKeyFormat.pas / PkixKeyIndex.pas
                                     PKIX/key-store integration for SSH keys.

CONNECTION / CHANNELS / FORWARDING
  StreamSec.SSH.Client.pas / Server.pas         Top-level client & server engines.
  StreamSec.SSH.ClientChannel.pas / ServerChannel.pas   Channel multiplexing
                                     (session + subsystem request); close/EOF
                                     state machine (fCloseSent/fEOFSent, PeerEOF).
  StreamSec.SSH.ServerSubSystem.pas  Subsystem dispatch + the base classes a
                                     subsystem author starts from
                                     (tSSHBaseServerSubSystem /
                                     TstCustomSSHSubSystem). Carries the
                                     AUTHORIZATION CONTRACT comment (section 8).
  StreamSec.SSH.ForwardingClient.pas / ForwardingClientSocket.pas
                                     client-side remote (-R) forwarding.
  StreamSec.SSH.ForwardedListenerSocket.pas / DirectSenderSocket.pas
                                     server-side -R listener + -L direct-tcpip sender.
  StreamSec.SSH.SocketClient.pas / SocketServer.pas     socket-bound engines.
  StreamSec.SSH.ChannelStreamWin32.pas          Win32 channel-as-stream adapter.
  StreamSec.SSH.BaseComponent.pas    Common component base.
  StreamSec.SSH.Reg.pas              Design-time registration.

SUBSYSTEM ON TOP OF THE STACK  (StreamSec.SFTP.*, 6 units - see section 10)
  StreamSec.SFTP.Types.pas           SFTP constants + iFileAttributes.
  StreamSec.SFTP.Version3Types.pas   protocol-3 attribute encoding.
  StreamSec.SFTP.Version5Types.pas   protocol-5 attributes / ACL / supported.
  StreamSec.SFTP.Transport.pas       SFTP packet layer over an SSH channel.
  StreamSec.SFTP.Client.pas          TstSFTPClient component.
  StreamSec.SFTP.ServerSubSystem.pas Jailed server subsystem
                                     (TstSFTPServerSubSystem + tSFTPJail).
  StreamSec.SFTP.Reg.pas/.dcr        Design-time registration (DStrSecIV370).


================================================================================
2. RFC MAP - WHICH RFC DEFINES WHAT, AND WHETHER IT IS IMPLEMENTED
================================================================================

CORE PROTOCOL (implemented)
  RFC 4251  - SSH Protocol Architecture (terminology, identifiers).
  RFC 4253  - SSH Transport Layer: version string, SSH_MSG_KEXINIT negotiation,
              binary packet protocol, key derivation (HASH-based), service
              request. (StreamSec.SSH.Transport / KeyAgreement.)
  RFC 4252  - SSH Authentication Protocol: the userauth service, "none",
              "password" and "publickey" methods. (ClientAuthentication[Server].)
  RFC 4254  - SSH Connection Protocol: channels, session + subsystem request,
              direct-tcpip / forwarded-tcpip / tcpip-forward port forwarding.
              (Client/ServerChannel, Forwarding*.) sec.5.3 close semantics -
              CHANNEL_EOF (send + receive) and the "MUST answer CHANNEL_CLOSE
              with CHANNEL_CLOSE" rule - are implemented; see section 7.
  RFC 4250  - Assigned message/algorithm numbers (SSH_MSG_* in Transport.pas;
              algorithm-name registries in Options.pas).

KEY EXCHANGE (implemented)
  RFC 4344  - SSH Transport Encryption Modes: AES-CTR, and the rekeying data
              limits (Transport rekey bound).
  RFC 5656  - ECC for SSH: ecdsa-sha2-nistp256/384/521 host keys and
              ecdh-sha2-nistp256/384/521 key exchange.
  RFC 7748  - X25519 / X448 functions, underlying the curve25519/curve448 KEX.
  RFC 8268  - Additional MODP DH groups: group14-sha256, group15/16/18-sha512.
  RFC 8731  - curve25519-sha256 and curve448-sha512 key exchange.
  RFC 9142  - KEX method updates/recommendations (the group/curve set above is
              the RFC 9142 "recommended" floor; group14-sha1 kept for legacy).

HOST / USER KEYS (implemented)
  RFC 8332  - rsa-sha2-256 / rsa-sha2-512 (SHA-2 RSA signatures; ssh-rsa/SHA-1
              kept only for legacy peers).
  RFC 8709  - ssh-ed25519 and ssh-ed448 (Ed25519/Ed448 host keys).

CIPHERS / MAC (implemented)
  RFC 5647  - AES-GCM for SSH (and the aes128/256-gcm@openssh.com variant).
  RFC 6668  - hmac-sha2-256 / hmac-sha2-512 MACs.
  OpenSSH PROTOCOL.chacha20poly1305 - chacha20-poly1305@openssh.com AEAD.

EXTENSIONS / HARDENING (implemented)
  RFC 8308  - Extension Negotiation: ext-info-c / ext-info-s and the
              server-sig-algs extension (advertising the full publickey user-auth
              set: ed25519/ed448, ecdsa-sha2-nistp*, rsa-sha2-*, ssh-rsa, ssh-dss).
  draft-ietf-sshm-strict-kex-02 "strict KEX", under the pre-standard names
              kex-strict-c/s-v00@openssh.com - the Terrapin (CVE-2023-48795)
              prefix-truncation mitigation: the peer's KEXINIT first, nothing
              but the key exchange's own messages during the initial key
              exchange, and sequence numbers reset after every NEWKEYS
              (section 8).

SUBSYSTEMS (implemented) - see section 10
  draft-ietf-secsh-filexfer-02  - SFTP protocol version 3 (the de-facto version:
              what OpenSSH's sftp speaks). Client + server.
  draft-ietf-secsh-filexfer-05  - SFTP protocol version 5 (ACLs, richer
              attributes, SSH_FXP_RENAME flags). Client + server.
              NOTE these are expired Internet-Drafts, never RFCs; v3 and v5 are
              nonetheless what deployed implementations negotiate.

POST-QUANTUM (implemented) - see section 9
  RFC 10042 - Hybrid ECDHE+ML-KEM KEX (Informational, August 2026):
              mlkem768x25519-sha256, mlkem768nistp256-sha256 and
              mlkem1024nistp384-sha384, using FIPS 203 ML-KEM.
  RFC 9941  - Hybrid sntrup761 + X25519 KEX (Informational, April 2026):
              sntrup761x25519-sha512 and its identical
              sntrup761x25519-sha512@openssh.com alias.
  draft-harrison-sshm-mlkem - Pure FIPS 203 ML-KEM KEX:
              mlkem512-sha256, mlkem768-sha256 and mlkem1024-sha384.
              These pure methods remain draft-based.

NOT IMPLEMENTED (standard SSH features that are absent) - see section 12
  RFC 4256  - keyboard-interactive authentication.
  RFC 4252 sec.9 - hostbased authentication.
  RFC 4419  - diffie-hellman-group-exchange-sha1/sha256.
  RFC 4462  - GSSAPI key exchange / authentication.
  *-etm@openssh.com MACs (Encrypt-then-MAC) and umac-64/128.
  OpenSSH certificate host keys (ssh-*-cert-v01@openssh.com).
  zlib@openssh.com (delayed/authenticated compression).
  X11 forwarding and agent forwarding (auth-agent@openssh.com).


================================================================================
3. IMPLEMENTED ALGORITHMS  (negotiated in KEXINIT)
================================================================================

NOTHING BELOW IS OFFERED UNTIL THE APPLICATION SELECTS IT. Each list shows
what the library REGISTERS - what can be selected - in registration order.
Every cipher, MAC and key-exchange selection starts empty and the host-key
offer follows the keys the application loads, so a client or server
negotiates nothing until the application has chosen its algorithms
(SelectedOptionNames on each option-list property). The order of that
selection is its preference order. Only compression starts selected, at
"none". The registration order puts the PQ-HYBRID key exchanges first
(ML-KEM, then sntrup761/X25519), followed by pure ML-KEM, classical curves
and MODP-DH groups: an application
that selects in that order is post-quantum first while staying interoperable.

KEY EXCHANGE  (StreamSec.SSH.KeyAgreement; in registration order)
  mlkem768x25519-sha256                     RFC 10042 hybrid (PQ; OpenSSH-compatible)
  mlkem768nistp256-sha256                   RFC 10042 hybrid (PQ)
  mlkem1024nistp384-sha384                  RFC 10042 hybrid (PQ)
  sntrup761x25519-sha512                    RFC 9941 hybrid (PQ)
  sntrup761x25519-sha512@openssh.com        RFC 9941 alias (same engine)
  mlkem768-sha256 / mlkem1024-sha384 / mlkem512-sha256   FIPS 203 pure (PQ)
  curve25519-sha256                         RFC 8731
  curve448-sha512                           RFC 8731
  ecdh-sha2-nistp256 / nistp384 / nistp521  RFC 5656
  diffie-hellman-group16-sha512             RFC 8268
  diffie-hellman-group18-sha512             RFC 8268
  diffie-hellman-group15-sha512             RFC 8268
  diffie-hellman-group14-sha256             RFC 8268
  diffie-hellman-group14-sha1               RFC 4253   (legacy, last resort)

HOST / PUBLIC KEYS  (StreamSec.SSH.KeyFormat - supported formats; the actual
offer is driven by the host keys the application loads, not a fixed list)
  ssh-ed25519                               RFC 8709
  ssh-ed448                                 RFC 8709
  ecdsa-sha2-nistp256 / nistp384 / nistp521 RFC 5656
  rsa-sha2-256 / rsa-sha2-512               RFC 8332
  ssh-rsa                                   RFC 4253   (SHA-1; legacy)
  ssh-dss                                   RFC 4253   (legacy)
  (also present: proprietary ssh-rsa-sha224/256/384/512 and
   ssh-dss-sha224/256/384/512 hash-named variants - NON-standard, kept for
   internal/back-compat use; do not enable for OpenSSH interop.)

CIPHERS  (StreamSec.SSH.BlockPadding; in registration order)
  chacha20-poly1305@openssh.com             AEAD (registered first)
  aes256-gcm@openssh.com / aes128-gcm@openssh.com   OpenSSH AES-GCM AEAD
  AEAD_AES_256_GCM / AEAD_AES_128_GCM       RFC 5647 native GCM names
  aes256-ctr / aes192-ctr / aes128-ctr      RFC 4344
  aes256-cbc / aes192-cbc / aes128-cbc      RFC 4253   (legacy)
  + proprietary: twofish{128,192,256}-ctr/-cbc, shacal256-cbc/ctr@streamsec.com,
    helix@streamsec.com  (StreamSec extensions; not for OpenSSH interop)
    The twofish* ciphers are DEPRECATED - use aes*-ctr or an AEAD cipher. On
    every platform but Win32 and Win64 (Linux64, macOS, iOS, Android) TwoFish
    has no block function, so a connection cannot use it there: the cipher
    raises eCipherError on the first packet it encrypts or decrypts.
    shacal256-* is offered only on Win32 and Win64: elsewhere stSHACAL does
    not register SHACAL-2.
  NOT registered at all: 3des-cbc, arcfour, blowfish (removed entirely - not
    recognised and not selectable, per StreamSec.SSH.Options).

  WHICH AES IMPLEMENTATION BACKS THE aes-* ENTRIES (since 2026-08-03). The
  SSH cipher names above map to cipher CLASSES resolved from the cipher-class
  registry, and three AES implementations compete for those slots:
    stAES    table-driven software AES - cache-timing variable (lookups
             indexed by key/data bytes). No registered aes-* cipher resolves
             to it any more.
    stAESNI  hardware AES-NI, registering where the CPU has the instructions
             (Delphi Win32 AND Win64, and FPC on SysV x86-64:
             Linux/macOS/BSD). It INCLUDES the SSH-CTR and SSH-GCM mode
             classes, so aes*-ctr and aes*-gcm@openssh.com run on AES-NI
             machines rather than falling back to the tables (~1.5 GB/s per
             core vs ~610 MB/s table asm).
    stAESCT  constant-time bitsliced software AES (Boyar-Peralta circuit,
             after BearSSL aes_ct), registering on exactly the complement of
             stAESNI's CPUID predicate: x86 CPUs without AES-NI (either
             bitness) and every non-x86 target (~40-50 MB/s per core - paid
             precisely where the tables would leak). Key schedule
             constant-time too.
  ON A DELPHI NON-WINDOWS BUILD, PUT chacha20-poly1305@openssh.com FIRST.
  The hardware AES arms are reached by a Delphi WIN32/WIN64 compile, and
  under FPC by SysV x86-64 and by aarch64 Linux/Android. A DELPHI build for
  Linux64, macOS, iOS or Android has no hardware AES at all and the aes-*
  ciphers resolve to the constant-time software implementation. (The ARMv8
  crypto extensions ARE implemented, but only for FPC: Delphi's ARM
  compilers reject inline assembler. An FPC aarch64 Linux build therefore
  gets hardware aes-*-gcm/ctr and does not need this advice.)
  Measured on one x64 core, ChaCha20-Poly1305 runs ~180 MB/s against
  ~80-95 MB/s for constant-time AES-GCM - roughly twice the throughput,
  with no security trade-off, since both are constant-time. On Windows the
  same preference costs an order of magnitude (AES-NI GCM is ~1900 MB/s),
  so this is a per-target decision, not a global one.

  The application's selection decides it: chacha20-poly1305@openssh.com
  heads the registration order above, but nothing is offered until the
  application selects it. In SSH the CLIENT's order decides (the first
  client algorithm the server also supports wins), so a client on these
  targets that puts it first gets it from any server that supports it.
  The case to watch is a selection that puts AES first, or an AES-only set
  chosen for policy reasons: on a Delphi POSIX or mobile build that halves
  bulk throughput. Servers are affected the same way, but Delphi's POSIX
  and mobile targets are overwhelmingly client-side.

  Tag acceptance is constant-time for every AEAD/MAC on this list
  (aes*-gcm, chacha20-poly1305@openssh.com, the *-omac MACs and Helix):
  they compare through stSecUtils.EqualMemConstantTime, so the time taken
  to reject a forged tag does not reveal how many of its leading bytes
  were correct.

  StreamSec.SSH.Transport and the snip client/server force-link both units,
  so an SSH-only statically linked application gets the right implementation
  without naming any crypto unit. chacha20-poly1305@openssh.com is a single,
  already constant-time implementation and is unaffected; the aes-*-omac
  MACs ride the same registry and switch implementation with the cipher.

MAC  (used only by the CBC/CTR suites; the AEAD ciphers carry their own tag)
  hmac-sha2-256 / hmac-sha2-512             RFC 6668
  hmac-sha1 / hmac-sha1-96                  RFC 4253
  + proprietary: aes-{128,192,256}-omac@streamsec.com,
    twofish-{128,192,256}-omac@streamsec.com  (OMAC/CMAC; StreamSec extensions)
    The twofish-*-omac MACs are DEPRECATED - use hmac-sha2-256 or -512.
  NOT registered at all: hmac-md5 / hmac-md5-96 (removed entirely).

COMPRESSION  (only "none" starts selected; zlib is registered but must be
              selected explicitly)
  none                                      RFC 4253
  zlib                                      RFC 4253


================================================================================
4. TRANSPORT LAYER  (RFC 4253) - DETAIL
================================================================================
  - VERSION EXCHANGE: each side sends "SSH-2.0-<software>\r\n"; the raw banner
    lines are retained because they feed the exchange hash H.
  - KEXINIT: each side sends its name-lists (kex / host-key / enc c2s / enc s2c /
    mac c2s / mac s2c / comp c2s / comp s2c). The first algorithm on the client
    list that the server also supports is chosen, per side/direction. The
    ext-info-c/s and kex-strict markers are appended here (sections 8).
  - BINARY PACKET: [packet_length(4) | padding_length(1) | payload | padding |
    MAC]. AES-GCM AEAD framing (RFC 5647) lives in BlockPadding (tSSHGCMBlockPadding);
    chacha20-poly1305@openssh.com does its own OpenSSH framing (no block padding) in
    stChaCha20Poly1305 (tSSHChaCha20Poly1305).
  - KEY DERIVATION: the six keys (IV c2s/s2c, enc c2s/s2c, MAC c2s/s2c) are
    derived from the shared secret K, the exchange hash H and the session id via
    the RFC 4253 sec.7.2 HASH(K || H || "A".."F" || session_id) ladder, extended
    by re-hashing when more key bytes are needed.
  - REKEYING: a new KEX is run on the RFC 4344 data/packet bound (cRekeyBound) or
    on demand; the session id stays fixed, only K/H and the derived keys change.
  - WRITING A PACKET (TstSSHSocketClient / TstSSHSocketServer): every packet is
    written whole, through tAbstractSocket.SendAll. When the socket takes part
    of it the rest follows; when the send buffer is full the send waits for
    room (WaitForWrite) and offers the same bytes again. That matters wherever
    a socket does not wait on its own: every connection a TstSSHSocketServer
    accepts on Windows, and every socket on POSIX. The published SendTimeout
    (ms, default 30000, 0 = no limit) ends a wait in which not one byte was
    taken: the socket is closed and the send raises eExternalSendError. The
    clock restarts at every byte taken. Packets go out one at a time under the
    transport lock, which the connection also reads under, so a packet that
    waits holds up its whole connection; freeing or deactivating the server
    (CloseAllOnDeactivate) ends the wait at once, and closing SocketClient
    ends a client's. A client socket on Windows waits inside send() itself,
    and never reaches this, unless WaitForData has been called on it.
    (CHANGES 36.)
  - WAITING FOR THE PEER'S NEXT MESSAGE: a read that needs it - in a key
    exchange, for a client the server's answers to its service request and
    authentication requests, for a server after the login - polls with
    growing sleeps (1, 2, ... 99 ms) and ends the connection with
    SSH_MSG_DISCONNECT reason 10 when the peer has sent nothing for about
    5 s: 4.95 s on Linux64, 5.8 s on Windows at the default timer
    resolution. The wait for a guessed first key exchange packet that the
    peer's KEXINIT announces (first_kex_packet_follows, RFC 4253 section
    7.1) is one of these, at either end (CHANGES 116). A server LOGGING A
    CLIENT IN waits instead for as long as its
    LoginGraceTime allows (ms, default 120000 as in OpenSSH's sshd, 0 = no
    limit), counted from the moment it took the connection on and covering
    the version strings, the key exchange, the service request and user
    authentication together: a person may be at the other end - OpenSSH and
    PuTTY ask whether to trust a host key they do not know before they send
    NEWKEYS, and ask for the password after the server's first answer.
    Skipped messages (IGNORE, DEBUG) do not extend it. The wait for the
    client's version string also ends after 30,000 sleeps of 1 ms - about
    33 s on Linux64, about 8 minutes on Windows at the default timer
    resolution - if that comes first. The server reads each authentication
    request holding the transport lock; Disconnect and freeing the server
    first end a login under way (iSSHServerLogin.CancelLogin), within
    about 0.1 s, and so does deactivating a TstSSHSocketServer with
    CloseAllOnDeactivate. The transport's lock is freed with the transport,
    when the last reference to it goes, not when its session ends.
    (CHANGES 113-114.)
  - A MESSAGE CUT SHORT: the transport reads the fields of
    SSH_MSG_DISCONNECT, SSH_MSG_DEBUG and SSH_MSG_UNIMPLEMENTED, and the
    service name of SSH_MSG_SERVICE_REQUEST and SSH_MSG_SERVICE_ACCEPT,
    from the message's own packet only - a message is one packet's payload
    (RFC 4253 section 6). A field that runs past the end of the packet -
    cut inside, missing, or a string longer than the rest - ends the
    connection at once with SSH_MSG_DISCONNECT reason 2 (protocol error)
    and eSSHOutgoingDisconnect; the next packet is never read as its rest.
    Data after the last field is dropped, and the data of an
    SSH_MSG_IGNORE is not read at all. (CHANGES 118.)
  - DISCONNECT DURING A LOGIN: until a client has logged in, the
    connection's own thread uses the transport without its lock - in the
    key exchange, the wait for the service request, the check of each
    authentication request and the USERAUTH_SUCCESS - so no other thread
    sends on the connection or closes it then. Disconnect, freeing the
    server and a Close made during the login only cancel it and return at
    once; the connection's thread sends SSH_MSG_DISCONNECT reason 11 and
    closes the connection the next time it reads or sends (at once while
    it waits for the client, otherwise when the step under way - a password
    or key check, an event handler - is done), and sends the client
    nothing else after the cancellation. After the login, Disconnect closes
    the connection from the caller's thread under the transport lock.
    (CHANGES 115.)
  - CLOSE DURING A CLIENT'S CONNECT OR LOGIN: the client's twin of the
    above. TstCustomSSHClient.ConnectToHost, Login and RequestService run
    on the caller's thread and use the transport without its lock - the
    version exchange, the key exchange and OnSetKey, user authentication
    and OnGetClientPassword - so no other thread sends on the connection or
    closes it then (iSSHClientCall). Close made on another thread during
    one of them, and TsnipClient.Stop while Start connects and logs in,
    only cancel the call and return at once; the call's own thread sends
    SSH_MSG_DISCONNECT reason 11 and closes the connection the next time it
    reads or sends (at once while it waits for the server, also while a
    packet arrives a little at a time or the server sends line after line
    before its version string, otherwise when the step under way - an
    event handler - is done, or as the call ends), sends the server nothing
    else, takes the transport off the client (Connected False) and ends the
    call with an exception. A call cancelled while the TCP connection is
    being made sends nothing at all, not even its version string, and ends
    once the connect is over; on Windows the connect is not cut short (to a
    host that does not answer, until the system gives up on it), elsewhere
    the wait for it ends at once. Login and RequestService make the channel
    broker as the call ends, under the client's own lock that Close takes
    too: a cancelled call makes none, and a Close after that closes the
    connection as after a Login. The version string is read only as it
    arrives, also on a socket that waits for data (a TstSSHSocketClient's
    on Windows), so the wait for a server that sends nothing ends at a
    Close too, and otherwise after 30,000 looks (about 8 minutes on
    Windows), as a server's does when its LoginGraceTime has not run out
    first. At most 1,024 other lines are read before it,
    at either end; one more ends the connection with reason 8. Not
    covered: a Close while CreateChannel, GlobalRequest or AddListener runs
    on another thread - so neither a TsnipClient.Stop while Start opens its
    channel, between the login and the wait for the channel open, nor one
    during the Snif login after it. Freeing the client during such a call
    is not supported. (CHANGES.txt entry 34, after 4.1.4.361.)


================================================================================
5. KEY EXCHANGE  (RFC 4253 sec.8, RFC 5656, RFC 8731) - DETAIL
================================================================================
  - All KEX methods compute the shared secret K through ONE unified path: the
    peer public value is processed by aPeerPub.GroupOpIteration on the method's
    group, and K is encoded as an mpint (with StripLeadingZeroBytes) for FFC/ECC.
    This single path replaced an earlier per-family split that mis-handled the EC
    vs FFC encodings. Verified against OpenSSH for curve25519, ecdh-nistp256/384/
    521, and dh-group14/16/18.
  - IsECDHGroup is a virtual predicate (NOT "Supports(group, iECurve)", because
    FFC groups also satisfy that), so the mpint-vs-string encoding of K is chosen
    correctly per method.
  - The exchange hash H is HASH(V_C || V_S || I_C || I_S || K_S || <method
    e/f or client/server pub> || K). The server signs H with the host key; the
    client verifies it - this authenticates the server and binds the whole
    negotiation. Host-key sign/verify is driven from KeyAgreement.
  - SHARED-KEY HANDLING: the host signing key is treated as immutable during a
    handshake (its signature digest/encoding is set once at startup, never
    per-connection), because the key instance is shared across connection threads.


================================================================================
6. AUTHENTICATION  (RFC 4252) - DETAIL
================================================================================
  Methods implemented: "none", "password", "publickey".

  PASSWORD: the server stores a PER-USER PBKDF2-HMAC verifier (per-user iteration
  count + hash in the user store; defaults 100000 iterations / SHA-512). The
  verifier is computed/checked via ComputeVerifier -> GetVerifier /
  AuthPassword.

  PUBLICKEY: the client signs the RFC 4252 sec.7 blob (session_id || SSH_MSG_
  USERAUTH_REQUEST || ... || public key) and the server verifies the signature
  against the stored authorized key (PublicKeyList). The server verify path
  (tSSHClientPublicKeyAuthenticationServer) covers the full set: ssh-ed25519 /
  ssh-ed448 (RFC 8709, EdDSA over the raw message), ecdsa-sha2-nistp256/384/521
  (RFC 5656, mpint r||mpint s), rsa-sha2-256/512 and ssh-rsa (RFC 8332 / legacy),
  ssh-dss and x509v3-sign-*. server-sig-algs (section 8) advertises exactly this
  set. The authorized-key store matches the presented key by re-deriving the
  stored key's canonical SSH wire form (TstSSHPublicKeyList / tKeyContainer), so
  an authorized key of any type matches however the store was populated: added
  with SetPublicKey, or kept in the list's PublicKeyFileName, where each key is
  an RFC 4716 block with the user name in a Subject header - ECDSA and EdDSA
  keys as SSH-Base64-ECDSA / SSH-Base64-ED25519 / SSH-Base64-ED448, whatever
  RSAPublicKeyFormat and DSSPublicKeyFormat select for RSA and DSS keys.
  EdDSA/ECDSA verify against a fresh per-request key so the shared authorized
  key is never mutated.
  Partial-success / multi-method continuation is handled by the userauth driver.

  NOT implemented: keyboard-interactive (RFC 4256), hostbased (RFC 4252 sec.9),
  GSSAPI (RFC 4462). See section 12.


================================================================================
7. CONNECTION PROTOCOL  (RFC 4254) - DETAIL
================================================================================
  - CHANNELS: open/close, window/adjust, data, EOF. Multiplexed by
    Client/ServerChannel. Extended data (CHANNEL_EXTENDED_DATA, a server's
    stderr) is received but not kept: neither channel class sends it or hands
    it to the application.
  - RECEIVING CHANNEL DATA: the connection's reading thread (the broker) copies
    each CHANNEL_DATA packet into the channel's window buffer and only then
    moves the write position past it. RecvLength is the write position less
    the read position, and Recv / InputStream copy from the buffer, so a
    reader on another thread - an application or the SFTP client reading a
    client channel, a subsystem's ReadData on its subsystem thread - never
    counts a byte that is not stored yet. The broker is the only thread that
    moves the write position forward. It goes back to 0 (ResetLocalWindow,
    under the transport lock, right after sending the WINDOW_ADJUST) only once
    the whole window has been taken in, when the broker has nothing left to
    store. Forwarded channels are read on the broker thread itself, straight
    after the copy (InternalAfterWriteChannelData).
    (CHANGES 44.)
  - SENDING CHANNEL DATA: a channel's Send (iTransport.Send on any
    iSSHWindowedChannel) passes octets as far as the peer's window allows.
    When the window shuts during the Send it waits about a second and a half
    (100 x 10 ms) for the peer to open a new one, then returns the count it
    passed - aCount or fewer - and when the window is shut already it returns
    0 at once (CHANGES 76). A protocol that frames what it sends must not
    stop there: SendAllOnChannel (StreamSec.SSH.Transport) waits for the
    window for as long as the channel is open and sends all of it. Port
    forwarding (CHANGES 62), the SFTP client and server (CHANGES 96) and snip
    over SSH (CHANGES 97) send that way. The snip connection also takes
    everything its channel holds into a buffer of its own whenever it looks
    for a message, so a window is opened again as soon as its last octet has
    arrived and a message of any size arrives whole. (Tested for SFTP
    and for snip.)
  - EXTENDED DATA AND THE WINDOW (RFC 4254 sec.5.2): CHANNEL_EXTENDED_DATA
    consumes the same window as CHANNEL_DATA, so the broker counts its octets
    against the window (DiscardChannelData, fLocalWindowDiscarded) and drops
    them. The window is used up once the octets read and the octets
    discarded add up to its size, and is then reopened (ReopenLocalWindow):
    by the reader in Recv, or by the broker itself when extended data ends a
    window whose data has all been read - the reader has nothing left to
    Recv then. Both decide only under the channel's fLocalWindowLock (Recv
    takes it on every pass), which is where each sees what the other did;
    the WINDOW_ADJUST + ResetLocalWindow happen under it too, so only the
    first to find the window used up sends one. RecvLength reads the two
    offsets under the same lock: a reopen by the broker sets the reader's
    offsets back to 0, and a count taken from the old write offset and the
    new read offset would hand the reader the previous window again. Before
    CHANGES 69 extended data was dropped uncounted and the channel stopped a
    window short, on both sides.
  - REQUESTS FROM THE SERVER (client side, RFC 4254 sec.4 and 5.4): a
    GLOBAL_REQUEST or CHANNEL_REQUEST with want_reply is answered
    REQUEST_FAILURE or CHANNEL_FAILURE - the client acts on none. The
    channel failure goes to the peer's number for the channel and is not
    sent after our CLOSE. One without want_reply (exit-status, exit-signal,
    hostkeys-00@openssh.com) is dropped. OpenSSH's sshd sends
    keepalive@openssh.com this way when ClientAliveInterval is set and ends
    the connection when ClientAliveCountMax go unanswered, which it did to
    this library's idle clients before CHANGES 69. (Interop: a script
    against a private OpenSSH sshd.)
  - GLOBAL REQUESTS FROM THE CLIENT (server side, RFC 4254 sec.4):
    tSSHServerChannelBroker.ReadGlobalRequest decodes want_reply itself,
    then hands tcpip-forward to a new listener from the listener controller
    and anything else to the open forwarded listeners (cancel-tcpip-forward);
    those decode want_reply again and send REQUEST_SUCCESS. A request none
    of them takes is answered REQUEST_FAILURE only when want_reply is set.
    Replies carry no request id and a client matches them to its requests
    by order, so before CHANGES 80 a FAILURE sent to a request without
    want_reply (no-more-sessions@openssh.com, an unknown one, a
    cancel-tcpip-forward of a port not forwarded) was taken as the answer to
    the client's next tcpip-forward: TstSSHForwardingClientSocket.Open
    raised although the server was listening. A GLOBAL_REQUEST that ends
    before want_reply raises eSSHDecodeError, which ends the connection, as
    a CHANNEL_REQUEST that ends there does. (Interop: a script running
    OpenSSH's ssh -R against our server identifying itself as OpenSSH.)
  - CLOSE / EOF STATE MACHINE (RFC 4254 sec.5.3):
      * There is NO central close logic. Close COMPLETION is delegated to whatever
        consumer owns the channel: forwarding channels have a loop (tTCPThrd.
        DoExecute polls fChannel.State every ~100 ms); a session channel's
        consumer is its subsystem, which calls Close (see SESSION below).
      * A received CHANNEL_CLOSE is ANSWERED with a CHANNEL_CLOSE by
        DoDisconnected itself, on both sides - the sec.5.3 MUST. That frees the
        PEER's channel number; ours is freed when the close completes.
      * DoDisconnected deliberately does NOT complete the close of a channel
        that has a consumer: it replies, stays csClosing, and lets the
        consumer's Close finish. Recv only drains the local window in
        [csConnected,csClosing], so completing it there DISCARDS the last
        buffered data (a real regression, caught by the -L remote-close test
        cell, which asserts the echo payload actually arrives).
      * SERVER, a channel with NO consumer: the virtual InternalHasConsumer
        (tCustomSSHServerChannel, True) decides. tSSHServerChannel answers
        whether a subsystem is attached; a session channel with none - none
        asked for, or the one asked for refused - has no reader and nobody to
        call Close, so DoDisconnected completes its close itself, right after
        its reply (both CLOSEs sent: sec.5.3's "considered closed"). Before
        CHANGES 112 it stayed csClosing on the broker until the connection
        ended, and each one held a MaxChannels slot, its DefaultWindowSize
        local window and its subsystem thread. A subclass whose own code consumes
        such a channel overrides InternalHasConsumer to answer True.
      * csClosing is ambiguous ("we closed first" vs "we replied to the peer"),
        so both channel classes carry fCloseSent: Close sends only if not
        fCloseSent. That makes Close idempotent, which is what lets the forwarding
        finally-blocks close unconditionally - necessary because after a
        peer-initiated close only that call does RemoveFromBroker.
      * SENDING CHANNEL_EOF is new. SendEOF was added to iSSHClientChannel /
        iSSHServerChannel and to both brokers, guarded by fEOFSent and only while
        csConnected and before our own CLOSE.
      * RECEIVING it is now observable: the new PeerEOF property exposes the
        formerly-private fLocalWindowEOF flag. Before this, peer EOF could ONLY be
        detected by a blocking Recv returning 0 - and Recv(aBlock=True) fills the
        WHOLE requested count, so it had to be a 1-byte probe. The new virtual
        InternalAfterCloseLocalWindow (overridden by tSSHServerChannel) also wakes
        the subsystem thread on EOF instead of flipping a flag silently.
  - SESSION: "session" channel with the "subsystem" request. ServerSubSystem
    dispatches the subsystem; SFTP (section 10), Snif and Snip are the shipping
    consumers. "exec"/"shell"/"pty-req" are NOT implemented (subsystem-only
    server). A subsystem MUST register itself via
    (aChannel as iSSHServerChannelSession).SetSubSystem(Result) at the end of
    NewSubSystem: TstCustomSSHServer.ExecuteSubSystem DISCARDS the interface
    NewSubSystem returns, so without that call fSubSystem stays nil and ReadData
    is never invoked at all.
    A subsystem MUST also complete its channel's close: ReadData drains,
    dispatches, and then calls aChannel.Close once aChannel.PeerEOF is set or
    aChannel.State <> csConnected (the server wakes the subsystem thread for
    the client's EOF and for its CLOSE). That is the application's part of the
    contract: the server answers the client's CLOSE
    but leaves the channel csClosing on its broker for the subsystem, so a
    subsystem that never calls Close keeps the channel's MaxChannels slot, its
    DefaultWindowSize local window and its subsystem thread until the
    connection ends, and the open after MaxChannels such channels is refused
    with SSH_OPEN_RESOURCE_SHORTAGE. SFTP and snip
    do this. A session channel with NO subsystem attached is closed by the
    server itself (CLOSE / EOF STATE MACHINE above).
  - PORT FORWARDING (the validated feature matrix):
      * Local  (-L): the client opens a direct-tcpip channel to the target -
        no dedicated component (Client.CreateChannel / ConnectToHost); the
        server-side DirectSenderSocket originates the onward TCP connection.
      * Remote (-R): the client sends the tcpip-forward global request and dials
        the target (ForwardingClient / ForwardingClientSocket); the server-side
        ForwardedListenerSocket is the listener that opens forwarded-tcpip
        channels back to the client. A remote-listener BIND FAILURE is reported
        synchronously through the protocol: the listener daemon sets its error
        flag, the blocking Listen returns False and the server DENIES the
        client's tcpip-forward request (no OnError involvement; '' / 'localhost'
        bind addresses are normalized to literal IPs first).
    Both directions, and both close orders, are interop-tested against OpenSSH and
    self (every cell of the role x platform x peer x variant matrix is green).
  - TCP HALF-CLOSE (new 2026-07-20). tAbstractSocket gained a virtual abstract
    ShutdownSend, overridden by tWinSocket (shutdown SD_SEND) and tPosixSocket
    (SHUT_WR) - only those two descendants exist, so the blast radius is small.
      * INBOUND is unconditional and pure gain: a peer CHANNEL_EOF now calls
        fSock.ShutdownSend, so the local forward target actually sees a FIN
        instead of nothing.
      * OUTBOUND is OPT-IN via the new global gSSHForwardHalfClose in
        StreamSec.SSH.Transport, DEFAULT FALSE. The reason is a hard protocol
        limit: a TCP FIN cannot distinguish "peer closed its send side" from
        "peer closed entirely", so unconditionally waiting for the peer after a
        local FIN leaves the channel open forever against a fully-closed target.
        Default False = announce EOF, then close immediately (historical prompt
        teardown, now with a correct EOF). Set it True only for forwarded
        protocols that genuinely half-close (HTTP-style request-then-read),
        accepting that a peer which never answers leaves the channel open.
      * IMPLEMENTATION TRAP: tTCPThrd descends from tPooledThread and is REUSED.
        Per-connection flags (fLocalEOFSent / fPeerEOFSeen) MUST be reset next to
        the existing fClosed := False in each unit's connect/accept setup, or a
        recycled thread believes the previous connection's half-close already
        happened and never reads its socket. Symptom: the FIRST -R test passes and
        the SECOND fails with an empty echo.
      * IMPLEMENTATION TRAP: fSock.Receive with no aErrorCode argument RAISES on a
        real error (WSAECONNRESET 10054). Pass @lErr and treat lLen<0 with lErr<>0
        as a close, lLen<0 with lErr=0 as the spurious-readable wakeup.
  - DYNAMIC forwarding here is HTTP-CONNECT, not SOCKS: a local (-L) variant where
    the listener reads the target host:port from each connection's HTTP request
    ("Host:") and opens a direct-tcpip channel to that per-connection target via
    the client's CreateChannel primitive. Shown in the Tunnel Client demo
    (TunnelClientEngine); it is NOT the SSH SOCKS "-D" forward - no SOCKS4/5
    listener exists, and it is not part of the interop matrix above.
  - NOT implemented: X11 forwarding, agent forwarding (auth-agent@openssh.com).


================================================================================
8. EXTENSIONS & SECURITY BEHAVIOUR
================================================================================
  - TERRAPIN MITIGATION (CVE-2023-48795): "strict KEX" (draft-ietf-sshm-
    strict-kex-02) is offered in each end's first SSH_MSG_KEXINIT under the
    pre-standard names, kex-strict-c-v00@openssh.com by the client and
    kex-strict-s-v00@openssh.com by the server. The standard names
    kex-strict-c and kex-strict-s are neither offered nor recognised, so with
    a peer that offers only those there is no strict KEX. It is in force when
    the peer's first SSH_MSG_KEXINIT carries the other side's name, and then
    for the whole connection: the name in a later SSH_MSG_KEXINIT, or its
    absence, is ignored (draft section 3.1). While it is in force:
      - the peer's SSH_MSG_KEXINIT must be the first packet it sends. A packet
        before it - SSH_MSG_IGNORE, SSH_MSG_DEBUG, a message this end does not
        recognise - is handled as it arrives as without strict KEX, which is
        not known yet; when the SSH_MSG_KEXINIT is then read, this end sends
        SSH_MSG_DISCONNECT with reason 3 (SSH_DISCONNECT_KEY_EXCHANGE_FAILED)
        and raises eSSHOutgoingDisconnect (draft section 3.2);
      - until this end has read the peer's SSH_MSG_NEWKEYS of the initial key
        exchange, any message but the key exchange's own and
        SSH_MSG_DISCONNECT ends the connection the same way (section 3.2);
      - the sequence numbers go back to 0 after every SSH_MSG_NEWKEYS, the
        initial key exchange's and each later one's: for the packets sent,
        after this end's SSH_MSG_NEWKEYS, for the packets read, after the
        peer's (section 3.3).
    Without it the sequence numbers run on through every key exchange (RFC
    4253 section 6.4). The transport counts the packets each way itself and
    gives each cipher it makes at SSH_MSG_NEWKEYS the sequence number of the
    next packet; aes-gcm's nonce counter is its own (RFC 5647) and is not
    given one. Measured in both directions against OpenSSH 9.5 (Windows)
    rekeying every 1024 octets (sshd and sftp with RekeyLimit 1K) under
    aes128-ctr with hmac-sha2-256, chacha20-poly1305@openssh.com and
    aes128-gcm@openssh.com, and against a test's own transport
    with and without strict KEX (CHANGES 103; also a script driving
    OpenSSH's sshd and sftp).
  - EXT-INFO (RFC 8308): ext-info-c/s is advertised and SSH_MSG_EXT_INFO is
    exchanged; server-sig-algs lets the client pick rsa-sha2-256/512 instead of
    the deprecated ssh-rsa/SHA-1 even when the key blob is "ssh-rsa".
  - NO HANDSHAKE MUTATION OF SHARED KEYS: signature parameters of the shared host
    key are never changed mid-handshake (thread-safety across connections); the
    per-connection hash is selected via the signing call's explicit hash argument.
  - SECRET ZEROIZATION: KEX shared secrets and derived key material are wiped
    (iSecretKey / ProtectClear) after use.
  - PUBLICKEY SIGNATURE VERIFICATION: the server verifies a client publickey
    signature over the RFC 4252 sec.7 blob with the session id LENGTH-PREFIXED,
    and builds the hash with .CreateUnkeyed + DoneBytes, matching how the peer
    computes it.
  - LISTENER BIND FAILURE IS VISIBLE: the socket is created, bound and set
    listening in tTCPDaemon.Create (StreamSec.SSH.SocketServer), which runs in
    the ACTIVATING thread, so a bind/listen failure (port in use, no
    permission) makes Active := True raise EstSocketError and leaves Active
    False, rather than killing the accept thread silently. AN ACCEPT THAT
    TAKES NOTHING leaves the listening socket open and the daemon waits
    again - pausing 100 ms when the socket is readable again at once, a
    connection waiting that cannot be taken (EMFILE), as sshd does. Closing
    and reopening the listening socket there would reset every connection
    waiting in its queue (CHANGES 121). On Windows it happened each time
    a connection the server took on ended, until tWinSocket.Accept cancelled
    the WSAEventSelect association an accepted socket keeps from its
    listening socket (CHANGES 132):
    the client's FIN woke the daemon. If the
    daemon thread dies LATER (canonically: waiting on the listening socket
    fails), the published OnError event (tSSHServerErrorEvent -
    Sender + the Exception; fired from the daemon thread, suppressed on normal
    deactivation) is the app's cue to log and schedule Active := False +
    re-activation - there is NO automatic restart, and Active may keep reading
    True until the dead thread's Synchronize'd OnTerminate runs. The
    SSHDAEMONFAULT define compiles in a gSSHDaemonFault hook that injects a
    daemon fault for tests (never defined in shipping builds). OPS NOTE: on
    Windows, "excluded port ranges" (netsh interface ipv4 show
    excludedportrange protocol=tcp - Hyper-V/WSL reservations that MOVE across
    reboots) make bind fail with WSAEACCES 10013 and mimic a code regression;
    raising on activate surfaces this immediately.
  - SUBSYSTEM AUTHORIZATION CONTRACT (documented in-code). The
    per-user subsystem grant (tUserItem.SubSystems) is applied by
    TstCustomSSHServer.SupportsSubSystem ONLY "if Assigned(fUsers)". On a server
    with no TstSSHServerUsers component a bare controller match therefore
    suffices, and ANY authenticated user reaches EVERY registered subsystem.
    That state is REACHABLE, not theoretical: publickey auth validates against
    ClientKeys without consulting the user list at all (SetAuthData), and
    password auth is satisfied by an OnSetClientPassword handler. (Password auth
    with neither users NOR that event does raise, so that one path fails closed.)
    This fall-through is BY DESIGN and must NOT be "fixed" centrally - the server
    cannot know how a given subsystem authorizes its callers. Instead every
    subsystem must satisfy ONE of:
      1. carry its own authentication/authorization layer - Snif and Snip do,
         which is why they survive being exposed this way; or
      2. REFUSE to serve when the SSH-level grant cannot be enforced - what
         TstSFTPServerSubSystem.RequireUserAuthorization (default True) does,
         closing the channel when Server.Users is nil.
    The contract is spelled out in comments at SupportsSubSystem
    (StreamSec.SSH.Server) and on TstCustomSSHSubSystem
    (StreamSec.SSH.ServerSubSystem), i.e. on the base class a new subsystem
    author starts from. Both branches have negative-control test coverage
    (section 13).
  - REGISTRATION ORDER: tUserItem.SubSystems.SelectedOptionNames selects among
    ALREADY-registered option names only. Register the controller (Server := ...)
    BEFORE granting the name to a user, or the grant silently does nothing and
    the server answers "refused the subsystem request".
  - LEGACY ALGORITHMS: there is no default offer to carry them. Every
    algorithm selection starts empty (section 3), so which algorithms are
    offered is the application's decision. The library still REGISTERS some
    SHA-1 / CBC names for interop with older peers -
    diffie-hellman-group14-sha1, hmac-sha1[-96] and aes*-cbc - and each is
    offered only if the application selects it: select them only for a peer
    that needs them. ssh-rsa (SHA-1) is among the host-key formats, whose
    offer follows the keys the application loads (section 3). The weakest
    names (3des-cbc, arcfour, blowfish, hmac-md5[-96], group1-sha1) are not
    registered at all and cannot be selected.


================================================================================
9. POST-QUANTUM KEY EXCHANGE  (RFC 10042 / RFC 9941 / pure ML-KEM draft)
================================================================================
  Six ML-KEM KEX methods are implemented and self-interop green; mlkem768x25519-
  sha256 is also green both directions against OpenSSH:

    HYBRID (ECDHE + ML-KEM, shared secret = HASH(K_PQ || K_classical) as an SSH
    "string"):
      mlkem768x25519-sha256     (X25519  + ML-KEM-768)   - OpenSSH default-aligned
      mlkem768nistp256-sha256   (P-256   + ML-KEM-768)
      mlkem1024nistp384-sha384  (P-384   + ML-KEM-1024)

    PURE (ML-KEM only, shared secret K = K_PQ as an mpint):
      mlkem512-sha256 / mlkem768-sha256 / mlkem1024-sha384

  The hybrid methods use the library's composite-KEM interface to combine an
  ECDHE share with the ML-KEM encapsulation; the classical and PQ parts are
  combined per the SSH PQ-KEX construction, then fed into the standard exchange
  hash. The client sends its ML-KEM (composite) public value in the first KEX
  message; the server encapsulates to it and returns the ciphertext, which the
  client decapsulates.

  RFC 9941 adds sntrup761x25519-sha512 and the interchangeable OpenSSH alias
  sntrup761x25519-sha512@openssh.com. Both names select the same client/server
  engine and SHA-512 transcript hash. The client sends the 1158-byte sntrup761
  public key followed by its raw 32-byte X25519 public value (1190 bytes);
  the server sends the 1039-byte sntrup761 ciphertext followed by its raw
  32-byte X25519 public value (1071 bytes). Both sides enforce these exact
  lengths and reject an all-zero X25519 shared secret. The combined secret is
  SHA-512(K_sntrup || K_x25519), encoded as a fixed 64-byte SSH string for the
  exchange hash AND key derivation. It is never converted to an mpint.

  StreamSec.DSI.Sntrup761 implements the native Pascal DSI provider tDSISNTRUP
  and the tSNTRUPKey / tSNTRUPPublicKey / tSNTRUPPrivateKey classes. The shared
  interfaces iSNTRUPKey, iSNTRUPPublicKey, iSNTRUPPrivateKey and iDSISNTRUP
  live in StreamSec.DSI.PKTypes. Obtain the registered provider through
  GetDSISNTRUP / MustGetDSISNTRUP, or create a separate tDSISNTRUP instance
  when setting a provider-specific PRNG. SSH uses these typed keys and the
  provider's KEMKeyGen / Encaps / Decaps operations.

  Private-key objects own zeroizing iSecretKey storage. Import validates key
  encoding and consistency; encoded-key getters return copies. The generic
  key-format framework exposes SNTRUP public/private format interfaces, base
  classes and format lists, so concrete encoders can use PKTypes contracts
  without depending on the implementation. These extension points assign no
  new ASN.1 algorithm identifier or certificate format.

  Encapsulation requires two distinct output variables and raises eSNTRUPError
  if the same variable is passed twice. Decapsulation permits input and output
  to share a variable or allocation without overwriting a distinct input.
  Results are published only after success; exceptions from key accessors and
  random sources propagate unchanged. Temporary secrets are cleared on exit.

  Decapsulation uses
  implicit rejection: a well-sized but invalid ciphertext yields a fallback
  secret rather than an oracle indicating ciphertext validity. The ensuing
  SSH host-signature/key confirmation fails for a tampered exchange.

  Applications must select the desired KEX names in SelectedOptionNames;
  registering these methods does not enable an algorithm offer by default.

  PK providers are application dependencies. StreamSec.SSH.KeyAgreement and
  StreamSec.SSH.KeyFormat use the shared interfaces and registered providers;
  they do not link the asymmetric implementations. Add the units needed by
  the application's selected algorithms to its uses clause:

    Fixed-group DH       StreamSec.DSI.FFC
    X25519/X448 or NIST  StreamSec.DSI.ECC
    sntrup761/X25519     StreamSec.DSI.Sntrup761 + StreamSec.DSI.ECC
    Pure ML-KEM          StreamSec.DSI.MLC
    Hybrid ML-KEM        StreamSec.DSI.CompositeKEM + StreamSec.DSI.MLC
                          + StreamSec.DSI.ECC

  Each KEX option's SuggestRequiredUnits reports its provider, random-source
  and hash units. The component's existing SuggestRequiredUnits mechanism
  aggregates these for the selected KexOptions. Host/user key components and
  their formats suggest their own providers. A built-in KEX is available
  only when its providers and required curve are registered.

  The SSH Snip components follow the same policy. TsnipClient and TsnipServer
  aggregate SuggestRequiredUnits from their owned SSH configuration; the server
  also asks the host-key component selected by HostKeyKind. Client verification
  requirements follow the selected host-key formats; an assigned client key
  contributes requirements when publickey login is selected. TsnipSSHClient
  and TsnipSSHServer forward requirements from their assigned SSH endpoints.
  The standard component editor can add these units through TstBaseComponent.
  Configured KEX and host-key names remain discoverable for suggestions and
  component streaming even when their providers are unavailable; the wire offer
  contains only usable algorithms. The default ML-KEM/X25519 Snip preset requires MLC,
  ECC and CompositeKEM, plus IFC for an RSA host key and EdDSA when accepting
  Edwards host keys. TLS keeps its intentional forced-provider linking.

  Validated 2026-10-18 on Win32 AND Win64: tests pass per target (native and
  ST4_NO_ASM) through iDSISNTRUP, including three
  independent OpenSSH-C full KEM vectors, implicit-rejection outputs, RFC 9941 Appendix A's
  combiner/string K, typed imports/exports, common-interface dispatch, defensive
  copies, aliased buffers, key lifetimes and injected PRNG/accessor failures.
  Provider availability and the generic/typed format registry are checked per
  target. Both names and malformed exchanges are exercised per target.
  Both names and both roles are tested against OpenSSH 10.3p1
  (client) / 10.2p1 (server), including 128 KiB SFTP upload/download with
  SHA-256 agreement and repeated key exchange under a 16 KiB rekey limit.
  All 14 runtime packages (XE3 through Delphi 13) build for both targets.


================================================================================
10. SFTP SUBSYSTEM  (draft-ietf-secsh-filexfer-02 / -05)
================================================================================
  Summarised here because it is the first fully-implemented subsystem and it
  exercises the connection layer harder than anything else; the full treatment
  (packet formats, attribute encoding, jail rules, per-version behaviour) is in
  SFTP.txt.

  SCOPE: protocol versions 3 and 5, CLIENT and SERVER. Six units in StrSecIV370
  (section 1); design-time registration in DStrSecIV370 via StreamSec.SFTP.Reg
  (TstSFTPClient + TstSFTPServerSubSystem on the 'StreamSec SSH Tools' palette
  page, icons at 16/24/32 32-bpp).

  CLIENT: TstSFTPClient over tSFTPTransport, which frames SFTP packets on an SSH
  session channel opened with the "sftp" subsystem request. Ported from the
  obsolete stSFTP* tree; paths are carried as UTF-8 tBytes rather than native
  strings, which is what the protocol actually specifies.

  SERVER: TstSFTPServerSubSystem - a JAILED, SINGLE-IDENTITY subsystem. It does
  NOT impersonate the authenticated user; every operation runs as the server
  process, confined by tSFTPJail to a configured RootDir (optionally a per-user
  subdirectory). Consequently it needs NO special Windows privileges - no
  SeCreateSymbolicLinkPrivilege, SeRestorePrivilege, SeTcbPrivilege or
  SeSecurityPrivilege - because none of the operations that require them
  (impersonation, symlink creation, backup/restore semantics, SACL access) are
  performed. tSFTPJail rejects backslashes, drive-letter colons, NUL and
  wildcards, resolves ".." within the virtual namespace only, and then re-checks
  that the canonical physical path still starts with the root.
  RequireUserAuthorization (default True) implements branch 2 of the section-8
  authorization contract.

  WHY ATTRIBUTES ARE ENCODED IN-UNIT rather than through tFileAttributes3/5: the
  set-based tPermissionFlags cannot express the POSIX S_IFMT bits, and a
  protocol-3 client has no type byte - it needs S_IFDIR / S_IFREG in the mode
  word to tell directories from files at all.

  TWO CONTRACTS THE SUBSYSTEM MUST HONOUR (both cost real debugging time):
    * Never block in ReadData - releasing the connection waits for the
      subsystem thread to finish, also when the subsystem has closed its own
      channel from ReadData (CHANGES 50). ReadData is drain -> dispatch ->
      "if PeerEOF or State<>csConnected then Close".
    * Never store the channel in the subsystem. The channel holds the subsystem
      (fSubSystem), so a persistent field forms a channel<->subsystem cycle and
      neither is ever released; hold it for the duration of ReadData only.
    * On peer EOF you must call aChannel.Close yourself or the client hangs
      forever. A real sftp-server is a PROCESS: it exits and sshd emits
      CHANNEL_CLOSE on its behalf. Nothing does that for an in-process
      subsystem. Symptom: every operation succeeds, then sftp/psftp never exits.
      The same Close after the client's CLOSE frees the channel's broker slot,
      which the server leaves to the subsystem (SESSION, section 7).

  INTEROP (both directions): as a SERVER, OpenSSH sftp / PuTTY psftp / curl
  (libssh2) / WinSCP / paramiko each complete a mkdir/put/ls/get/rm/rmdir round
  trip against us (all negotiate v3); as a CLIENT, we drive the real OpenSSH
  sftp-server.exe through a private sshd, which is also the only
  coverage of our v3 client path. See SFTP.txt section 7 for the tests, the
  "." / ".." finding, and an intermittent libssh2-only KEX-establishment
  flakiness (an SSH-transport issue below SFTP, retried in the curl cell).

================================================================================
11. DEPENDENCY GRAPH  (".pas uses" relationships)
================================================================================

Legend:  A -> B  means  "unit A depends on (uses) unit B".

  StreamSec.SSH.Types        -> stDERUtils, stSecUtils
                                (mpint/string wire codec helpers; base of all)
  StreamSec.SSH.Error        -> (leaf: disconnect/error codes)
  StreamSec.SSH.Options      -> Types (algorithm preference lists)
  StreamSec.SSH.Compression  -> (interface) ; CompressionZLib -> zlib backend
  StreamSec.SSH.BlockPadding -> stDERUtils, stSecUtils, stGHash, stBlockCipher
                                (AES-CBC/CTR + AES-GCM packet framing / cipher modes)
  StreamSec.SSH.KeyFormat    -> StreamSec.DSI.PKTypes / CustomKeyFormat,
                                stOIDs + Types (host/user key blobs)
  StreamSec.SSH.KeyAgreement -> stDERUtils, stSecUtils, StreamSec.DSI.* (incl.
                                PKTypes / ArithTypes / FFC.MODPGroups +
                                DSI.CustomKeyFormat), stOIDs
                                (the KEX methods + exchange hash + host-key sign)
  StreamSec.SSH.Transport    -> stMemoryMapFiler, stDERUtils, stSecUtils,
                                Options, KeyAgreement, Compression,
                                stCustomProtoComp
                                (the binary packet + KEXINIT + rekey engine)
  StreamSec.SSH.ClientAuthentication / ClientAuthenticationServer
                             -> Transport (+ Types)
  StreamSec.SSH.Client / Server -> Transport + auth units + channels + KeyFormat
  StreamSec.SSH.ClientChannel / ServerChannel -> Transport (channel multiplexing)
  StreamSec.SSH.ServerSubSystem -> ServerChannel, Server
  StreamSec.SSH.Forwarding* / *Socket / ChannelStreamWin32
                             -> the channel layer (forwarding + socket binding)
  StreamSec.SSH.Reg          -> design-time registration of the components

  StreamSec.SFTP.Types       -> (leaf: SFTP constants + iFileAttributes)
  StreamSec.SFTP.Version3Types / Version5Types
                             -> SFTP.Types, StreamSec.SSH.Types (wire codec)
  StreamSec.SFTP.Transport   -> SFTP.Types + Version3/5Types,
                                StreamSec.SSH.ClientChannel (the channel it frames on)
  StreamSec.SFTP.Client      -> SFTP.Transport
  StreamSec.SFTP.ServerSubSystem
                             -> StreamSec.SSH.ServerSubSystem, ServerChannel, Server
                                (attribute encoding is in-unit, NOT via Version3/5Types
                                 - see section 10)

  Crypto foundation: the DSI public-key stack (StreamSec.DSI.*) and stRandom /
  stDrbgAesCtr supply all asymmetric operations and the CSPRNG; the legacy stMP*
  arithmetic is NOT used.


================================================================================
12. IMPLEMENTED vs MISSING - FEATURE MATRIX
================================================================================
Area              Implemented                         Missing / not implemented
----------------  ----------------------------------  --------------------------
Transport         version exchange, KEXINIT, binary   -
(RFC 4253/4344)   packet, rekey, strict-KEX
Key exchange      curve25519/448, ecdh-nistp*,        diffie-hellman-group-
                  dh-group14/15/16/18, ML-KEM pure    exchange (RFC 4419),
                  + hybrid, sntrup761x25519           gss-* KEX
Host keys         ed25519/448, ecdsa-nistp*,          OpenSSH certificate keys
                  rsa-sha2-256/512, ssh-rsa, ssh-dss  (*-cert-v01@openssh.com)
Ciphers           chacha20-poly1305@openssh,          3des-cbc, arcfour,
                  aes-gcm@openssh, aes-ctr, aes-cbc,  cast128, blowfish, seed,
                  twofish*, shacal/helix (proprietary) rijndael-cbc@lysator
MAC               hmac-sha2-256/512, hmac-sha1[-96],  *-etm@openssh.com (EtM),
                  *-omac@streamsec (proprietary)      umac-64/128, hmac-md5
Compression       none, zlib                          zlib@openssh.com (delayed)
Authentication    none, password (PBKDF2), publickey  keyboard-interactive
(RFC 4252)                                            (4256), hostbased, GSSAPI
Connection        session (subsystem req),            X11/agent forwarding,
(RFC 4254)        -L/-R/dynamic (HTTP-CONNECT) fwd,   exec/shell/pty-req
                  CHANNEL_EOF both ways + sec.5.3
                  close reply, TCP half-close
Subsystems        SFTP v3+v5 client + jailed server,  SFTP v6, symlinks,
                  Snif / Snip class remoting          user impersonation
Extensions        ext-info, server-sig-algs (8308),   ping@openssh.com,
                  strict-KEX (Terrapin)               no-flow-control@openssh.com

  NOTE on AEAD vs EtM: although the separate *-etm@openssh.com MAC algorithms are
  not implemented, the recommended AEAD ciphers (chacha20-poly1305@openssh.com
  and aes-gcm) provide authenticated encryption, so the practical EtM use case is
  covered. EtM is only relevant when negotiating an aes-ctr/cbc cipher.


================================================================================
13. TESTS & INTEROP
================================================================================
  What the tests verified, by area.

  NEGOTIATION. Exercised: our server's algorithm negotiation, under a probe;
  the StreamSec.SSH.* namespace, under a probe; our client against OpenSSH's
  sshd (key exchange + host-key verification); and our SSH server ported to
  Linux64 against the OpenSSH ssh client - key exchange, cipher, MAC,
  host-key and auth-method negotiation, with the snip subsystem hosted.

  PUBLICKEY USER AUTHENTICATION (section 6):
    * the CLIENT side against OpenSSH's sshd: a publickey-only login
      (UserAuthOptions.SelectedOptionNames = 'publickey') exercises the
      signature construction, per key type.
    * the SERVER verify side, our client <-> our server in one process: per
      key type a client key is generated, its public half registered in the
      server's ClientKeys (SetPublicKey), and the login made with
      UserAuthOptions = 'publickey'. Covers the RSA/DSS arms plus the EdDSA
      (VerBuf) and ECDSA (SSHEcdsaBlobToRaw + VerDig) arms and the
      re-derive-from-key authorized-key match. GREEN: ed25519, ed448,
      ecdsa256/384/521, rsa.
    * the SERVER verify side against the REAL OpenSSH client: OpenSSH-format
      public keys are loaded as authorized keys (base64 -> wire blob ->
      SetPublicKey), one per user, and ssh -v must report "Authenticated to
      ... using publickey". GREEN vs OpenSSH_10.3p1: ed25519,
      ecdsa256/384/521.

  LISTENER BIND FAILURE (section 8): Active := True on a blocked or excluded
  port must RAISE, with Active False and OnError silent; then a daemon fault
  injected through gSSHDaemonFault (the SSHDAEMONFAULT define) must fire
  OnError. GREEN.

  A PACKET THAT MEETS A FULL SEND BUFFER is written whole (section 4). A relay
  between our client and our server stops reading one direction while 4 MB go
  the other way; the send waits, then every byte arrives in order. Also
  SendTimeout expiry on both sides (the server closes the connection), a
  server freed while a packet waits, SocketClient.Close ending a client's
  wait, and RawSend over a scripted socket that takes a few bytes at a time.
  Against a release without the fix: eExternalSendError as soon as the buffer
  is full. Loopback only.

  DATA READ FROM A CHANNEL WHILE MORE IS ARRIVING (section 7). The reader
  polls RecvLength and Recv(..., False) in a tight loop and checks every byte
  against its position - a main thread reading a client channel, and a
  subsystem's ReadData reading a server channel - each through a window
  larger than the transfer and through a 256 KB window adjusted as it goes.
  Against a release without the fix, 10 runs each: 56 of 160 transfers wrong
  on Win32, 66 of 160 on Win64, byte counts exact. Loopback only.

  STRICT KEX OVER THE WHOLE CONNECTION (section 8). The other end is the
  test itself, with a transport of its own (AES-128, CTR, HMAC-SHA-256,
  ChaCha20 and Poly1305 written from the standards and checked against
  FIPS-197, RFC 4231 and RFC 8439 first) and its own count of the packets
  each way: as a client to our server and as a server to our client, an
  IGNORE, a DEBUG or message 200 before a KEXINIT offering strict KEX must
  end the connection with DISCONNECT reason 3; then a login and two later key
  exchanges under aes128-ctr/hmac-sha2-256 and chacha20-poly1305, with and
  without strict KEX, a GLOBAL_REQUEST answered after each. A packet that
  does not verify is tried under other numbers and the report names the one
  the other end gave it. Against a release without the fix the test
  fails on Win32, Win64 and Linux64. Also our client against an sshd, and
  OpenSSH's sftp against our SFTP server with RekeyLimit 1K.

  PORT FORWARDING. The 16-cell role x platform x peer matrix is all-green
  (section 0).
    * our client <-> our server, -L and -R with both close orders (the "self"
      cells of the matrix), plus the close-propagation and half-close cells
      added 2026-07-20: GREEN. The half-close cell drives
      the one shape the matrix never did: the TCP client ShutdownSends, and a
      DEFERRED-REPLY target answers only AFTER it sees the FIN, with
      gSSHForwardHalfClose True for the cell. NEGATIVE CONTROL VERIFIED: with
      the switch False the middle check fails with reply="" - the deferred
      reply is lost entirely - while the other two still pass, which isolates
      the fix to the WAITING, not the EOF plumbing. A "Runtime error 217" as
      that run exits is a pre-existing teardown nuisance, not a failure.
    * our server (Linux64-capable) with both forwarding controllers, driven
      by the OpenSSH ssh client, -L/-R with a password login.
    * our client -> sshd port forwarding, -L/-R.
    * the ported SSH port-forwarding units compile for Linux64 (a compile
      check, no runtime test; runtime forwarding is covered by the two tests
      above that run our server).

  SNIF CLASS-REMOTING OVER SSH CHANNELS, on Windows and Linux64 targets.

  SFTP (section 10; SFTP.txt section 7 has the detail):
    * our client <-> our server in ONE process: GREEN. Covers the v3/v5
      operation set, 4 jail-escape refusals, and two authorization cells,
      each with a negative control:
        - a 2nd account with valid credentials but NO SubSystems grant must
          authenticate, open a session channel, yet have "subsystem sftp"
          REFUSED. Negative control: grant that user 'sftp' and the check
          flips to FAIL with no exception.
        - a 2nd server with NO TstSSHServerUsers (port+1, OnSetClientPassword
          returning True) must still authenticate - proving the section-8
          fall-through is reachable - but must refuse SFTP. Negative control:
          set RequireUserAuthorization False and the check flips to FAIL.
      Refusal arrives as eSFTPClientError, not a clean protocol error,
      because ExecuteSubSystem has already replied CHANNEL_SUCCESS before
      NewSubSystem runs, so it manifests as a channel close. The test ends
      with ExitProcess, not Halt: finalization AVs against the parked
      subsystem thread.
    * THE OTHER DIRECTION: our CLIENT against the real OpenSSH
      sftp-server.exe, reached through a PRIVATE sshd on a loopback high port
      (own host key / authorized_keys / config in a temp dir, deleted
      afterwards - so the system SSH config is never read or modified, and no
      elevation is needed). GREEN. Only coverage of our v3 client path.
    * our server against EXTERNAL clients: FIVE PASS a mkdir/put/ls/get/rm/
      rmdir round trip - OpenSSH sftp, PuTTY psftp, curl (libssh2), WinSCP,
      paramiko - all negotiate v3. The curl cell retries an intermittent
      libssh2-only KEX-establishment failure (~1/35 fresh connections, below
      SFTP, not reproduced by OpenSSH) - bounded and logged, so the suite is
      deterministic without hiding it.

  LINUX64 COMPILE VERIFICATION (no PAServer, no sysroot). A dcclinux64 UNIT
  compile needs neither - those are for LINKING/deployment - which is the cheap
  way to check POSIX-only code that the Win32 matrix never sees (stSocket.Posix
  is entirely $IFDEF POSIX). Used 2026-07-20 to verify the half-close change
  set: stSocket.Posix (implements ShutdownSend) plus the five units that
  consume it (Server/ClientChannel and the three forwarding sockets) - all 6
  E=0 F=0, the five SSH units W=0, and stSocket.Posix's 2 warnings
  pre-existing (Posix.StrOpts / MSG_NOSIGNAL platform-specific). CAVEAT: a
  MISSING override would not hard-error, since Delphi only objects when an
  abstract-bearing class is instantiated - so the load-bearing evidence is
  that ShutdownSend appears as a literal symbol in the emitted
  stSocket.Posix.dcu, not the exit code. The CALLERS are conclusive either
  way (an undeclared identifier is a hard error).

  Interop bench used during development: OpenSSH 10.x sshd / ssh / ssh-keygen,
  PuTTY/plink, nmap, ssh-audit, tshark. Results: curve25519 + the ecdh-nistp* /
  dh-group* KEX, ed25519/ecdsa/rsa host keys, AEAD ciphers, publickey + password
  auth, and -L/-R forwarding are all green both directions; mlkem768x25519-sha256
  is green against OpenSSH. Publickey user-auth is green in BOTH roles and for the
  full key set: our client -> sshd and OpenSSH ssh -> our server
  (vs OpenSSH_10.3p1), plus our-client<->our-server - see section 6.

================================================================================
 END OF FILE
================================================================================