Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

Release notes 4.1.5.362

================================================================================
 CHANGES - StreamSec Tools
 (StreamSec Security Library for Embarcadero Delphi)
================================================================================

Grouped by subject. Entries marked BEHAVIOUR CHANGE alter what existing code
does without any source change on your part - read those before upgrading.

WHAT THIS FILE COVERS. Changes made SINCE release 4.1.4.361, which was
released on 2026-10-07. What that release itself brought is in

    CHANGES_4.1.4.361.txt

and every earlier release is archived beside it the same way, one file per
version. So this file is always short: it is the difference between the zip
you have and the one you are looking at, and nothing else.

--------------------------------------------------------------------------------
CMS: AN AuthEnvelopedData CONTENT CIPHER THAT IS NOT AES-GCM WITH GCMParameters
================================================================================

RFC 5083 AuthEnvelopedData names its content cipher in an algorithm identifier,
and that cipher has to be an authenticated-encryption one, such as AES-GCM and
AES-CCM (RFC 5084) or ChaCha20-Poly1305 (RFC 8103). As an AuthEnvelopedData
content cipher this library implements AES-GCM in three key sizes and nothing
else; it has AES-CCM and ChaCha20-Poly1305 ciphers, but not as CMS content
ciphers. A message naming any other identifier there - another AEAD cipher, a
CBC algorithm, which belongs in EnvelopedData, or an identifier no table carries
- or naming AES-GCM with parameters that are not GCMParameters, is a message
this library cannot open, and saying so is all it has to do.


1. FIXED - reading or building the content-encryption algorithm of an
   AuthEnvelopedData that is not AES-GCM with SEQUENCE parameters read past the
   end of the table of the ones this library knows

   The three AES-GCM alternatives are held in tables of three entries each -
   their identifiers, and their parameter types - and the metadata beside them
   declared a field count of NINE: the count belonging to the EnvelopedData
   table beside it, which really does have nine CBC alternatives. Every release
   from 4.0.1.345 to 4.1.4.361 has it.

   THE STEPS THAT FAILED are the two that map an AuthEnvelopedData's content
   encryption algorithm onto one of the alternatives, and the declared count
   bounds both. When a message is read, the first matches the encoding of the
   parameters against each alternative's parameter type, all three a SEQUENCE;
   the second, which also runs when a program sets the identifier, compares the
   identifier against each alternative's identifier. Each stops at the first
   match. So the three AES-GCM identifiers with SEQUENCE parameters ended both
   walks within the table, and so did parameters that are absent, which neither
   walk looks at. Anything else went past the end and read the constants the
   compiler had placed after the table. In the first walk that was parameters
   that are not a SEQUENCE: the OCTET STRING nonce of ChaCha20-Poly1305, a CBC
   IV, or AES-GCM sent with the wrong shape of parameters. In the second it was
   any identifier but the three - AES-CCM, a CBC algorithm, an unknown one -
   whether read with SEQUENCE parameters or set by a program. Measured with
   Delphi 13 on Win32 and Win64, each was an access violation: in the identifier
   walk a read of address 00000DF9 on Win32 and 0000001000000DF9 on Win64; in
   the parameter walk an execution of address 00000000 on Win32 and a read of
   0000001000000220 on Win64. Those addresses are the ones to compare; the
   address of the faulting instruction differs from program to program. With
   another compiler or platform the constants after the table differ, and so
   can the failure.

   WHAT A PROGRAM SAW DEPENDS ON HOW IT READ THE MESSAGE, and through the
   component it saw the right answer for the wrong reason. TstMPEnvelopedData
   loads a message inside a guard that answers False for any failure, so
   Decrypt refused such a message, and refusing it is correct; the access
   violation was raised and caught inside the component. A debugger still
   stopped on it as a first-chance exception, and so did an exception logger
   that reports handled exceptions. A program using the ASN.1 classes itself
   (tContentInfo, tAuthEnvelopedData) got the access violation. Reading with
   fmtBER, which reads the whole message, it came from LoadFromStream. Reading
   with fmtDER, it came on first touching the content-encryption algorithm
   identifier: for parameters that are not a SEQUENCE, reading its algorithm
   was enough; for an identifier but the three, it came on touching its
   parameters. Building an AuthEnvelopedData, it came on touching the
   parameters after setting any identifier but the three.
   TstMPEnvelopedData.Encrypt puts only AES-GCM in an AuthEnvelopedData and was
   not affected.

   The count now says three, and both walks stay inside the table. An
   identifier other than the three AES-GCM ones, set by a program or read with
   parameters that are a SEQUENCE, raises the same eASN1Error the EnvelopedData
   table raises for one it does not carry: "Unidentified type", naming the
   identifier. Parameters that are not a SEQUENCE raise its descendant
   eASN1DataError, "Field parameters missing", which does not name it. With
   fmtBER both come from LoadFromStream; with fmtDER, "Field parameters
   missing" comes when the algorithm identifier is first touched, and
   "Unidentified type" when its parameters are.

   THE DISCRIMINATING TEST: read, with tContentInfo.LoadFromStream and fmtBER,
   an AuthEnvelopedData whose content-encryption algorithm is id-aes128-CCM
   (2.16.840.1.101.3.4.1.7) with its CCMParameters SEQUENCE, or id-aes256-GCM
   with an OCTET STRING as its parameters. An affected release built with
   Delphi 13 for Win32 or Win64 raises an access violation; this one raises
   eASN1Error. Through TstMPEnvelopedData.Decrypt both releases answer False,
   which is why this went unnoticed.

   PLATFORMS. CmsAeadBoundaryTest (battery row Win32) sets id-aes128-CCM,
   ChaCha20-Poly1305, id-aes256-CBC and 2.25.1 as the content-encryption
   algorithm of an AuthEnvelopedData, and reads four content-encryption
   algorithm identifiers - id-aes128-CCM and id-aes256-CBC with SEQUENCE
   parameters, ChaCha20-Poly1305 with its nonce, id-aes256-GCM with an OCTET
   STRING - and requires each of the eight to be refused with an eASN1Error.
   The controls: id-aes256-GCM in an EnvelopedData is refused the same way, and
   the three AES-GCM alternatives read back. An affected release fails those 8
   of its 21 checks, on Win32 and on Win64 alike; this release passes all 21 on
   both. The tables, and the fix, are the same on every platform; only Win32
   and Win64 were run.

   NOT CHANGED: the three AES-GCM alternatives, which resolved correctly before
   and still do, in all three key sizes and whether the message is read or
   written; a content-encryption algorithm with no parameters at all, refused
   with "Field parameters missing" before and now; and which structure takes
   which cipher - AES-GCM in AuthEnvelopedData (RFC 5083, RFC 5084), the CBC
   algorithms in EnvelopedData (RFC 3370, RFC 3565).


--------------------------------------------------------------------------------
SSH SERVER: AN IDLE CONNECTION WITH A CHANNEL OPEN KEPT A CORE BUSY
================================================================================


2. BEHAVIOUR CHANGE - TstSSHServer and TstSSHSocketServer kept a CPU core
   busy for each connection that had a channel open and nothing arriving on
   it, from about a second after the user logged in for as long as the
   channel stayed on the connection: on Windows the whole core, on Linux 12
   to 16 points of one. With a channel open, a message that comes after a
   quiet spell is now read up to one system timer tick later

   The server reads each connection's messages on a thread of its own, the
   connection's channel broker. When nothing has arrived, the broker asks
   the server whether to send an SSH_MSG_IGNORE (OnBeforeSendIgnore) and
   then sleeps for a millisecond before it looks again - with no channel
   open, on every pass. With a channel open it asks only once the last
   IGNORE it sent is older than a span it draws on each pass, between
   10 ms and 1 s, and on a pass that asked it yielded the processor
   (Sleep(0)) instead of sleeping. Sleep(0) returns at once on Windows when
   no other thread is waiting to run, and on Linux after a few tens of
   microseconds. The span runs from the last IGNORE sent, and the server
   sends none unless an OnBeforeSendIgnore handler says so. So with no
   handler, or with one that did not send, every pass from about 1 s after
   the login asked and yielded, and the thread went round without stopping.

   Measured with one connection and one session channel with nothing sent
   on it: the process used 87% or more of one core on Win32 and Win64,
   against 0 to 3% for the same connection before the channel was opened,
   and on Linux64 (WSL, kernel 6.18) 16 to 19.5% against 2.4 to 3.5%. An
   OnBeforeSendIgnore handler that never sends was asked 2.2 to 3.5
   million times in 2.3 s on Windows, and 24,000 to 28,000 times on Linux.

   It went on after the client closed the channel if nothing closed the
   server's end of it. The server answers the client's
   SSH_MSG_CHANNEL_CLOSE and keeps the channel on the connection, closing,
   until whoever uses it calls Close. The SFTP server
   (TstSFTPServerSubSystem) and snip over SSH (TsnipSSHServer) do; a
   channel whose subsystem, one of the program's own, does not stays on the
   connection until the connection ends, and until then counted as a
   channel open. (A session channel with no subsystem has completed its
   close since 4.1.4.361, entry 112 of its notes.)

   A handler that sent IGNOREs often hid most of it: with one every 200 ms
   the last one is never old enough for more than a few passes in a row to
   yield, and the process used up to 5 points of one core. The longer the
   gap between IGNOREs, the more of it was spent going round, and from 1 s
   on, all of it.

   NOW the broker sleeps for a millisecond after every pass that reads
   nothing, whatever the server answered. When it asks about an IGNORE is
   unchanged: on every pass with no channel open, and with channels open
   once the last IGNORE is older than the span drawn on that pass. That age
   is now taken so that it stays right when the system's millisecond count
   wraps, every 49.7 days: before, a wrap that came while the server kept
   answering no could stop the asking, with a channel open, for the next
   49.7 days.

   WHAT IT COSTS. A message that arrives while the broker sleeps waits for
   the sleep to end: about a millisecond on Linux, and on Windows up to the
   system timer's tick (Sleep(1) took 15.3 to 15.6 ms on the test machine).
   The client's broker has always slept this way, and so did the server's
   with no channel open and in a connection's first second. With a channel
   open and no IGNOREs, the server's broker used to read at once, as it
   never slept. A client that waits for each answer before it asks again
   sees the difference: in the test below, echoes sent one after another
   came back 44 to 54 times in 2 s on Windows, against 65 to 80 before, and
   1,026 to 1,138 times on Linux, against 1,395 to 1,465; a single echo
   after a pause took 16 to 63 ms on Windows, against 15 to 47 before, and
   1 to 4 ms on Linux, against 1 to 3. A message that is there when the
   broker looks is read at once, and the next one looked for at once, as
   before.

   WHO. A program with TstSSHServer or TstSSHSocketServer whose clients
   keep a channel open without sending on it - an SFTP session left open, a
   snip over SSH client, which holds its channel for as long as it is
   connected, a forwarded TCP connection (-L or -R) with nothing on it, or
   a subsystem or session of the program's own - with no
   OnBeforeSendIgnore handler, or with one whose IGNOREs are far enough
   apart. Each such connection has a thread of its own, and each of them
   did this. The SSH client (TstSSHClient, TstSSHSocketClient) was not
   affected: its broker sleeps whenever it reads nothing.

   HOW IT WAS FOUND. Measured: a TstSSHSocketServer with one session channel
   from a paramiko 5.0.0 client, open with nothing on it, used 4.97 to 4.98
   s of process CPU in 5 s on Win32, against 0.00 s with no client and with
   a client logged in that had no channel open, and went on so after the
   client closed the channel. Then the broker's code.

   THE DISCRIMINATING TEST: log in to the server, wait a second, open a
   session channel and send nothing on it, and read the server process's
   CPU time over a few seconds. An affected release uses a whole core more
   on Windows than before the channel was opened, and 12 to 16 points more
   on Linux; this one uses no more.

   PLATFORMS. New test SshIdleChannelCpuTest (battery rows Win32, Win64 and
   Linux64) reads the process's CPU time over 2 s spells: with no channel
   open, with a channel left idle, closed by the client and left open by
   its subsystem, and idle with an OnBeforeSendIgnore handler that never
   sends, each against the same connection before the channel; and as
   controls, a subsystem that closes its end, a handler that sends an
   IGNORE every 200 ms, and echoes after a pause and one after another. An
   affected release fails 3 of these 18 checks on Win32, Win64 and Linux64;
   this release passes all of them on the three.

   NOT INVOLVED: what goes on the wire - when the server asks about an
   IGNORE, and what it sends, are unchanged; the SSH client; data that
   keeps arriving.

   NOT CHANGED:

   - The broker still finds out that a message has arrived by looking,
     between sleeps, not by waiting on the socket. On Linux the test's
     process, holding both ends of one connection with nothing on it, used
     2 to 4% of one core, with a channel open or not.
   - A channel the client has closed, whose subsystem never calls Close,
     stays on the connection until the connection ends (entry 112 of the
     4.1.4.361 notes completes the close only for a session channel with no
     subsystem). It no longer costs CPU.


--------------------------------------------------------------------------------
SSH SERVER: WHAT OnBeforeSendIgnore IS TOLD
================================================================================


3. BEHAVIOUR CHANGE - the aTicksSinceLast of the OnBeforeSendIgnore event
   of TstSSHServer and TstSSHSocketServer is the time in milliseconds since
   the server last sent an SSH_MSG_IGNORE on the connection, or since the
   user logged in if it has sent none, as its name and its description
   say. It was the system's millisecond count at that moment

   The server asks OnBeforeSendIgnore whether to send an IGNORE on a
   connection that has nothing to read (entry 2 says when). The event's
   description said it came "with the elapsed idle ticks", and the
   parameter is named for the time since the last one. What the server
   passed was the tick count (GetTickCount) it had noted when it last sent
   one, or when the user logged in: on Windows, the milliseconds since the
   computer started, which wrap every 49.7 days. A handler that took it as
   the time since read the computer's uptime instead. One that sends an
   IGNORE once aTicksSinceLast passes a keep-alive interval sent one each
   time it was asked - with no channel open, every time the connection's
   thread found nothing to read.

   NOW it is the tick count at the call less the noted one, which stays
   right across the wrap. The description of OnBeforeSendIgnore now says
   what the parameter is and when the server asks.

   WHO. A program that assigns OnBeforeSendIgnore and reads
   aTicksSinceLast. A handler written for what the server passed - one
   that subtracts aTicksSinceLast from GetTickCount to get the time since -
   now gets a wrong figure from that subtraction, and must use
   aTicksSinceLast as it is. A handler that does not read the parameter is
   not affected.

   THE DISCRIMINATING TEST: on a connection with nothing sent on it, compare
   aTicksSinceLast in OnBeforeSendIgnore with the time since the login. An
   affected release passes a number close to the computer's uptime in
   milliseconds; this one passes the time since the login.

   PLATFORMS. Two more checks in SshIdleChannelCpuTest (entry 2), which
   has 20 in all: with a handler that never sends, the moment aTicksSinceLast
   names - the call's time less aTicksSinceLast - lies between the client's
   start of the connection and the return of its login; with a handler
   that sends an IGNORE every 200 ms, once the first has gone, it is the
   moment of the last one, within 50 ms. A release with entry 2 and not
   this one fails those 2 on Win32, Win64 and Linux64 (the moment named
   lies as long before the login as the machine, or the WSL instance, had
   been running); this release passes all 20 on the three.

   NOT CHANGED: when the server asks, and what it does with aSendIt and
   aLength.


--------------------------------------------------------------------------------
CMS: A SIGNER, ORIGINATOR OR RECIPIENT NAMED BY ITS SUBJECT KEY IDENTIFIER
================================================================================


4. FIXED - a SignerInfo whose sid is a subjectKeyIdentifier was written with
   universal tag 0 where RFC 5652 has [0] - 00 14 <ski> instead of
   80 14 <ski>, which OpenSSL refuses - and in 4.1.4.361 SignData with
   AllowCMSv3 raises eASN1Error instead; the library did not read the [0]
   form OpenSSL writes; and an rKeyId was written and read with the tag of
   an issuerAndSerialNumber

   RFC 5652, section 12.1, module CryptographicMessageSyntax2004, which is
   DEFINITIONS IMPLICIT TAGS:

      SignerIdentifier ::= CHOICE {
        issuerAndSerialNumber IssuerAndSerialNumber,
        subjectKeyIdentifier [0] SubjectKeyIdentifier }

      OriginatorIdentifierOrKey ::= CHOICE {
        issuerAndSerialNumber IssuerAndSerialNumber,
        subjectKeyIdentifier [0] SubjectKeyIdentifier,
        originatorKey [1] OriginatorPublicKey }

      KeyAgreeRecipientIdentifier ::= CHOICE {
        issuerAndSerialNumber IssuerAndSerialNumber,
        rKeyId [0] IMPLICIT RecipientKeyIdentifier }

   So a subjectKeyIdentifier goes on the wire as 80 14 <20 octets>, and an
   rKeyId as A0 <length> 04 14 <20 octets> .. StreamSec.DSI.CMS declared the
   subjectKeyIdentifier of SignerIdentifier and of OriginatorIdentifierOrKey
   with universal tag 0, and rKeyId with the universal SEQUENCE tag of
   IssuerAndSerialNumber (30). RecipientIdentifier, the rid of a
   KeyTransRecipientInfo and a KEMRecipientInfo, had [0] and was right.

   THE STEPS THAT FAILED:

   - Signing. TstMPSignedData.SignData with AllowCMSv3 = True and a signer
     certificate that has a subjectKeyIdentifier extension names the signer
     by that identifier. 4.1.4.360 and earlier wrote the sid as
     00 14 <ski>; "openssl cms -verify" refuses such a message ("no
     matching choice type" for CMS_SignerIdentifier). 4.1.4.361 refuses to
     encode it (4.1.4.361's entry 134: a value of type ANY with universal
     tag 0) and SignData raises eASN1Error "signerInfos: a value of type ANY
     in it was never set - it has no tag, so there is nothing to encode".
     The counter-signature of CounterSignData with AllowCMSv3 writes its sid
     with the same definition.

   - Verifying. The sid of a message signed by key with the RFC tag -
     "openssl cms -sign -keyid" - matched no alternative, so the signer was
     not looked up and VerifySignedData returned False. By the code, the
     same holds for the signer of an RFC 3161 time-stamp token that names
     its signer by key (StreamSec.DSI.Tsp); that was not measured.

   - Decrypting. A KeyAgreeRecipientInfo whose rid is an rKeyId -
     "openssl cms -encrypt -keyid" to an EC recipient - could not be read:
     eASN1DataError "Field rid missing from ST-CMS.RecipientEncryptedKey",
     and Decrypt returned False. An rKeyId a program built with the DSI
     classes was written 30 .. 04 14 <ski> .., and read back as an
     issuerAndSerialNumber that has no issuer. (OpenSSL's message also
     leaves out the curve of its ephemeral key, which entry 13 is about;
     it decrypts with both.)

   NOW the three are written as RFC 5652 has them: 80 14 <ski>, and
   A0 .. 04 14 <ski> ... They are read in that form, and in the forms
   earlier versions wrote:

   - a subjectKeyIdentifier with universal tag 0 (00 14 <ski>), in a sid or
     an originator;
   - an rKeyId with the universal SEQUENCE tag, which is the tag of an
     issuerAndSerialNumber too. The two are told apart by the first element
     inside: an IssuerAndSerialNumber starts with a Name, a SEQUENCE; a
     RecipientKeyIdentifier with an OCTET STRING. A SEQUENCE that starts
     with neither is refused with eASN1DataError ("a SEQUENCE that is
     neither an IssuerAndSerialNumber (a Name first) nor a
     RecipientKeyIdentifier (an OCTET STRING first)") rather than taken for
     either. Reading the old form with fmtBER needs entry 17 as well.

   Choice reports an identifier read in an old form as
   siSubjectKeyIdentifier, oiSubjectKeyIdentifier or kaRKeyId, and
   AsSubjectKeyIdentifier and AsRkeyId give its value, as for the RFC form.
   The library never writes an old form: wherever it encodes such an
   identifier again - a message loaded with fmtBER, as TstMPSignedData and
   TstMPEnvelopedData load one, or a SignerInfo that was changed - it
   writes the RFC form. A message loaded with fmtDER and saved unchanged
   keeps the octets it was read from, as every structure does (4.1.4.361's
   entry 134). No signature or MAC of RFC 5652 covers a sid, rid or
   originator (sections 5.4, 9.2 and 11.4), so a signature still verifies
   with the identifier written in the other form. A CAdES
   archive-time-stamp-v3 does cover the sid: see the last point under WHAT
   A PROGRAM CAN SEE CHANGE.

   An rKeyId whose optional date was never given was written with the date
   00000000000000Z, which is no time; it is now left out, also when such
   an rKeyId is read and written again.

   WHAT A PROGRAM CAN SEE CHANGE. No declaration changes: the enumerations,
   interfaces and accessors are as they were, and AsSubjectKeyIdentifier
   still returns an iASN1OctetString. But:

   - the object behind AsSubjectKeyIdentifier of a SignerIdentifier or an
     OriginatorIdentifierOrKey is a tASN1OctetString (an OCTET STRING with
     the tag [0]), not a tASN1GenericContent, and a dump shows it as such;
   - a sid or originator whose tag is neither of the two above is no longer
     taken in: the SignerInfo or KeyAgreeRecipientInfo that holds it is
     refused when it is read (eASN1DataError), where before it was taken
     into an identifier that had no alternative selected;
   - the object behind AsIssuerAndSerialNumber of a
     KeyAgreeRecipientIdentifier is a descendant of tIssuerAndSerialNumber;
   - asked for AsIssuerAndSerialNumber, a KeyAgreeRecipientIdentifier that
     holds an rKeyId read in the old form starts a new, empty
     issuerAndSerialNumber, as it does for an rKeyId of the RFC form;
   - a message this version writes with a subjectKeyIdentifier sid is not
     read by 4.1.4.361 or earlier (they select no alternative for 80), so
     programs that exchange such messages need this version on both sides;
   - A SAVED CAdES SIGNATURE CAN LOSE ITS ARCHIVE TIME-STAMP. An
     archive-time-stamp-v3 (ETSI EN 319 122-1) hashes the sid of the
     SignerInfo it is on octet for octet, and the octets of each of its
     unsigned attribute values, a countersignature's sid among them;
     StreamSec.DSI.CAdES builds it that way. A signature 4.1.4.360 or
     earlier made with AllowCMSv3 has the sid 00 14 <ski>. If it has an
     archive-time-stamp-v3 - from AddArchiveTimestamp or ExtendToLTA, or
     from other software - and a program loads it with fmtBER and saves it
     again, the sid is written 80 14 <ski> and the time-stamp no longer
     matches what it stamped: a validator that checks it refuses it. The
     signature itself still verifies. Loading with fmtBER and saving again
     is what TstMPSignedData does when it writes out again a message it
     loaded (FinalSign saves the whole SignedData), and what ExtendToLT and
     ExtendToLTA do with the whole SignedData, every SignerInfo in it, when
     they add to it.
     AddArchiveTimestamp does not: it adds its attribute to the octets it
     was given and leaves the rest of them as they are.

     THE SAFE WAY with such a file: keep the file as it is. Reading and
     verifying it changes nothing - a program that loads it and does not
     save it is not affected. To add an archive time-stamp, use
     AddArchiveTimestamp, which keeps the octets and so the earlier
     time-stamp. A program that must read it with the DSI classes and write
     it out again loads it with fmtDER and saves it unchanged, which keeps
     the octets it was read from. Do not run ExtendToLT or ExtendToLTA on
     it, or write it out through TstMPSignedData, in place of the original.
     A signature this version makes has the sid 80 14 <ski> from the start,
     so a time-stamp added to it later is not affected.

   WHO. Programs that sign with TstMPSignedData and AllowCMSv3 = True;
   programs that verify SignedData, or decrypt EnvelopedData, made by other
   software that names signers or recipients by key; time-stamp clients
   whose TSA names itself by key; programs that build or read these
   identifiers with the DSI classes; and programs that keep
   archive-time-stamped signatures made with AllowCMSv3 by 4.1.4.360 or
   earlier and save them again (the last point above).

   THE DISCRIMINATING TEST: sign with TstMPSignedData, AllowCMSv3 = True,
   and a signer certificate with a subjectKeyIdentifier extension. 4.1.4.361
   raises eASN1Error; 4.1.4.360 writes the sid 00 14 <ski>, which
   "openssl cms -verify" refuses; this one writes 80 14 <ski>, the octets
   "openssl cms -sign -keyid" writes for the same certificate, and
   "openssl cms -verify" accepts the message.

   PLATFORMS. The code is the same on every platform. Measured with the new
   PkixCmsSidWireTest, a battery row on Win32, Win64 and Linux64
   (floor 74): its references are OpenSSL 3.5.7's messages with and
   without -keyid and identifiers written by "openssl asn1parse", its old
   forms were written by the library before this change
   (by OldFormGen, against 4.1.4.360 and against 2c394c0, the library
   just before this change), and it reads what the library writes
   with a DER walk of its own. Before this change (and entry 17) 20 of the 62
   checks it gets to were red on each of the three platforms - the 12 others
   it does not reach, SignData having raised - and now 74 of 74 pass on each.
   Those 20 were measured while the harness made its EC private key itself,
   from the scalar in its PFX file, so entry 8 had no part in them; the
   harness now takes the key from ImportFromPFXFile, which stores it only with
   entry 8, and gives the same 20 with entries 8 to 10 in. Against
   5dd97d1, the library before this change, entry 17 and entries 8 to 10,
   the harness as it now is gives 23 of the 62 red on each platform - the
   20, the check that the key is held, and the two decryptions to it by
   issuerAndSerialNumber (of OpenSSL's message and of the library's). Entry 8
   lists the checks that need it.
   Outside the battery, a script has OpenSSL verify the SignedData and decrypt
   the EnvelopedData the library writes, with and without certificates and
   after writing an old form again: all accepted.

   NOT CHANGED: RecipientIdentifier. The KeyAgreeRecipientInfo that
   TstMPEnvelopedData builds names its recipient by issuerAndSerialNumber
   and itself by originatorKey, as before - AllowCMSv3 does not apply to
   it. CounterSignData names its counter-signer by the same definition, but
   up to 4.1.4.361 it raised before it wrote a sid, for every message
   (entry 6). With entry 6 its countersignature with AllowCMSv3 carries
   80 14 <ski> as well, which CmsCounterSignTest checks with openssl
   asn1parse. stCMS.pas, which no package from StrSecIV170 up contains and
   no shipped unit uses, keeps its definitions, which have the same faults
   (and RecipientIdentifier's as well).


--------------------------------------------------------------------------------
ASN.1: AN OPTIONAL TIME THAT A PROGRAM NEVER SETS
================================================================================


5. BEHAVIOUR CHANGE - an OPTIONAL GeneralizedTime or UTCTime that a program
   never set is left out of the structure it belongs to, where it was
   written holding 00000000000000Z (000000000000Z as a UTCTime), which is
   no time

   The ASN.1 layer writes a field when it is present, and took a value for
   present whenever its text was not empty. A time never set has the text
   00000000000000Z, so every OPTIONAL time a program left alone went out
   holding it - 18 0F 30 .. 30 5A as a GeneralizedTime, 17 0D 30 .. 30 5A
   as a UTCTime - where the structure should have had no such field at
   all. That string is no time: OpenSSL's own generator refuses it ("illegal
   time value"), and this library could not read it back as one (below).
   These are the OPTIONAL time fields of the shipped units, all affected:

   RFC 5652, section 6.2.2 (StreamSec.DSI.CMS):

      RecipientKeyIdentifier ::= SEQUENCE {
        subjectKeyIdentifier SubjectKeyIdentifier,
        date GeneralizedTime OPTIONAL,
        other OtherKeyAttribute OPTIONAL }

   RFC 5652, section 6.2.3 (StreamSec.DSI.CMS):

      KEKIdentifier ::= SEQUENCE {
        keyIdentifier OCTET STRING,
        date GeneralizedTime OPTIONAL,
        other OtherKeyAttribute OPTIONAL }

   RFC 6960, section 4.2.1 (StreamSec.DSI.Ocsp):

      SingleResponse ::= SEQUENCE {
         certID                       CertID,
         certStatus                   CertStatus,
         thisUpdate                   GeneralizedTime,
         nextUpdate         [0]       EXPLICIT GeneralizedTime OPTIONAL,
         singleExtensions   [1]       EXPLICIT Extensions OPTIONAL }

   RFC 5280, section 5.1 (StreamSec.DSI.PkixCRL), two fields of TBSCertList:

           thisUpdate              Time,
           nextUpdate              Time OPTIONAL,

   RFC 3280, section 4.2.1.4 (stPkixExtension):

      PrivateKeyUsagePeriod ::= SEQUENCE {
           notBefore       [0]     GeneralizedTime OPTIONAL,
           notAfter        [1]     GeneralizedTime OPTIONAL }

   THE STEPS THAT FAILED:

   - OCSP. BuildBasicOCSPResponse (StreamSec.DSI.Ocsp) leaves nextUpdate
     out when aNextUpdate is 0, which RFC 6960 section 4.2.2.1 gives a
     meaning: "If nextUpdate is not set, the responder is indicating that
     newer revocation information is available all the time." The
     response went out with a nextUpdate holding 00000000000000Z instead.
     tSingleResponse.hasNextUpdate answered True for it, on the response
     as built and as read back from DER, and nextUpdate then raised
     EConvertError: "Invalid argument to date encode" on Windows, "'0/0/0
     0:0:0.0' is not a valid date and time" on Linux64. By the code,
     TstAbstractOcsp checking such a response reads nextUpdate, because
     hasNextUpdate says there is one, and meets the same exception; that
     was not measured. TstOcspServer always gives a nextUpdate and is not
     affected.

   - CRL. Signing a tCertificateList fills in its signature algorithm,
     issuer and extensions; thisUpdate and nextUpdate are the program's
     to set. A TBSCertList with thisUpdate set and nextUpdate not was
     written with a nextUpdate of 000000000000Z. RFC 5280 section 5.1.2.5
     says "Conforming CRL issuers MUST include the nextUpdate field in all
     CRLs." and goes on "Note that the ASN.1 syntax of TBSCertList
     describes this field as OPTIONAL"; a CRL without one is now written
     without one.

   - CMS. A RecipientKeyIdentifier or a KEKIdentifier built without a date
     was written with one. Entry 4 says the same of the date of an rKeyId,
     which is a RecipientKeyIdentifier.

   - PrivateKeyUsagePeriod. With one bound set, the other went out holding
     00000000000000Z.

   - A structure read from DER, made writable and marked modified to be
     written again wrote an OPTIONAL time that the DER did not have as
     18 00, a GeneralizedTime with no contents.

   NOW a UTCTime or GeneralizedTime field (tASN1CustomDateTime in
   stASN1Types, and the classes derived from it) is present when it holds
   a time. Without one, an OPTIONAL field is left out, and any other keeps
   the presence its structure gives it. tSingleResponse.hasNextUpdate is
   False for a response built without a nextUpdate.

   WHO. Programs that encode one of the structures above without setting
   its time, and programs that call BuildBasicOCSPResponse with
   aNextUpdate 0. A structure read from DER and saved again unchanged
   writes the octets it was read from, as before.

   THE DISCRIMINATING TEST: build a KEKIdentifier, set its keyIdentifier to
   the 16 octets A0 .. AF and leave its date alone, and encode it. An
   affected release writes 30 23 04 10 A0 .. AF 18 0F 30 .. 30 5A; this one
   writes 30 12 04 10 A0 .. AF, the octets "openssl asn1parse -genconf"
   writes for that KEKIdentifier.

   PLATFORMS. The code is the same on every platform. Asn1OptionalTimeTest
   (battery rows Win32, Win64 and Linux64) builds each structure above
   without its time and with it, and compares the DER with OpenSSL's: an
   affected release fails 12 of its 24 checks on each platform, the same
   12; this one passes all 24 on each.

   NOT CHANGED: a time that is set, or read from DER, is written as before.
   A mandatory time - the thisUpdate of a SingleResponse or of a CRL, a
   revocationTime, a producedAt, a certificate's validity - is written as
   before even when the program never set it, holding 00000000000000Z
   (000000000000Z as a UTCTime), so such a structure is still written
   whole, with a value in it that is no time. A structure read from DER
   reads as before.


--------------------------------------------------------------------------------
CMS: COUNTER-SIGNING A SIGNEDDATA, AND CHECKING A COUNTERSIGNATURE
================================================================================

A countersignature (RFC 5652 section 11.4) is an unsigned attribute of a
SignerInfo whose value is a SignerInfo of its own: a second party's signature
over the first one's signature value, added afterwards - to witness or to time
a signature someone else made. TstMPSignedData.CounterSignData adds one, by the
certificate you give it, to every SignerInfo of a SignedData; VerifySignedData
checks each one it finds and reports it through OnGoodCounterSignature, or
through OnBadSignature with the counter-signer's certificate. RFC 5652 section
11.4 gives countersignature values "the same meaning as SignerInfo values for
ordinary signatures", except that their message digest is taken over the
signature value they countersign and that their signed attributes carry no
content type.


6. FIXED - TstMPSignedData.CounterSignData counter-signed no message at all:
   it raised eASN1Error "Attempt to modify ReadOnly instance of
   tASN1ObjectIdentifier" whatever message and whatever counter-signer it
   was given; and the countersignature it would have written past that point
   was one only this library could check

   CounterSignData reads the message, adds the counter-signer's certificate
   chain to the message's certificates as SignData does for a signer, appends
   a countersignature attribute to each SignerInfo, and writes the message
   out again.

   THE STEP THAT FAILED is the appending. Reading a message leaves every part
   of it read-only, and a part added to it later is read-only as well,
   because it takes that from the part it is added to. So the new attribute
   refused the first thing written into it, its type - an object identifier,
   hence the class named in the message. That happened before the
   counter-signer's key was asked for: the key, the certificate, how they
   were loaded (a PFX, a key file), the hash, and who made the message -
   "openssl cms -sign", or SignData in the same program - had no part in it.
   Measured with 4.1.4.360 and 4.1.4.361; by the code, every release since
   4.0 beta 0.291a, which brought TstMPSignedData to StreamSec.DSI.PkixCms
   (the earlier TstMPSignedData of 4.0 betas 0.276 to 0.279, in
   stPkixCms.pas, was not examined).

   One thing CounterSignData did before it raised stayed done: it set the
   component's DetachedSignature to True. The next SignData on the same
   component then wrote a SignedData without its content ("openssl cms
   -verify": "no content").

   PAST THAT STEP - measured with the parts it writes into made writable and
   nothing else changed, against OpenSSL 3.5.7 - CounterSignData raised
   again, eASN1NotSupported "Must specify a tASN1DataCoder", measuring the
   attribute it had built. With that out of the way too, the
   countersignature it wrote
   - named the counter-signer by an issuer and serial number whose issuer
     was empty (the octets 30 00), so it named no certificate;
   - carried a content-type attribute, which RFC 5652 section 11.4 rules
     out: "The signedAttributes field MUST NOT contain a content-type
     attribute; there is no content type for countersignatures.";
   - by an RSA counter-signer, padded the bare SHA-256 digest with no
     DigestInfo around it, which is not the PKCS #1 v1.5 signature that
     rsaEncryption names (RFC 3370 section 3.2, RFC 8017 section 8.2):
     "openssl dgst -verify" answered "Verification failure";
   - by an ECDSA counter-signer, was not made: CounterSignData returned
     False.
   VerifySignedData in the same releases checked only that RSA form; see
   entry 7.

   NOW CounterSignData makes writable just the two parts it writes into -
   the certificates and each SignerInfo's unsignedAttrs - and leaves the
   rest of the message as it was read: the signer's SignerInfo comes out
   with the same octets, up to and including its signature value. It names
   and signs the counter-signer as SignData names and signs a signer, by the
   same code: by the issuer and serial number of the counter-signer's
   certificate (version 1), or, with AllowCMSv3 and a certificate that has a
   subjectKeyIdentifier extension, by that extension's value with the [0]
   tag of entry 4 (version 3);
   RSA as PKCS #1 v1.5 with the DigestInfo and rsaEncryption, or RSA-PSS
   where SignData would use it; ECDSA as ecdsa-with-SHA256 (or the
   ecdsa-with-SHA2 identifier of the hash in use) with a DER ECDSA-Sig-Value,
   as RFC 5753 section 2.1.1 has it. Its signed attributes are the message
   digest of RFC 5652 section 11.4, the signing time unless
   IncludeSigningTime is False, and SigningDescription when it is set.
   DetachedSignature is left as it was found.

   A counter-signer's certificate without the subjectKeyIdentifier extension
   is named by issuer and serial number even with AllowCMSv3, as SignData
   names a signer: by RFC 5652 section 5.3 the key identifier "matches the
   X.509 subjectKeyIdentifier extension value". CounterSignData took a key
   identifier computed from the public key for such a certificate; it never
   got as far as writing one.

   THE DISCRIMINATING TEST: counter-sign any SignedData. An affected release
   raises eASN1Error "Attempt to modify ReadOnly instance of
   tASN1ObjectIdentifier" from CounterSignData; this one writes the message,
   "openssl cms -verify" still accepts the signer's signature in it, and
   VerifySignedData reports the countersignature through
   OnGoodCounterSignature.

   NOT CHANGED: what SignData writes - CounterSignData now signs by the code
   SignData signs by, which was moved and not changed; the message
   CounterSignData is given, apart from the countersignature attributes and
   the counter-signer's certificates added to it.

   PLATFORMS. CmsCounterSignTest (battery rows Win32, Win64 and Linux64;
   openssl on PATH) counter-signs a SignedData "openssl cms -sign" made and
   one SignData made, by an RSA-2048 counter-signer, by an ECDSA P-256 one,
   by the RSA one with AllowCMSv3, and by the RSA one with IncludeSigningTime
   True, the default (the other cases set it False, so that what they write
   is the same on every run). It asks OpenSSL (3.5.7 on Windows, 3.5.5 on
   Linux) whether the signer's signature still holds, where the
   countersignature is, whether it verifies with the counter-signer's public
   key - and that it does not with one octet of it changed - and what its
   sid, algorithms, message digest and signing time have to be; and it
   checks the component's next SignData. Against 4.1.4.361, 97 of its 104
   checks fail on all three platforms; against this release all 104 pass.
   That takes entry 8 as well: without it CounterSignData returns False,
   with CertificateNotFound set, for an ECDSA counter-signer whose
   certificate and key were imported from a PFX file, because the key was
   not stored - 19 of the 104 checks. The AllowCMSv3 case passes with
   entry 4, which writes a subjectKeyIdentifier with the tag RFC 5652 gives
   it; without entry 4 its 18 checks fail.


7. FIXED - VerifySignedData raised eASN1NotSupported "Class
   tIssuerAndSerialNumber does not implement ContentAsOctetString" for a
   message whose countersignature names its counter-signer by issuer and
   serial number, and reported every countersignature signed as RFC 5652
   has it through OnBadSignature

   VerifySignedData checks each SignerInfo's signature and, once that holds,
   each countersignature attribute of the SignerInfo: it looks the
   counter-signer's certificate up in KeysAndCerts by the countersignature's
   sid, and checks the countersignature with that certificate's public key.

   THE STEPS THAT FAILED:
   - Looking up the certificate, when the sid is an issuer and serial number
     (a version 1 countersignature). The lookup asked that structure for a
     value it does not have, and the eASN1NotSupported this raised reached
     the caller of VerifySignedData - after OnGoodSignature had reported the
     signer. Measured on a version 1 countersignature; the lookup raises
     before it compares anything, so it raised for every one, including
     every countersignature CounterSignData now writes without AllowCMSv3.
   - Checking the signature. Only an RSA signature over the bare digest,
     with no DigestInfo, was accepted: the form CounterSignData set out to
     write (entry 6), and the form the legacy stMpCms TMPSignedData writes.
     A countersignature signed as RFC 5652 has it - RSA PKCS #1 v1.5 with the
     DigestInfo, RSA-PSS, ECDSA with a DER ECDSA-Sig-Value - was reported
     through OnBadSignature with the counter-signer's certificate, and no
     OnGoodCounterSignature came. Measured, with the lookup corrected, for an
     RSA and an ECDSA countersignature.

   WHO SAW IT: a program that called VerifySignedData on a SignedData another
   program had counter-signed. TstSMIMEBroker checks a signed message through
   VerifySignedData; TstPdfVerifier does too, and calls a signature that
   brought any OnBadSignature "The CMS signature did not verify" (by the
   code; neither was run). VerifySignedData itself returned True when only a
   countersignature failed, and still does: it reports countersignatures
   through the events alone.

   NOW the certificate is looked up by the DER of the issuer and serial
   number, as the signer's is, and the countersignature is checked by the
   code that checks the signer's signature - RFC 5652 section 11.4 gives it
   "the same meaning". An RSA countersignature in the bare-digest form is
   still accepted when the RFC form does not verify, so a message
   counter-signed by stMpCms still checks; this library never writes that
   form.

   THE DISCRIMINATING TEST: check with VerifySignedData a message whose
   countersignature names its counter-signer by issuer and serial number -
   any message CounterSignData now writes without AllowCMSv3. An affected
   release raises eASN1NotSupported; this one reports the countersignature
   through OnGoodCounterSignature.

   NOT CHANGED: how the signer's own signature is checked - the code was
   moved, not changed (entry 28 changes how it reads RSASSA-PSS parameters,
   a signer's and a countersignature's alike); the bare-digest RSA form,
   still accepted; a countersignature whose counter-signer's certificate is
   in neither KeysAndCerts nor the message, which sets CertificateNotFound
   as before.

   PLATFORMS. CmsCounterSignTest (entry 6) has VerifySignedData report every
   countersignature it makes, and the same message with one octet of the
   countersignature changed (OnBadSignature, no OnGoodCounterSignature). It
   also puts, in place of one countersignature value, a bare-digest one that
   OpenSSL made ("openssl pkeyutl -sign" with no digest set), which
   "openssl dgst -verify" refuses and VerifySignedData accepts.


--------------------------------------------------------------------------------
PRIVATE KEYS FROM PFX FILES AND KEY STORES
================================================================================


8. FIXED - an EC or DSA private key that had been decoded from PKCS#8 - the
   key bag of a PFX file, a PKCS#8 key file, a key read back from a key
   store - could not be stored: SetPrivateKey returned False, and
   ImportFromPFXFile stored the certificate but not the key

   A key store writes an EC or DSA private key in one of the PKCS8 DSS
   formats its PrivateKeyFormatDL selects (PKCS8-Plain-DSS,
   PKCS8-Encrypted-DSS and their PEM forms). Each writes a PrivateKeyInfo
   carrying the StreamSec key-usage attribute (1.3.6.1.4.1.13085.4.3),
   which records the key's digest algorithm.

   THE STEP THAT FAILED is that write, for a key that had itself been
   decoded from PKCS#8. Such a key carries the PrivateKeyInfo it was
   decoded from, and the formats wrote that structure, adding the attribute
   to it. A decoded structure is read-only - what was read stays what was
   read - so the call that finds the attribute or adds it returned nil, and
   the next line read through it: an access violation, a read of address
   0, in tPrivateKeyInfo.AssignKeyUsageAttribute. The key store tries each
   of its formats and takes an exception as "this format cannot write the
   key", so none could, and the key was refused with nothing raised:
   TstCustomCertificateManager.SetPrivateKey returned False.
   ImportFromPFXFile then filed the key's certificate as one whose private
   key is not held - under TrustedStoreName, not MyStoreName - and returned
   True (entry 10). GetDSSPrivateKey found no key for the certificate, so
   nothing could sign or decrypt with it.

   NOW a key whose own PrivateKeyInfo is read-only is written from a new
   PrivateKeyInfo built from the key, as a key that was never encoded
   always was: for an EC key, the RFC 5915 ECPrivateKey with the curve and
   the public key, and the key-usage attribute.

   WHO. Programs that store an EC or DSA private key the library decoded:
   ImportFromPFXFile of a PFX file holding one, whoever made the file;
   SetPrivateKey of a key loaded from a PKCS#8 file or from a PKCS#12 key
   bag; and a key read from one key store and stored in another. A key the
   library generated, and has not read back since, was stored before and
   is stored now. RSA keys were not affected: their formats always build a
   new PrivateKeyInfo. Nor were EdDSA keys: no key-usage attribute is
   written for them, and they are written as before, from the structure
   they were decoded from.

   THE DISCRIMINATING TEST: make a P-256 key and certificate with
   "openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256", a PFX
   file of them with "openssl pkcs12 -export", and import it with
   ImportFromPFXFile into a TstCertificateManager whose key store selects
   PKCS8-Plain-DSS. In an affected release GetDSSPrivateKey of the
   certificate returns nil; in this one it returns the key. A key with the
   same scalar made by MustGetDSIEC.NewKeys was stored before and is stored
   now: what decided it was where the key came from, not the key.

   PLATFORMS. The code is the same on every platform. Measured with the new
   PfxImportTest against PFX files OpenSSL 3.5.7 made - P-256 with the key
   in a shrouded and in a plain key bag, and DSA - and with a P-256 key read
   back from a key store and stored in another. Before, 14 of its checks
   failed on Win32, Win64 and Linux64: for each P-256 file the key was not
   found, and the signature and the decryption that need it failed; the DSA
   key was not found; and the key read back was not stored. Now all pass. A
   SignedData made with the imported P-256 key verifies, and an EnvelopedData
   to its certificate decrypts, with openssl cms. Each of the four
   formats, plain, PEM, encrypted and encrypted PEM, faulted on the P-256
   and the DSA key from those files and writes them now; an Ed25519 key
   from an OpenSSL PFX file is written the same before and after (Win32).
   PkixCmsSidWireTest (entry 4) takes the private key of its EC PFX file from
   ImportFromPFXFile and so needs this entry too. Without entries 8 to 10,
   7 of its 74 checks fail on Win32, Win64 and Linux64: the key manager
   does not hold that EC key, and the six KeyAgreeRecipientInfo decryptions to
   it fail. Without this entry alone, ImportFromPFXFile returns False for
   that file (entry 10) and the harness stops before its first check.

   NOT INVOLVED: the PFX file, its password and its encryption - the key
   came out of it correctly, before as now; which of the PKCS8 DSS formats
   a key store selects - each of them refused such a key.

   NOT CHANGED:
   - A PFX file whose DSA certificate is signed with id-dsa-with-sha256, as
     OpenSSL 3 signs one by default, still makes ImportFromPFXFile raise
     eASN1Error "Unidentified type for tSignatureAlgorithmID": the library
     reads no DSA signature with SHA-2, and the import stops there, before
     it reaches the key.
   - tPrivateKeyInfo.AssignKeyUsageAttribute still faults when it is called
     on a read-only PrivateKeyInfo; the key formats no longer call it on
     one.
   - The legacy unit stPkcs8Format, which no longer ships, is not changed.


9. FIXED - ImportFromPFXFile stored only the first private key of a PFX file
   holding more than one: once a key had been stored, it offered no later key
   in the file to the key store

   THE STEP THAT FAILED is the loop over the file's key bags, which kept
   its result as Result := Result or <store the key>. The library is
   compiled with short-circuit evaluation ({$BOOLEVAL OFF} in ver.inc), so
   once a key had been stored and the result was True, the store was not
   called for any later key. Each later key's certificate was then filed
   as one whose private key is not held, and ImportFromPFXFile returned
   True.

   NOW every key in the file is offered to the key store, whatever became
   of the ones before it.

   WHO. Programs that import PFX files holding more than one private key.
   A file with one key - what "openssl pkcs12 -export" and ExportToPFXFile
   write - was not affected.

   THE DISCRIMINATING TEST: import a PFX file holding two keys and their
   certificates, and ask GetRSAPrivateKey (GetDSSPrivateKey for an EC or
   DSA key) for the second certificate. An affected release answers nil,
   this one the key.

   PLATFORMS. PfxImportTest imports two RSA-2048 keys and their
   certificates in one file: two PFX files from OpenSSL joined, the MAC
   computed again, and OpenSSL verifies the MAC and finds both keys.
   Before, the second key and the count of what was stored failed on
   Win32, Win64 and Linux64 (2 checks); now both pass.

   NOT INVOLVED: the file, its password and its encryption - each later key
   was decrypted, and then not stored.


10. BEHAVIOUR CHANGE - ImportFromPFXFile returns False when a private key in
    the file was not stored. It returned True as soon as anything was stored,
    so a file whose key was refused reported success on the strength of its
    certificate

   ImportFromPFXFile files the private keys of a PFX file under
   MyStoreName, and then its certificates: one whose private key is held
   under MyStoreName, a CA certificate under RootStoreName, any other under
   TrustedStoreName.

   THE STEP THAT FAILED is the result. It was True when any key or any
   certificate was stored, so a key that was not - its bag did not
   decrypt, or no key store or key format took it (entry 8) - went
   unreported when a certificate was stored: the caller was told the file
   was imported, and learnt otherwise only when it asked for the key.

   NOW ImportFromPFXFile returns False when a private key in the file was
   not stored, and True when every key was stored, or was there already,
   and something was stored. The certificates are filed in either case, as
   before: with its key not stored, a certificate is filed as one whose
   private key is not held. Nothing is taken out of the stores again.

   BEHAVIOUR CHANGE: a PFX file whose private key is not stored makes
   ImportFromPFXFile return False where it returned True. Most often that
   is a key store with no format selected for that kind of key - an EC key
   and nothing selected in PrivateKeyFormatDL - or a key bag under another
   password than the file's. The certificates are stored as they were.

   WHO. Programs that test ImportFromPFXFile's result and import a file
   whose key is not stored. A program that ignores the result sees no
   change.

   THE DISCRIMINATING TEST: import a P-256 PFX file from "openssl pkcs12
   -export" into a TstCertificateManager whose key store selects no PKCS8
   DSS format. An affected release returns True, this one False; with
   both, the store holds the certificate and GetDSSPrivateKey of it returns
   nil.

   PLATFORMS. PfxImportTest does exactly that, and imports a file whose
   certificate is under the file's password and whose key is under another
   (two OpenSSL PFX files joined; OpenSSL verifies the MAC and reads the
   certificate but not the key). Before, "returns False" failed for both
   on Win32, Win64 and Linux64; now it passes. With both releases nothing
   is raised and the certificate is filed.

   NOT CHANGED: a file that does not open under the password - its MAC does
   not verify, or its contents do not decrypt - returns False, as before.


--------------------------------------------------------------------------------
RSA: SIGNATURES AND CIPHERTEXTS AS LONG AS THE MODULUS, AND SIGNING WITH A KEY
OF ANY LENGTH
================================================================================

RFC 8017 makes an RSA signature, and an RSA ciphertext, exactly as long as the
modulus: k octets, k being the modulus's length in octets. Both entries below
are about the RSA private keys this library computes with itself - loaded from
a key file, a PFX or a key store, or generated - and about RSA encryption to
any public key.


11. FIXED - an RSA signature or ciphertext whose first octet is zero was
    written one octet short, and OpenSSL refused such a signature: about one
    RSA-2048 signature in 256, and nearly every one with a 2049-bit key

    StreamSec.DSI.IFC. RFC 8017 sections 8.1.1 (RSASSA-PSS) and 8.2.1
    (RSASSA-PKCS1-v1_5), step 2c:

        "Convert the signature representative s to a signature S of
        length k octets (see Section 4.1):

           S = I2OSP (s, k)."

    and sections 7.1.1 (RSAES-OAEP) and 7.2.1 (RSAES-PKCS1-v1_5), step 3c,
    the same of a ciphertext: C = I2OSP (c, k). A value whose first octet is
    zero is still k octets long, and starts with 00. Verifying starts by
    checking that, section 8.2.2 step 1: "Length checking: If the length of
    the signature S is not k octets, output "invalid signature" and stop."

    THE STEP THAT FAILED is the last one of signing and of encrypting:
    writing the number out as octets. tDSIIF.SSASignatureGeneration and
    tDSIIF.Encryption wrote it in as few octets as it takes, so a signature
    or ciphertext whose first octet would have been 00 came out k - 1 octets
    long (and k - 2 when two would have been, about once in 65536). The
    number itself was right - "openssl pkeyutl -verifyrecover" recovers the
    right encoded message from such a signature - and neither the key, how
    it was loaded, the hash, the padding scheme nor the data had a part in
    it. How often it happened depends on the modulus alone: the value is
    spread evenly below the modulus N, so its first octet is zero with
    probability 256^(k-1)/N - between 1 in 256 and 1 in 128 for a key of
    1024, 2048, 3072 or 4096 bits, by the modulus's first octet, and nearly
    always for a modulus one or a few bits longer than a whole number of
    octets, such as 2049 bits. Of RsaI2ospTest's 1000 SHA-256 signatures
    with an OpenSSL RSA-2048 key, 10 were short. Every release since
    StreamSec.DSI.IFC came, in 4.0 beta 0.287.

    WHO SAW IT. Measured with OpenSSL 3.5.7: "openssl dgst -verify" and
    "openssl cms -verify" refuse a short PKCS #1 v1.5 signature ("rsa
    routines:ossl_rsa_verify:wrong signature length"), and so does OpenSSL
    for the TLS 1.0/1.1 form (PKCS #1 v1.5 over MD5 and SHA-1, no
    DigestInfo) when it is checked as TLS checks it (digest md5-sha1). The
    same OpenSSL accepts a short RSA-PSS signature and decrypts a short
    OAEP or PKCS #1 v1.5 ciphertext; other implementations were not
    measured. The library's own verification and decryption accept the
    short form (see NOT CHANGED), so a program that signs and verifies with
    this library alone did not see it. By the code, everything below that
    signs or encrypts with RSA went through this step:
    - CMS SignedData: TstMPSignedData.SignData, and what is built on it -
      S/MIME, PDF signatures, CAdES (CounterSignData did not get that far:
      up to 4.1.4.361 it raised before it signed, entry 6);
    - certificates, certification requests (PKCS #10), CRLs and OCSP
      responses signed with RSA or RSA-PSS;
    - SSH: user authentication and host-key signatures, ssh-rsa,
      rsa-sha2-256 and rsa-sha2-512;
    - DKIM signatures; JWS signatures (RS256 and the other RS and PS
      algorithms), and with them ACME requests;
    - TLS 1.3 CertificateVerify, client and server (RSA-PSS);
    - TLS 1.2 client CertificateVerify, see below;
    - CMS EnvelopedData and AuthEnvelopedData to an RSA recipient (the
      encryptedKey of the KeyTransRecipientInfo), PEM messages, and
      TstRSAPublicKey.Encrypt.
    TLS 1.0 to 1.2 lengthened the server's ServerKeyExchange signature and
    the client's encrypted premaster secret to k octets itself, and TLS
    1.0/1.1 the client's CertificateVerify too, so those were not affected.
    TLS 1.2's client CertificateVerify (StreamSec.Mobile.Tls) lengthened the
    signature too, but then wrote its length as k + 2 with k octets
    following, which overruns the message: by the code, about one TLS 1.2
    handshake in 256 with an RSA client certificate failed there.

    An external key (ReprType 3: a PKCS #11 token, CryptoAPI) that signs by
    itself writes its own signature, and that did not change. When the
    library encodes and the store only does the RSA operation, the
    signature was written short the same way.

    NOW a signature and a ciphertext are always k octets, k taken from the
    modulus - for an external key, from its GetKeySize. The TLS 1.2 branch
    is no longer reached; it writes k as the length as well.

    THE DISCRIMINATING TEST: sign a few thousand messages with an RSA-2048
    key and compare each signature's length with the modulus's length in
    octets. An affected release returns some one octet short, about one in
    256; this one returns none. Or sign with a 2049-bit key (with entry 12):
    an affected release returns 256 octets nearly every time, this one 257.

    NOT CHANGED:
    - Verification, which still accepts a signature shorter than k octets,
      as releases before this one wrote them; entry 15 refuses a longer
      one. Decryption, which still reads a ciphertext shorter than k octets.
    - The legacy unit stMPIF, which no longer ships, still writes the short
      form.
    - The RSA operation itself, and every signature and ciphertext that was
      k octets long before: the same octets.

    PLATFORMS. RsaI2ospTest (battery rows Win32, Win64 and Linux64) checks
    87 signatures OpenSSL made - PKCS #1 v1.5 over SHA-1, SHA-256, SHA-384
    and SHA-512 and the TLS 1.0/1.1 form, 10 per key with a short integer -
    octet for octet through four entry points, with OpenSSL keys of 1024,
    2047, 2048, 3072 and 4096 bits and a 2049-bit key; runs of 1000, 256 and
    256 SHA-256 signatures against OpenSSL's; OpenSSL's ciphertexts with a
    leading zero octet; randomised RSA-PSS signatures and OAEP and PKCS #1
    v1.5 encryption; an external key; and certificates and CMS SignedData
    made with the 2049-bit key. Against 4.1.4.361 it failed 46, 43 and 42 of
    its 68 signing and encryption checks on Win32, Win64 and Linux64 (the
    randomised checks fail only in a run that draws a short value); with
    this entry alone, 13 on each platform - the 2049-bit key's signatures,
    which need entry 12.
    And "RsaI2ospTest emit" handed 1000 signatures of each kind, 1000
    ciphertexts of each kind and 63 certificates and CMS messages made with
    the RSA-2048 key to OpenSSL (3.5.7 on Windows, 3.5.5 on Linux): against
    4.1.4.361 OpenSSL refused 4 of the 1000 PKCS #1 v1.5 signatures and 7 of
    the 1000 TLS ones on each of the three platforms, and one certificate
    (Win32, Win64) or one CMS message (Linux64), every time for "wrong
    signature length"; 4 to 9 RSA-PSS signatures and 8 to 18 ciphertexts
    were short as well, which that OpenSSL accepted. With this release
    (and entry 12), the same with the 2049-bit key as well, 10378 items on
    each platform: every one k octets, OpenSSL accepted every one, and some
    5220 of them on each platform start with 00.


12. FIXED - an RSA key whose modulus is 1 to 8 bits longer than a multiple
    of 64 bits - 2049 bits, say - could not sign: eDSInteger "Illegal
    parameter in FixedModInto"

    StreamSec.DSI.IFC. An RSA private key held with its primes (ReprType 1
    or 2, which is every key loaded from a PKCS #1, PKCS #8 or PFX file or a
    key store) signs and decrypts in fixed time by default (gFixedTime).
    Entry 30 of 4.1.3.358 made that path take a modulus of any length and
    named 2049 bits among the lengths that could now sign and decrypt. They
    could decrypt; some could not sign.

    THE STEP THAT FAILED is the first one of the private-key operation: it
    reduces its input modulo each prime, reading the input at the modulus's
    length in 32-bit words. A ciphertext of k octets is always long enough.
    The encoded message a signature is computed from is built here one
    octet shorter than the modulus - for RSA-PSS only when the modulus is
    one bit longer than a whole number of octets - and numbers are held in
    whole 64-bit limbs, so for some modulus lengths it was held in one word
    fewer than the operation reads, and FixedModInto refused it before
    computing anything. The lengths, measured by handing that step an input
    built as each scheme builds it, for every modulus length from 512 to
    4200 bits on Win32 and Win64, and by signing with a 2049-bit key on all
    three platforms:
    - PKCS #1 v1.5 and TLS 1.0/1.1 signatures: lengths 1 to 8 bits over a
      multiple of 64 - 1025 to 1032, 2049 to 2056, 3073 to 3080, 4097 to
      4104 bits, and so on;
    - RSA-PSS signatures: lengths 1 bit over a multiple of 64 - 1025, 2049,
      3073, 4097 bits, and so on.
    Keys of 1024, 1536, 2048, 3072 and 4096 bits were never affected, nor
    any key with gFixedTime set to False or held without its primes
    (ReprType 0). The key, how it was loaded and the hash had no part in it.

    Decrypting a ciphertext one octet short with such a key - as releases
    before entry 11 wrote about one ciphertext in 256, and nearly every one
    for a 2049-bit key - raised the same way; it decrypts now (measured on
    Win32 with OpenSSL's OAEP and PKCS #1 v1.5 ciphertexts for the 2049-bit
    key, their leading zero octet removed).

    NOW an input held in fewer words than the operation reads is widened
    into a local copy first, as the operation already did with the other
    operands it reads at a fixed width. NO NEW TIMING DEPENDENCE: how many
    words an input is held in follows from the modulus's length and the
    padding scheme, never from the value, so a key takes the same branch on
    every signature with one scheme.

    THE DISCRIMINATING TEST: sign with a 2049-bit RSA key loaded from a file
    (openssl genpkey -pkeyopt rsa_keygen_bits:2049 makes one). An affected
    release raises eDSInteger "Illegal parameter in FixedModInto"; this one
    returns a 257-octet signature (with entry 11).

    NOT CHANGED: every key length outside the ranges above, which takes the
    same steps on the same operand sizes as before.

    PLATFORMS. RsaI2ospTest (entry 11) signs with the 2049-bit key through
    every entry point, in certificates and in CMS SignedData: with entry 11
    alone, 13 of its 68 signing and encryption checks fail on Win32, Win64
    and Linux64, every one on that key's eDSInteger; with this entry too,
    none.


--------------------------------------------------------------------------------
CMS: THE CURVE OF THE SENDER'S EPHEMERAL KEY IN A KeyAgreeRecipientInfo
================================================================================


13. FIXED - TstMPEnvelopedData did not decrypt a KeyAgreeRecipientInfo whose
    originatorKey names no curve - every one OpenSSL writes to an EC
    certificate - and Decrypt returned False; with the curve given as NULL
    the message did not even load; and a message naming another curve than
    the recipient's could make Decrypt raise eDSInteger

   RFC 5753, section 3.1.1, on the originatorKey of a KeyAgreeRecipientInfo
   for ephemeral-static ECDH:

      "The parameters associated with id-ecPublicKey MUST be absent,
      ECParameters, or NULL.  The parameters associated with id-ecPublicKey
      SHOULD be absent or ECParameters, and NULL is allowed to support
      legacy implementations.  The previous version of this document
      required NULL to be present.  If the parameters are ECParameters,
      then they MUST be namedCurve."

   The sender makes its ephemeral key on the curve of the recipient's key,
   so parameters left out, or NULL, mean that curve. "openssl cms -encrypt"
   leaves them out: its originatorKey algorithm is SEQUENCE {
   id-ecPublicKey } and nothing more. This library writes the namedCurve.

   THE STEPS THAT FAILED:

   - Reading the curve. TstMPEnvelopedData.Decrypt took the curve of the
     ephemeral key from the namedCurve in those parameters and nowhere
     else. With the parameters left out it found no curve and returned
     False - for every KeyAgreeRecipientInfo OpenSSL writes, on every
     curve. The key, the certificate, the key store and the rid were not
     involved: the same message with namedCurve P-256 put into the
     parameters decrypted with the same key.
   - Loading the message. With the parameters NULL, as senders following
     RFC 3278 write them, reading the EnvelopedData itself failed:
     StreamSec.DSI.CMSAlgorithms took only an OBJECT IDENTIFIER there.
     Decrypt returned False before it looked at any recipient.
   - A curve that is not the recipient's. A message naming another curve
     than that of the recipient's key, with a valid point on that curve -
     namedCurve P-384 and a P-384 point, to a P-256 recipient - had the
     point combined with the P-256 private key, and Decrypt raised
     eDSInteger "Overflow in DSIWsCopy" instead of returning False. A named
     curve with a point of another curve's size was refused, as before:
     the point did not decode.

   NOW the curve of the ephemeral key is the curve of the recipient's key,
   taken from the certificate the rid names: the namedCurve of an
   id-ecPublicKey or id-ecDH key, the algorithm of an X25519 or X448 key.
   A namedCurve in the originatorKey must be that curve, an id-ecPublicKey
   originatorKey must go to an EC key, and an id-X25519 or id-X448 one
   (RFC 8418) to a key of the same algorithm. Otherwise, or when the point
   does not decode on that curve, that recipient is passed over, and
   Decrypt returns False when none is left - without combining the point
   with a private key, and without raising. NULL parameters are read.

   WHAT A PROGRAM CAN SEE CHANGE. iOPKParams, the parameters of the
   originatorKey's algorithm, gains AsEcParameters, an iOPKEcParameters:
   CHOICE { namedCurve OBJECT IDENTIFIER, implicitCurve NULL }, its Choice
   oeNamedCurve or oeImplicitCurve. AsNamedCurve still gives the namedCurve
   OBJECT IDENTIFIER, that alternative selected, and the library still
   writes the namedCurve, in the same octets (30 13 06 07 2A 86 48 CE 3D 02
   01 06 08 2A 86 48 CE 3D 03 01 07 for P-256). But the object behind the
   parameters is now that CHOICE, not the OBJECT IDENTIFIER itself, and in
   a decoded message AsNamedCurve of NULL parameters raises eASN1Error
   "Attempt to modify ReadOnly instance", as selecting another alternative
   of a read-only CHOICE does. A program learns which it holds from
   AsEcParameters.Choice, once GetStruct.Present of the parameters has said
   they are there - and, in a message read with fmtDER, once
   AsEcParameters.GetStruct.Data has read the value, as with the other
   CHOICE types of StreamSec.DSI.CMS.

   THE INTERFACE CHANGED, SO ITS GUID DID. iOPKParams is now
   {402F916C-928F-4F7F-A810-CB807E342859}. Code that names the interface -
   a declaration, Supports(X, iOPKParams, Y), an as-cast - recompiles
   unchanged and uses the new GUID. Code that wrote the old GUID out as a
   literal must use the new one.

   WHO. Programs that decrypt with TstMPEnvelopedData what OpenSSL, or other
   software that leaves the parameters out or writes NULL, encrypted to an
   EC certificate. Every release with KeyAgreeRecipientInfo, from 4.1.0.348
   on, is affected. Messages the library writes name the curve; they
   decrypted before and decrypt now.

   THE DISCRIMINATING TEST: encrypt a file with "openssl cms -encrypt
   -binary -recip <a P-256 certificate> -outform DER" and give the result
   to TstMPEnvelopedData.Decrypt with that certificate and its key in
   KeysAndCerts. An affected release returns False; this one gives back
   the file. If "openssl cms -cmsout -print -inform DER" shows the message's
   originatorKey algorithm with a parameter that names the curve of the
   recipient's key, and the message still does not decrypt, it is not this
   defect.

   Measured with the new PkixCmsKariCurveTest, a battery row on Win32, Win64
   and Linux64 (floor 38). Its references are OpenSSL 3.5.7's messages to a
   P-256, a P-384 and a P-521 recipient, and copies of the P-256 one with the
   originatorKey changed: NULL and namedCurve P-256, which OpenSSL decrypts;
   namedCurve P-384 with the P-256 point, namedCurve P-384 with a P-384 point,
   a P-384 point with no parameters, and id-X25519, which OpenSSL refuses
   (all made and checked by a script). It reads each one's originatorKey
   with a DER walk of its own before decrypting it, and also decrypts the
   library's own P-256 message, with and without its parameters, and an
   X25519 one. Before this change 6 of its 38 checks failed on each of the
   three platforms - OpenSSL's three messages, the NULL copy and the
   library's message without its parameters returned False, and the valid
   P-384 point raised - and now 38 of 38 pass. Outside the battery,
   a script has OpenSSL decrypt the library's P-256 message, with and without
   its parameters: both accepted.

   PLATFORMS. Every platform; the code is the same on each.

   NOT INVOLVED: encrypting, which writes the namedCurve as before; the key
   derivation, the key wrap and the content cipher; how the rid finds the
   certificate.

   NOT CHANGED:

   - X25519 and X448. Their curve is the originatorKey's algorithm (RFC
     8418), as before; it is now also checked against the recipient's key.
     OpenSSL 3.5.7 writes no KeyAgreeRecipientInfo for either ("operation
     not supported for this keytype"), so they are measured with the
     library's own messages only.
   - ECParameters other than namedCurve, which RFC 5753 does not allow
     here, are refused, as before.
   - An id-ecDH recipient certificate (RFC 5480) is read by the code path
     of id-ecPublicKey; no such certificate is among the references, so
     that is not measured.


--------------------------------------------------------------------------------
ASN.1: A FIELD WHOSE TYPE ANOTHER FIELD NAMES, READ BEFORE THAT FIELD
================================================================================

Several ASN.1 structures hold a field whose type is named by another field
beside it: an AlgorithmIdentifier's parameters by its algorithm, a
ContentInfo's content by its contentType, an attribute's values by its type.
This library resolves such a field through an information object (stASN1Base),
which looks its type up from the identifier.


14. FIXED - reading the parameters of an AlgorithmIdentifier decoded with
    fmtDER before reading its algorithm raised an access violation

   fmtDER decodes on demand: loading a structure finds where each of its
   fields is, and a field is created when it is first read. The information
   object learned the identifier when the identifier field was created, and
   not before.

   THE STEP THAT FAILED is resolving the type of the parameters. Read first -
   parameters.Choice, an As... accessor, parameters.GetStruct.Data - they
   found no identifier, so their type could not be resolved, and the
   "Unidentified type" eASN1Error that says so read the identifier out of the
   field that did not exist yet: an access violation, read of address 0.
   Measured on Win32, Win64 and Linux64.

   IT IS NOT PARTICULAR TO ONE STRUCTURE. Measured on the content-encryption
   algorithm of an AuthEnvelopedData (AES-GCM) and of an EnvelopedData
   (AES-CBC), and on a certificate's signatureAlgorithm, each resolved by an
   information object of its own. What kept it out of sight: fmtBER creates
   every field at load, in order; reading the algorithm first creates the
   identifier first, and that is what TstMPEnvelopedData does, so the
   component was not affected; and ContentInfo.content and the attribute
   values read their identifier first inside their own accessors.

   A structure built in code whose parameters are read before any algorithm
   is assigned reached the same error, and raised the same access violation.
   There the type really is not known.

   Under fmtDER, creating a field of an information object now first creates
   the fields of the same information object that come before it in the
   structure, so they reach the information object in the order fmtBER gives
   them, and the parameters resolve whichever is read first. The
   "Unidentified type" error no longer reads an identifier field that does not
   exist: the structure built in code gets that eASN1Error, with "Identifier
   value: (none)".

   THE DISCRIMINATING TEST: load an AlgorithmIdentifier - id-aes256-GCM with
   GCMParameters, say - with fmtDER, and read parameters.Choice before
   algorithm. An affected release raises EAccessViolation; this one returns
   eaAes256Gcm, and algorithm read afterwards is id-aes256-GCM
   (Asn1ReadOrderTest, on Win32, Win64 and Linux64).

   NOT CHANGED: what a structure that decoded before decodes to - the same
   alternatives, values and identifiers, with either coder; fmtBER, which
   already created the fields in order; a structure built in code whose
   algorithm is assigned first; and the subjectPublicKey of a
   SubjectPublicKeyInfo decoded with fmtDER and read before its algorithm,
   which raises eASN1Error "Key type is not yet resolved" as before - its
   identifier is inside the nested AlgorithmIdentifier, and that information
   object reports it itself.


--------------------------------------------------------------------------------
RSA SIGNATURE VERIFICATION: A SIGNATURE LONGER THAN THE MODULUS
================================================================================


15. BEHAVIOUR CHANGE - RSA signature verification refuses a signature longer
    than the modulus

    StreamSec.DSI.IFC. RFC 8017 sections 8.1.2 (RSASSA-PSS) and 8.2.2
    (RSASSA-PKCS1-v1_5), step 1:

        "Length checking: If the length of the signature S is not k
        octets, output "invalid signature" and stop."

    tDSIIF.SSASignatureVerification, which every RSA and RSA-PSS signature
    check in the library goes through, read a signature of any length as a
    number. One with zero octets put in front of it - k + 1 octets, k + 2,
    and so on - verified as the signature itself did, so every RSA signature
    this library checked had any number of other encodings that it accepted
    too: a certificate, a CRL, an OCSP response or a CMS message could be
    given other octets, and so another hash, and still verify here. OpenSSL
    refuses them.

    NOW a signature longer than k octets is refused before any arithmetic,
    as one whose number is not below the modulus already was. A signature
    SHORTER than k octets is still read: releases before entry 11 wrote one
    whose first octet is zero without that octet, about one in 256, and the
    certificates, CRLs, CMS messages and other signatures made that way go
    on verifying here. (RFC 8017 refuses those too, and OpenSSL refuses the
    PKCS #1 v1.5 ones; see entry 11.)

    WHO IS AFFECTED: a program that checks a signature written with extra
    leading zero octets. No signer that follows RFC 8017 writes one, this
    library never did, and OpenSSL refuses them. Inside the library every
    caller hands over the signature as it was received - an X.509
    signatureValue without the BIT STRING's unused-bits octet, a CMS
    signature, an SSH signature blob, a TLS signature, a DKIM or PEM
    signature - so nothing the library checks itself changes.

    THE DISCRIMINATING TEST: verify a valid RSA signature with one zero octet
    put in front of it. An affected release accepts it; this one refuses it.

    NOT CHANGED: a signature of k octets, or shorter; the TLS layer's own
    length checks, made first - a server's ServerKeyExchange signature must
    be exactly k octets and a client's CertificateVerify at most k, as
    before; decryption, which still reads a ciphertext shorter than k octets
    (and one longer, whose extra first octets are zero).

    PLATFORMS. RsaI2ospTest (entry 11) verifies, per key, OpenSSL's
    signatures as they are, the short ones with their zero octets removed,
    and every one with a zero octet put in front. Before this entry the last
    were accepted: 6 of its 12 verification checks failed on Win32, Win64
    and Linux64; now none.


--------------------------------------------------------------------------------
RC2 KEY WRAP (RFC 3217)
================================================================================


16. NEW, DEPRECATED on arrival - RFC 3217 RC2 key wrap (tARC2_KeyWrap,
    stArc2.pas) now wraps and unwraps a key. Earlier releases carried only a
    non-functional stub.

   It is provided for completeness of the RFC 3217 / CMS cipher set only. No
   one has asked for it and nothing should adopt it: RC2 is obsolete and RC2
   key wrap is deprecated the moment it works - use a modern standard key wrap
   such as AES key wrap (RFC 3394) instead. Both directions now round-trip,
   checked against the RFC 3217 section 4.4 RC2 example.


--------------------------------------------------------------------------------
ASN.1, fmtBER: AN ABSENT OPTIONAL FIELD THAT HAS NO TAG OF ITS OWN
================================================================================


17. FIXED - reading with fmtBER, a field with no tag of its own - a CHOICE,
    or an ANY - that is OPTIONAL and absent left the reading past the next
    element's header, so the fields after it were read from the wrong place

   THE STEP THAT FAILED is tBERCoder.ReadHeader (stBERCoder). A field with
   no tag of its own is matched by reading the next header from the stream
   and asking the field's class whether it takes that tag. When the class
   took it, the stream went back to where the header starts; when it did
   not, the stream stayed after the header, and the next field was matched
   against what follows it - the contents of the element, not the element.
   The same held for a CHOICE alternative of that kind that is not taken,
   when an alternative after it is tried. fmtDER reads by offset into a
   buffer and was not affected.

   NOW the stream goes back to the start of the header either way.

   WHO. Programs that read with fmtBER - TstMPSignedData and
   TstMPEnvelopedData do, for every message - a structure that has such a
   field, absent, before other fields. The rKeyId of entry 4, read in the
   form earlier versions wrote, is one: its issuerAndSerialNumber reading
   has an optional Name first. In the library's own definitions the same
   shape is also in TBSCertList (an optional nextUpdate before
   revokedCertificates; StreamSec.DSI.PkixCRL) and AdmissionSyntax (an
   optional admissionAuthority first; stPkixAdmissions); those two were
   found by reading the definitions, not measured.

   THE DISCRIMINATING TEST: load, with fmtBER, an EnvelopedData whose
   KeyAgreeRecipientInfo rid is an rKeyId of the old form and read the rid.
   With entry 4 and not this one it raises eASN1DataError ("a SEQUENCE that is
   neither ..."), and TstMPEnvelopedData.Decrypt returns False; with both,
   the rid is kaRKeyId with the recipient's subject key identifier, and
   Decrypt gives back the content.

   PLATFORMS. The code is the same on every platform. PkixCmsSidWireTest
   (entry 4) has three checks that need this: red on Win32 with entry 4 and
   without this one, green with both; the rows run on Win32, Win64 and
   Linux64.

   NOT CHANGED: fmtDER; a field that has a tag of its own, which was always
   put back when it did not match.


--------------------------------------------------------------------------------
CRLs WITHOUT nextUpdate, AND THE REPLACEMENT FOR A STALE CRL
================================================================================


18. FIXED, BEHAVIOUR CHANGE - A CRL without nextUpdate raised EConvertError
    wherever the library asked whether it was still current: LoadCRL of
    TstKeyFilterCRL refused it, a Directory scan passed it over without a
    word, and TsmX509TrustedCertificates did not use it - under rpSoftFail
    a certificate the CRL lists as revoked was accepted. And TstKeyFilterCRL
    read the times of the replacement OnFetchFreshCRL hands back before
    checking its signature, so a CRL that is not the CA's could make it
    leave a stale CRL, and the certificates that CRL lists, out

   RFC 5280, section 5.1.2.5:

      "Conforming CRL issuers MUST include the nextUpdate field in all
      CRLs.  Note that the ASN.1 syntax of TBSCertList describes this field
      as OPTIONAL, which is consistent with the ASN.1 structure defined in
      [X.509].  The behavior of clients processing CRLs that omit
      nextUpdate is not specified by this profile."

   The library's answer, given in the description of
   TstCustomKeyFilterCRL.IsCRLFresh, is that such a CRL never expires by
   time. The code could not give it.

   THE STEPS THAT FAILED:

   - Reading nextUpdate. tbsCertList.nextUpdate always returns an object -
     the field exists whether or not the CRL carries a time in it - so
     IsCRLFresh's test, Assigned(nextUpdate), was always True, and
     TsmX509TrustedCertificates.CRLUsable made no test at all. Both then
     read nextUpdate.AsDateTime, which for a field holding no time raises
     EConvertError: "Invalid argument to date encode" on Windows, "'0/0/0
     0:0:0.0' is not a valid date and time" on Linux64. The CRL's signature
     had been checked and had passed; its encoding, the CA certificate and
     the key store were not involved.
   - The order of the checks on a replacement. When a CRL being loaded has
     passed its nextUpdate, TstKeyFilterCRL asks OnFetchFreshCRL for a
     replacement - which the handler typically downloads with FetchCRL,
     and FetchCRL checks nothing - and it asked IsCRLFresh about the
     replacement BEFORE checking its signature. A replacement without
     nextUpdate raised EConvertError there, and one whose nextUpdate is no
     date (a month 13, say) raised eASN1DataError "Could not interpret
     contents" - whoever had made it.

   What followed depended on who asked:

   - TstCustomKeyFilterCRL.LoadCRL, under rpSoftFail and rpHardFail, raised
     the exception and left the CRL out: the certificates it lists stayed
     allowed, and HasFreshCRLFor - what TstOcspServer asks before it
     answers "good" - said False for its CA.
   - A Directory scan (enabling the filter, or PopulateKeyList) passed the
     CRL over without a word: its revocations were not loaded, and the
     certificates it lists were allowed. With a replacement that raised, the
     CRL passed over was the stale one being loaded - which rpSoftFail
     promises to load, so that the certificates it lists stay refused.
   - Under rpIgnore LoadCRL took a CRL without nextUpdate, since it asks
     nothing about time then, and HasFreshCRLFor raised EConvertError for
     its CA - and with it TstOcspServer.ProcessRequest for a certificate of
     that CA.
   - TsmX509TrustedCertificates.CheckRevocation, which the TLS layer asks
     about the certificates of a peer's chain, took the exception for an
     inconclusive answer: crcOK under rpSoftFail (the default), so a
     certificate the CRL lists as revoked was accepted; crcRevocationUnknown
     under rpHardFail, for every certificate of that CA. CRLs held after it
     for the same CA were not looked at, and OnFetchCRL was not asked for
     another.

   A CRL built in code whose nextUpdate was never assigned raised the same
   way.

   NOW nextUpdate is asked whether it holds a time - read from DER, when the
   DER carries one; built in code, once one has been assigned - and a CRL
   without one does not go stale by time, in IsCRLFresh and in CRLUsable
   alike. thisUpdate is checked as before, and a nextUpdate that has passed
   is stale as before. The signature of an OnFetchFreshCRL replacement is
   checked first, and a replacement whose signature fails is passed over as
   if none had come back, before anything in it is read. On the CRL page of
   TstCertificateViewer a CRL without nextUpdate reads "Next Update: none",
   where it read "Next Update: 000000000000Z". The description of
   iTBSCertList.nextUpdate now says how a program tells whether the field
   holds a time: GetStruct.Present for a CRL read from DER, GetStruct.Modified
   for one built in code - not Assigned, which is always True.

   WHAT A PROGRAM CAN SEE CHANGE:

   - With a CRL without nextUpdate, LoadCRL and a Directory scan load it,
     and the certificates it lists are refused.
   - HasFreshCRLFor says True for its CA, so a TstOcspServer answers "good"
     for a certificate the CRL does not list, where it answered "unknown",
     and under rpIgnore ProcessRequest no longer raises.
   - TsmX509TrustedCertificates answers crcRevoked for a certificate the
     CRL lists, under either policy, and under rpHardFail crcOK for one it
     does not list, where it answered crcRevocationUnknown.
   - Since such a CRL does not go stale, OnFetchCRL is not asked for a
     newer one while it is held. A newer CRL from the CA reaches
     TsmX509TrustedCertificates through AddCRL, which replaces the one held
     when the new one's CRL number is higher, and TstKeyFilterCRL through
     LoadCRL or Directory.
   - A stale CRL whose OnFetchFreshCRL replacement does not verify is
     treated as having none: under rpSoftFail it is loaded, and under
     rpHardFail LoadCRL raises eKeyManagerError, as with no replacement -
     where a replacement without nextUpdate or with a nextUpdate that is no
     date raised EConvertError or eASN1DataError.

   WHO. Programs that check certificates against CRLs from a CA that leaves
   nextUpdate out, which RFC 5280 does not allow a conforming CA to do; and
   programs that assign TstKeyFilterCRL.OnFetchFreshCRL to a handler that
   downloads. Every release from 4.1.1.349 on is affected. No program in
   this distribution or its demos assigns OnFetchFreshCRL.

   WHO COULD MAKE IT HAPPEN. A CRL without nextUpdate that verifies comes
   only from the CA, and the library reads a CRL's times only after
   checking its signature - except for the replacement OnFetchFreshCRL
   hands back. There, anyone who can answer the program's download of a
   CRL (a CRL distribution point is usually an http URL) could hand back a
   CRL that names the CA, has no nextUpdate or a time that is no date, and
   is signed by anyone. With rpSoftFail (the default), a CRL in Directory
   that had gone stale when the filter was enabled, and that download, the
   Directory scan left the stale CRL out, and a certificate it lists as
   revoked was allowed; LoadCRL of the stale CRL raised to the program
   instead of loading it. Under rpHardFail a stale CRL with no usable
   replacement is refused anyway, so nothing more was lost there. Where a
   CA itself leaves nextUpdate out, the holder of a certificate it revoked
   was accepted by a TsmX509TrustedCertificates under rpSoftFail and by a
   TstKeyFilterCRL that read the CRL from its Directory. This is an
   ordinary fix, not a security update.

   THE DISCRIMINATING TEST: "openssl crl -inform DER -in <file> -noout
   -nextupdate" prints "nextUpdate=NONE" for a CRL without nextUpdate, and
   "nextUpdate=Bad time value" for one whose nextUpdate is no date. LoadCRL
   of a CRL without nextUpdate raises EConvertError "Invalid argument to
   date encode" in an affected release and loads it in this one. For the
   replacement: load a stale CRL under rpSoftFail with an OnFetchFreshCRL
   handler that hands back such a CRL signed by another key; an affected
   release raises, this one loads the stale CRL.

   PLATFORMS. Every platform; the code is the same on each.

   NOT INVOLVED: the CRL's revoked-certificate list, the clock skew
   (CRLClockSkew), FetchCRL itself, and the nextUpdate of an OCSP response
   (StreamSec.DSI.Ocsp), which was already asked whether it was there.

   Measured with the new CrlFreshnessTest, a battery row on Win32,
   Win64 and Linux64 (floor 45). Its references are made by OpenSSL
   3.5.7 (by a script that also has "openssl crl -CAfile" check
   every CRL's signature): a CA, a certificate it issued, three CRLs
   from the CA listing that certificate, thisUpdate 2026-10-01 - without
   nextUpdate, with nextUpdate 2026-10-02, and with nextUpdate 9999-12-31 -
   and two that name the CA, list nothing and are signed with another key,
   one without nextUpdate and one whose nextUpdate is 261301000000Z. It asks
   IsCRLFresh about the CA's CRLs and about CRLs built in code with and
   without nextUpdate; loads them into the TstKeyFilterCRL of a key manager
   with LoadCRL under rpSoftFail, rpHardFail and rpIgnore and with a
   Directory scan, and asks IsKeyAllowed and HasFreshCRLFor; hands the two
   forged ones back from OnFetchFreshCRL for the stale one, by LoadCRL and
   by a Directory scan; and asks a TsmX509TrustedCertificates holding each
   CRL CRLUsable and CheckRevocation under rpSoftFail and rpHardFail.
   Before this change 21 of its 45 checks failed, the same 21 on each of
   the three platforms; now 45 of 45 pass. With the test of nextUpdate
   alone, the 3 checks of the replacement whose nextUpdate is no date still
   fail. TstCertificateViewer is not in the harness: it is compiled by the
   package build and was not run.


--------------------------------------------------------------------------------
TLS 1.0-1.2 SERVER: STATIC RSA KEY EXCHANGE WITHOUT A PADDING ORACLE
================================================================================

In a static RSA key exchange - the TLS_RSA_WITH_* suites of TLS 1.0 to 1.2 -
the client encrypts the premaster secret to the RSA key of the server's
certificate, and the server decrypts it. The two entries below are about what
happens when that decryption does not give what it should. Neither touches the
TLS client, TLS 1.3, or any key exchange but static RSA.


19. FIXED - a TLS 1.0-1.2 server doing static RSA key exchange answered a
    ClientKeyExchange that did not decrypt to a correct premaster secret
    with an immediate illegal_parameter alert, or an exception, so that
    any client could learn whether a ciphertext of its choosing decrypted
    to a PKCS #1 v1.5 block: a Bleichenbacher padding oracle

    StreamSec.Mobile.Tls, StreamSec.Mobile.TlsLayer. RFC 5246 section
    7.4.7.1:

        "In any case, a TLS server MUST NOT generate an alert if processing
        an RSA-encrypted premaster secret message fails, or the version
        number is not as expected.  Instead, it MUST continue the handshake
        with a randomly generated premaster secret."

    THE STEP THAT FAILED is the server reading the client's
    ClientKeyExchange: TLS_DecodeClientKeyExchange, with the server's RSA
    key. It decrypted the EncryptedPreMasterSecret and returned False
    unless the plaintext was a PKCS #1 v1.5 block of exactly 48 octets
    beginning with ClientHello.client_version, and the handshake then sent
    a fatal illegal_parameter alert at once. A ciphertext that did decrypt
    to such a block got no answer until Finished. A block of 00 02 with no
    zero octet after it raised ERangeError instead (entry 20), and a
    ciphertext not below the modulus raised EAssertionFailed; both left the
    connection open, and in TsmAsyncTLSServer an exception closes the
    connection without an alert. So the server answered in three different
    ways, each telling the sender something about the plaintext of a
    ciphertext the sender chose. The random premaster secret the RFC asks
    for was drawn, and then used only where the alert had already been
    decided.

    That is the oracle of Bleichenbacher, "Chosen Ciphertext Attacks
    against Protocols Based on RSA Encryption Standard PKCS #1" (CRYPTO'98,
    LNCS vol. 1462), and of Klima, Pokorny and Rosa, "Attacking RSA-based
    Sessions in SSL/TLS" (2003), both cited by RFC 5246 for this rule:
    enough such answers decrypt any ciphertext made with the key, or sign
    with it. Boeck, Somorovsky and Young, "Return Of Bleichenbacher's Oracle
    Threat (ROBOT)" (USENIX Security 2018), found it in many TLS servers.

    NOW the server takes every ClientKeyExchange whose length fields agree,
    and builds the premaster secret the way RFC 5246 recommends (the first
    of its two constructions): ClientHello.client_version followed by the
    last 46 octets of the plaintext when the plaintext is a 48-octet PKCS #1
    v1.5 block, and ClientHello.client_version followed by 46 random octets
    otherwise. A client that sent anything else, the wrong version
    included, fails at Finished, with the bad_record_mac any client gets
    that holds the wrong keys. The block is checked without branching on
    what it holds: the private-key operation is done raw, every octet of
    the block is read, and a mask chooses between its last 46 octets and
    the random ones; nothing is raised. A ciphertext whose integer is not
    below the modulus gets the random premaster secret before any
    private-key operation. A key in a key store (ReprType 3) that decrypts
    PKCS #1 v1.5 itself, as the CryptoAPI and PKCS #11 stores do, still
    does so, and an exception from the store counts as a failed decryption;
    a store that offers only the raw operation is checked as a key in
    memory is.

    A program that calls TLS_DecodeClientKeyExchange itself with an
    iIFPrivateKey sees the change: it returns False only for a message
    shorter than its own length fields.

    WHO WAS AFFECTED. A TLS server built on this library that negotiated a
    TLS_RSA_WITH_* suite. That takes an RSA certificate whose keyUsage
    includes keyEncipherment, with its private key, and TLSOptions that
    allow static RSA (KeyAgreementRSA) and a bulk cipher it comes with:
    every static RSA suite the library has is CBC, 3DES or RC4.
      - Up to 4.1.1.354 both were on by default: every server with such a
        certificate was affected unless it had turned them off.
      - 4.1.2.355 to 4.1.3.359: KeyAgreementRSA was off by default, but the
        components built on TsmCustomSimpleTLSInternalServer - among them
        TsmAsyncTLSServer and so the HTTPS and REST servers - kept AES-CBC
        on, so turning KeyAgreementRSA on was enough.
      - 4.1.4.360 and 4.1.4.361: both off by default; a server that turned
        both on was affected.
    The code was the same in every release from 4.0.1.313 on; older ones
    were not examined. The TLS client, TLS 1.3, and a server whose
    TLSOptions leave static RSA off were never affected.

    WHAT IT GAVE AWAY. Anyone who could connect to such a server could ask
    it about ciphertexts of their choosing, one connection a question, with
    no account and no position on the network. With enough questions - the
    published attacks take from tens of thousands to millions of
    connections, each costing the server one RSA private-key operation -
    they could decrypt the premaster secret of a static RSA session they had
    recorded with that server, and so the whole session, for as long as the
    server keeps the key; and they could compute an RSA signature with the
    server's key on data of their choosing.

    THE DISCRIMINATING TEST. A server does static RSA key exchange with AES
    if
        openssl s_client -connect <host>:<port> -tls1_2
                -cipher AES128-SHA256:AES128-SHA:AES256-SHA256:AES256-SHA
    completes a handshake with it. Such a server on an affected release
    answers a ClientKeyExchange holding a random ciphertext at once with
    the fatal alert illegal_parameter, 15 03 03 00 02 02 2F; this one sends
    nothing until Finished.

    PLATFORMS. The code is the same on every platform. The new harness
    TlsRsaCkeTest gives 21 EncryptedPreMasterSecret values for an
    OpenSSL RSA-2048 key - conformant, a wrong version inside, 12
    that are not a 48-octet PKCS #1 v1.5 block, a ciphertext not below the
    modulus or longer than it; built by Python, checked by OpenSSL - to
    TLS_DecodeClientKeyExchange with a key in memory and with two key-store
    keys, and, on the wire in memory, to TsmSimpleTLSInternalServer on
    TLS_RSA_WITH_AES_128_CBC_SHA256, whose answers must be the same octets
    for every one; then a whole static RSA handshake with our client. On
    4.1.4.361 (main 4a3177a) 100 of its 261 checks pass, on Win32, Win64 and
    Linux64; with this entry alone 246 (the rest are entry 20's); with both
    entries 261.

    NOT CHANGED. The RSA private-key operation itself, which already runs
    in fixed time by default (gFixedTime); the client's side of static RSA;
    the alert for a ClientKeyExchange cut short, which depends only on its
    length fields.


20. FIXED - RSA decryption (tDSIIF.Decryption) raised ERangeError for a PKCS
    #1 v1.5 block with no zero octet after 00 02, failed an assertion for a
    ciphertext not below the modulus, and decrypted a ciphertext longer than
    the modulus as its low bits, where each should have been refused

    StreamSec.DSI.IFC. RFC 8017 section 5.1.2, RSADP step 1:

        "If the ciphertext representative c is not between 0 and n - 1,
        output "ciphertext representative out of range" and stop."

    and section 7.2.2, RSAES-PKCS1-v1_5 decryption, step 3: "if there is no
    octet with hexadecimal value 0x00 to separate PS from M", the output is
    "decryption error". tDSIIF.Decryption is the RSA decryption behind every
    caller in the library - CMS key transport (tMPPrivateKeyIF.
    DecryptKeyTransport), PEM, the composite KEM, the RSA key components,
    and the TLS server until entry 19 - and it answers False for a
    ciphertext it cannot decrypt.

    THE STEPS THAT FAILED:
      - The padding check (EME_PKCS1_v1_5_Decoding) looked for the zero
        octet and, finding none, went on to copy out a message of length
        -1: SetLength(..., -1) raised ERangeError (Delphi 13's RTL) out of
        the call. This is what the TLS server's ERangeError in entry 19 was.
      - The ciphertext was read as an integer cut to the modulus's bit
        length, so a ciphertext longer than the modulus lost its leading
        bits without notice and the rest was decrypted - a different
        ciphertext from the one given. One of the modulus's length whose
        integer was not below the modulus reached the private-key
        operation, whose assertion ("Input must be smaller than the
        modulus") raised EAssertionFailed, the library being built with
        assertions on; with assertions off it was decrypted as c mod n.

    NOW each of the three answers False and raises nothing: the block must
    have its zero octet, and the ciphertext is read whole and refused when
    its integer is not below the modulus. A longer ciphertext whose extra
    leading octets are zero is still taken, as before, and so is one
    shorter than the modulus. Decryption of a well-formed ciphertext, PKCS
    #1 v1.5 or OAEP, is unchanged.

    WHO SEES A DIFFERENCE. Only a program that decrypts such a ciphertext:
    it now gets False where it got an exception, or a message decrypted
    from other octets than it gave. Nothing in the library makes one.

    THE DISCRIMINATING TEST. With any RSA key of k octets, encrypt the block
    00 02 followed by k - 2 nonzero octets with the raw public operation
    (openssl pkeyutl -encrypt -pkeyopt rsa_padding_mode:none) and decrypt
    the result with tDSIIF.Decryption, PKCS #1 v1.5: an affected release
    raises ERangeError, this one returns False. OpenSSL's own PKCS #1 v1.5
    decryption refuses the same ciphertext.

    PLATFORMS. The code is the same on every platform. TlsRsaCkeTest
    (entry 19) checks tDSIIF.Decryption on its 21 ciphertexts with a key in
    memory and with a key-store key that does only the raw operation, and
    a key-store key that decrypts by calling tDSIIF.Decryption is checked
    through the TLS server's decoder: each must get OpenSSL's verdict - the
    message's length where OpenSSL decrypts, refusal where it refuses - and
    raise nothing. With entry 19 alone 15 of its 261 checks fail on Win32,
    Win64 and Linux64; with this entry none.

    NOT CHANGED. Whether a block decrypts is still the caller's to know:
    that is what the call is for. A program that decrypts PKCS #1 v1.5
    messages from anyone and lets the sender see whether it worked offers
    the oracle of entry 19 itself; RFC 3218, "Preventing the Million
    Message Attack on Cryptographic Message Syntax", section 2.3, gives the
    countermeasures for CMS.


--------------------------------------------------------------------------------
RSAES-OAEP DECRYPTION
================================================================================

RSAES-OAEP (RFC 8017 section 7.1) is RSA encryption with OAEP padding:
tDSIIF.Decryption with eeEME1. In the library it decrypts a CMS key
transport recipient whose keyEncryptionAlgorithm is id-RSAES-OAEP
(TstMPEnvelopedData, TstSMIMEBroker), the RSA half of the composite ML-KEM
algorithms in a CMS KEMRecipientInfo, and what the RSA key components'
Decrypt is given when their EncryptEncoding is eeEME1, the default. OAEP
encoding is public: anyone who has the public key - a certificate is enough -
can encrypt an encoded message of their own making, well formed or not.


21. FIXED - RSAES-OAEP decryption of a ciphertext whose decoded block has
    no 01 separator read on past the end of the block, and when the first
    nonzero octet it met there was 01 it raised ERangeError (Win32) or made
    a message of almost 4 GiB (Win64, Linux64)

   StreamSec.DSI.IFC. RFC 8017 section 7.1.2 step 3g separates the decoded
   data block as DB = lHash' || PS || 0x01 || M, PS a string of zero octets:
   "If there is no octet with hexadecimal value 0x01 to separate PS from M,
   if lHash does not equal lHash', or if Y is nonzero, output "decryption
   error" and stop."

   THE STEP THAT FAILED is the separator scan in EME1Decoding. Once lHash'
   was found equal to lHash, it skipped zero octets until it met one that
   was not zero, with no bound. A DB of lHash followed by nothing but zero
   octets has no such octet, so the scan went on past the end of the block
   into whatever the heap held behind it, and took the first nonzero octet
   there for the end of PS. If it was not 01 the ciphertext was refused, as
   it should be. If it was 01, the message length came out negative in a
   Cardinal - -1 for a 01 right after the block, -10 for one nine octets
   further on. On Win32 SetLength raised ERangeError out of the call. On
   Win64 and Linux64 that is a length of almost 2^32, and the call either
   raised EOutOfMemory or, where that much memory could be committed,
   returned True with a message of that many zero octets (measured with
   4294967295 octets: 1.1 s on Win64, 5.2 s on Linux64).

   WHAT IT TAKES. The public key, and a ciphertext anyone can make with it:
   the encoded message 00 || maskedSeed || maskedDB of DB = lHash || 00 ...
   00, encrypted with the public key; lHash is the hash of the empty label
   that CMS uses. Which octet the scan meets is not the sender's to write,
   but it is not chance either: it is whatever the program left behind the
   block, and in a test program it came out the same from run to run. With
   the ordinary memory manager the 14 such ciphertexts of the test below
   were refused on every platform; on Win64, six others - a 3072-bit key,
   SHA-512 or SHA-256 with a different MGF1 hash - came back True with a
   message of 4294967286 octets, the same six in two runs. A CMS message
   names its own OAEP and MGF1 hashes, so its sender picks among such
   combinations. With a test memory manager that puts each block on pages
   of its own the read past the end raised EAccessViolation, and with one
   that puts 01 right after each block it raised ERangeError (Win32) or
   asked for 4294967311 octets, the message and its array header (Win64,
   Linux64), on all 14.

   WHAT A SENDER GETS. No octet from past the block is copied out or sent
   anywhere; what differs is the outcome of the call. For a CMS recipient
   a refusal is "no recipient" - TstMPEnvelopedData.Decrypt returns False,
   as for a message to someone else. ERangeError and EOutOfMemory reach the
   program out of TstMPEnvelopedData.Decrypt and TstSMIMEBroker.Decode,
   which do not catch them. The message of almost 4 GiB is refused one
   step later, by its length (CMS key transport) or by the key unwrap after
   the composite KEM has hashed it, but only after the memory has been
   committed, filled and wiped. Nothing in the library decrypts a message
   the program did not hand it, or answers the sender of one.

   NOW every octet of DB after lHash' is read, none past it, and the same
   way whatever they hold; the first one that is not zero must be 01, and a
   DB with no such octet is refused: False, and nothing raised.

   COMPATIBILITY. Only a ciphertext whose block has no separator decrypts
   differently: it is refused now, where before, depending on the heap, it
   was refused, raised ERangeError or EOutOfMemory, or decrypted to almost
   4 GiB of zero octets. No encoder makes one. A well-formed ciphertext
   decrypts as before, and a program needs no change.

   THE DISCRIMINATING TEST. Encrypt the encoded message above with any RSA
   key - Python's pow(EM, e, n), or openssl pkeyutl -encrypt -pkeyopt
   rsa_padding_mode:none - and decrypt it with tDSIIF.Decryption, eeEME1,
   in a program whose memory manager puts 01 after each block: an affected
   release raises ERangeError (Win32) or EOutOfMemory (Win64, Linux64; or,
   without that memory manager's 64 MB cap, returns True with 4294967295
   octets); this one returns False. OpenSSL's RSAES-OAEP decryption refuses
   the same ciphertext.

   PLATFORMS. The code is the same on every platform. RsaOaepTest
   decrypts 118 ciphertexts for three OpenSSL keys (2048, 2041
   and 3072 bits; SHA-1, SHA-256 and SHA-512), each against OpenSSL's
   verdict; 28 of its checks are about this entry, and fail on Win32,
   Win64 and Linux64 before it and pass with it.

   NOT CHANGED. Decryption of a well-formed ciphertext. The legacy unit
   stMPIF, which is in none of the StrSecIV170-370 packages and not in the
   release, has the same scan and is left as it is.


22. FIXED - RSAES-OAEP decryption took a decoded block whose first octet
    was not zero when the modulus is not one bit more than a whole number
    of octets (2048 and 3072 bits among them), and it looked at the size of
    the plaintext before the hashes, so a hash it cannot use raised for
    some ciphertexts and was a quiet refusal for others

   StreamSec.DSI.IFC, EME1Decoding. RFC 8017 section 7.1.2 step 3g (quoted
   under entry 21) refuses a block whose first octet Y is not zero, and the
   note after step 4 reads: "Care must be taken to ensure that an opponent
   cannot distinguish the different error conditions in Step 3.g, whether
   by error message or timing".

   THE STEP THAT FAILED is the first one. It refused the plaintext integer
   m when its bit length was more than |n| - 1, |n| the bit length of the
   modulus, and returned at once:
     - That is the test for Y = 0 only when |n| is one more than a multiple
       of 8. For other moduli an m from 2^(8(k-1)) up to 2^(|n|-1) - a Y of
       01 to 7F for a 2048-bit modulus - got through, Y was dropped, and a
       well-formed rest decrypted.
     - It came before anything else, the hashes included. An OAEP hash
       shorter than 20 octets or not linked, and an MGF1 hash not linked,
       raise eDSIIFCUnsupportedHash - but only for the ciphertexts whose m
       got past the first step; for the others the call returned False.
     - With hashes it can use, it made those ciphertexts quicker to refuse:
       10 microseconds of 930 (medians, 2048-bit key, SHA-1, Win64).

   WHAT IT TAKES. A CMS KeyTransRecipientInfo names its own OAEP and MGF1
   hashes in its RSAES-OAEP-params, and TstMPEnvelopedData decrypts with
   the hashes it names (StreamSec.DSI.PkixCms). Whoever writes the message
   can name MD5, or a hash this library does not know, and then the outcome
   of decrypting it - eDSIIFCUnsupportedHash out of
   TstMPEnvelopedData.Decrypt and TstSMIMEBroker.Decode, or "no recipient" -
   says whether m < 2^(|n|-1), for a ciphertext of the sender's choosing.
   Answers to that question about c * s^e for chosen s are the kind of
   oracle Manger's attack on OAEP (CRYPTO 2001) uses to decrypt c - here,
   the content-encryption key of a recorded message. The answer reaches
   the sender only if the program shows it to them: the library raises it
   to the program, and nothing in the library decrypts a message on its own
   or replies to the sender of one. A program that decrypts S/MIME from
   anyone without a person in the loop and answers an exception otherwise
   than a message not for it would hand it over, one message per answer.

   NOW the hashes are checked first, and Y, lHash' and the separator are
   computed for every ciphertext and decided together, in one value. A
   hash the decoder cannot use raises eDSIIFCUnsupportedHash for every
   ciphertext, and a nonzero Y is refused for every modulus. Measured
   after, the three kinds of m above are refused within 1.5 microseconds of
   each other (medians of 873).

   COMPATIBILITY. A ciphertext whose block begins with a nonzero octet
   and is otherwise well formed decrypted before, with moduli of 2048 and
   3072 bits among others, and is refused now, as OpenSSL refuses it. No
   conforming encoder makes one - this library's own encryption writes a
   zero - so only a ciphertext made to be malformed sees a difference. A
   call with a hash the decoder cannot use raises for every ciphertext now,
   where it returned False for some. A program needs no change.

   THE DISCRIMINATING TEST. With a 2048-bit key, encrypt with the raw
   public operation a well-formed OAEP block whose first octet is 01 in
   place of 00, and decrypt it with tDSIIF.Decryption, eeEME1: an affected
   release returns True and the message, this one returns False, as
   OpenSSL's decryption does. Then decrypt, with haMD5 as the OAEP hash, a
   ciphertext whose block begins with 80: an affected release returns
   False, this one raises eDSIIFCUnsupportedHash, as both do for a block
   that begins with 00.

   PLATFORMS. RsaOaepTest (entry 21) has 19 checks of this: 10 ciphertexts
   with a nonzero first octet, and 9 decrypted with an unusable hash. They
   fail on Win32, Win64 and Linux64 with entry 21 alone and pass with this
   entry; 183 of 183.

   NOT CHANGED. A hash shorter than 20 octets still raises rather than
   returning False, and the hashes a KeyTransRecipientInfo names are still
   used as named.


--------------------------------------------------------------------------------
RSAES-OAEP: AN OAEP HASH AND AN MGF1 HASH THAT DIFFER
================================================================================

RSAES-OAEP (RFC 8017 section 7.1) takes two hash functions, chosen each on its
own: the OAEP hash, which hashes the label (lHash = Hash(L)), and the hash of
the mask generation function MGF1, which makes both masks. RFC 8017 does not
ask for the two to be the same. Java's "OAEPWithSHA-256AndMGF1Padding" is
SHA-256 with MGF1-SHA-1; a CMS KeyTransRecipientInfo names both in its
RSAES-OAEP-params; TstRSAPublicKey and TstRSAKey have a DigestAlgorithm and an
MGFHashAlgorithm. The four entries below are about two different hashes. With
the same hash twice - every default in the library - nothing changes.


23. FIXED, BEHAVIOUR CHANGE - RSAES-OAEP with an OAEP hash and an MGF1 hash
    that differ masked the seed with MGF1 over the OAEP hash: such a
    ciphertext from OpenSSL did not decrypt here, and one this library made
    decrypted nowhere else

    StreamSec.DSI.IFC, StreamSec.DSI.PKTypes. RFC 8017 section 7.1.1, step
    2g, and section 7.1.2, step 3c:

        "Let seedMask = MGF(maskedDB, hLen)."

    tDSIIF.Encryption and tDSIIF.Decryption with eeEME1 - what
    TstRSAPublicKey.Encrypt, TstRSAKey.Decrypt and CMS key transport call -
    made the DB mask with MGF1 over the MGF1 hash, as RFC 8017 says, and the
    seed mask with MGF1 over the OAEP hash. Every release since
    StreamSec.DSI.IFC came, in 4.0 beta 0.287.

    THE STEPS THAT FAILED, with two different hashes:
      - Decrypting a ciphertext any other implementation made: the seed came
        out wrong, DB with it, and Decryption returned False - as for a
        ciphertext to another key. Neither the key, how it was loaded, the
        label nor the hash units linked had a part in it.
      - Encrypting: OpenSSL refused the ciphertext ("oaep decoding error"),
        as does any decryptor that follows RFC 8017. By its code that takes
        in a PKCS #11 key used through this library: StreamSec.DSI.
        Pkcs11ExtKey hands both hashes to the token and lets it decrypt (not
        measured; no token here).

    NOW both masks come from MGF1 over the MGF1 hash, both ways. The two
    hashes are still chosen each on its own.

    WHAT EARLIER RELEASES ENCRYPTED STILL DECRYPTS. When the two hashes
    differ and the RFC 8017 decoding fails, iDSIIF.Decryption - and so
    TstRSAKey.Decrypt - tries the seed mask of the earlier releases, so data
    a program encrypted with two different hashes and kept decrypts as
    before. The new interface iIFDecryptionRFC8017 (StreamSec.DSI.PKTypes;
    DecryptionRFC8017, the same arguments as the long Decryption; ask
    GetDSIIF for it with Supports) decrypts what RFC 8017 defines and
    nothing else, as OpenSSL does. CMS key transport uses it: there the
    message names its hashes, and no CMS message an earlier release made
    with two different hashes opened anywhere (entry 24).

    THE BEHAVIOUR CHANGE. A ciphertext this release makes with two different
    hashes does not decrypt in an earlier release, which knows only the old
    seed mask. Where a program of an earlier release decrypts what this one
    encrypts, upgrade the decrypting side first, or keep the two hashes the
    same until both are upgraded.

    WHO IS AFFECTED. A program that sets the two hashes apart: TstRSAPublicKey
    or TstRSAKey with DigestAlgorithm and MGFHashAlgorithm set to different
    values (their defaults have always been the same: SHA-1 and SHA-1 up to
    4.1.3.359, SHA-256 and SHA-256 since 4.1.4.360), tDSIIF.Encryption or
    Decryption with two different hashes, or the Encryption and Decryption
    overloads without a label with eeEME1 and a hash other than SHA-1 - those
    take MGF1 with SHA-1. Nothing in the library sets them apart by itself;
    CMS does what the application or the message says.

    THE DISCRIMINATING TEST. Encrypt with OpenSSL,
        openssl pkeyutl -encrypt -inkey <key> -pkeyopt rsa_padding_mode:oaep
                -pkeyopt rsa_oaep_md:sha256 -pkeyopt rsa_mgf1_md:sha1
    and decrypt with tDSIIF.Decryption, haSHA256, haSHA1, eeEME1: an affected
    release returns False, this one the message.

    NOT CHANGED: one hash twice, either way; PKCS #1 v1.5; how a key in a
    PKCS #11 token decrypts - the token does it, so what an earlier release
    encrypted with two hashes to such a key did not decrypt and still does
    not.

    PLATFORMS. RsaOaepMgfTest decrypts, with three OpenSSL keys
    (2048, 2041 and 3072 bits) and six ordered pairs of SHA-1, SHA-256 and
    SHA-512, 78 conformant ciphertexts (6 encrypted by OpenSSL), 36 made the
    way earlier releases made them and 72 malformed ones, all built by
    Python and checked against OpenSSL; and encrypts 48 known-seed vectors,
    the seed handed over through the library's random generator. Before this
    entry every conformant ciphertext was refused and every encryption with
    two hashes differed from Python's: 151 of the 286 checks that do not
    need iIFDecryptionRFC8017 were green; now all 473, with the 187 that do,
    on Win32, Win64 and Linux64.


24. FIXED - TstMPEnvelopedData with RSAOAEPMGFHashAlgorithm set apart from
    RSAOAEPHashAlgorithm named the OAEP hash as the MGF1 hash in its
    RSAES-OAEP-params: nothing could open the message, this library
    included

    StreamSec.DSI.PkixCms. RFC 8017 appendix A.2.1, maskGenAlgorithm: "The
    parameters field associated with id-mgf1 SHALL be an algorithm ID with
    an OID in the set OAEP-PSSDigestAlgorithms, identifying the hash
    function on which MGF1 is based."

    THE STEP THAT FAILED. Encrypt with UseRSAOAEPEncryption wrapped the
    content key with MGF1 over RSAOAEPMGFHashAlgorithm and wrote
    RSAOAEPHashAlgorithm into maskGenAlgorithm. A recipient takes the hashes
    from the message, so it unmasked with the other one and found no key -
    OpenSSL, other implementations, and this library too. Since 4.0.1.328,
    where the two properties came.

    NOW the parameters name RSAOAEPMGFHashAlgorithm. With entry 23, openssl
    cms -decrypt opens the message.

    WHO IS AFFECTED. A program that sets the two properties apart. Both
    default to SHA-1, and with them equal nothing changes. A message made
    with them apart never opened anywhere, so there is nothing to keep
    compatible with.

    THE DISCRIMINATING TEST. Encrypt with RSAOAEPHashAlgorithm haSHA256 and
    RSAOAEPMGFHashAlgorithm haSHA1, and look at the message with openssl cms
    -cmsout -print: an affected release names sha256 under maskGenAlgorithm,
    this one sha1.

    NOT CHANGED. The SHA-1 defaults are still written out. RFC 3560 section 3
    says an encryptor "MUST omit" the hashFunc field when SHA-1 is used, and
    the maskGenFunc field for MGF1 with SHA-1; but a recipient on a release
    without entry 25 cannot open a message that leaves maskGenAlgorithm out.

    PLATFORMS. CmsOaepTest (entry 25) makes our own messages under five hash
    pairs and checks the OIDs in their parameters, and that they open again;
    a script has OpenSSL open them. With entry 23 alone three of the five did
    not open anywhere, and their parameters named the wrong hash; now all five
    open, here and in OpenSSL.


25. FIXED - TstMPEnvelopedData.Decrypt raised eASN1Error ("Attempt to modify
    ReadOnly instance of tASN1ObjectIdentifier") for a KeyTransRecipientInfo
    whose RSAES-OAEP-params leave maskGenAlgorithm out - MGF1 with SHA-1, the
    default, which is how OpenSSL writes it

    StreamSec.DSI.PkixCms. RFC 8017 appendix A.2.1:

        RSAES-OAEP-params ::= SEQUENCE {
            hashAlgorithm      [0] HashAlgorithm     DEFAULT sha1,
            maskGenAlgorithm   [1] MaskGenAlgorithm  DEFAULT mgf1SHA1,
            pSourceAlgorithm   [2] PSourceAlgorithm  DEFAULT pSpecifiedEmpty
        }

    and RFC 3560 section 3: "Implementations that perform encryption MUST
    omit the maskGenFunc field when MFG1 with SHA-1 is used".

    THE STEP THAT FAILED. To learn the recipient's MGF1 hash, Decrypt asked
    maskGenAlgorithm for its MGF1 parameters also when the message had none,
    and that raised out of Decrypt. So no message with MGF1-SHA-1 opened:
    neither what "openssl cms -encrypt -keyopt rsa_padding_mode:oaep" makes
    (SHA-1 and MGF1-SHA-1, the parameters an empty SEQUENCE) nor SHA-256
    with MGF1-SHA-1. Messages this library made did open: it writes the
    defaults out (entry 24, NOT CHANGED). Since 4.0.1.328.

    NOW a field the parameters leave out is its default.

    WHO IS AFFECTED. A program that decrypts RSAES-OAEP EnvelopedData from
    OpenSSL or any other sender that leaves the defaults out, as RFC 3560
    asks.

    THE DISCRIMINATING TEST. openssl cms -encrypt -binary -aes128 -recip
    <certificate> -keyopt rsa_padding_mode:oaep, and Decrypt the result: an
    affected release raises eASN1Error, this one opens it.

    PLATFORMS. CmsOaepTest decrypts OpenSSL's AES-128-CBC EnvelopedData
    to an OpenSSL RSA-2048 recipient under five hash pairs and one
    with the defaults written out, refuses eight that OpenSSL refuses,
    and makes our own under five pairs (entry 24). Before entry 23, 31 of
    the 43 checks that do not need iIFDecryptionRFC8017 were green; with
    entry 23, 36 of 46; with 24, 42; with this entry 45, and with entry 26
    all 46, on Win32, Win64 and Linux64.


26. FIXED - TstMPEnvelopedData.Decrypt passed over RSAES-OAEP-params it does
    not use: a message naming a label was decrypted with the empty one, and
    a hash it did not know left the hash it used undefined

    StreamSec.DSI.PkixCms. RFC 8017 appendix A.2.1: pSourceAlgorithm
    "identifies the source (and possibly the value) of the label L", and
    maskGenAlgorithm "SHALL consist of id-mgf1".

    THE STEPS THAT FAILED:
      - pSourceAlgorithm was not read at all. The content key was unwrapped
        with the empty label whatever the message named: one that names a
        label but was wrapped with none opened (OpenSSL refuses it), and one
        wrapped with its label did not open - rightly, but for the wrong
        reason.
      - The result of OIDToHashAlgorithm was not looked at, nor the mask
        generation function's OID: a hash it does not know would have left
        the hash used to whatever was there before. No message reaches this
        today: the RSAES-OAEP tables of StreamSec.DSI.Pkcs1 refuse an OID
        outside them while the message is read, before any key is touched.

    NOW a recipient whose parameters name a label, a hash it does not know,
    or a mask generation function other than MGF1 is refused - Decrypt
    returns False, raising nothing, when no other recipient opens - as
    OpenSSL refuses it.

    NOT CHANGED. A label is still not supported. That the hash is linked and
    long enough is still the decryption's own check, which raises
    eDSIIFCUnsupportedHash.

    PLATFORMS. CmsOaepTest (entry 25) has OpenSSL's SHA-1 message with
    parameters written over it naming the label "L", an unknown OAEP hash,
    an unknown MGF1 hash and an unknown MGF, and checks each is refused.
    With entry 25 alone the first opened; now none does, on Win32, Win64
    and Linux64.


--------------------------------------------------------------------------------
RSASSA-PSS AND RSAES-OAEP PARAMETERS OF KEYS AND SIGNATURES
================================================================================

RSASSA-PSS signatures (RFC 8017 section 8.1), and RSA keys restricted to them
or to RSAES-OAEP, carry an AlgorithmIdentifier whose parameters name the hash,
the mask generation function and its hash, the salt length and the trailer
field (RFC 8017 appendix A.2.3 and A.2.1, RFC 4055). Every one of these fields
has a DEFAULT, and RFC 4055 section 3.1 tells a signer to leave out each field
that holds it: OpenSSL's signature with SHA-256 and MGF1-SHA-1 carries no
maskGenAlgorithm, and one with SHA-1 throughout an empty SEQUENCE. Entry 25 did
for CMS key transport what entry 28 below does for signatures and keys.


27. FIXED - a certificate whose public key is an RSASSA-PSS key
    (id-RSASSA-PSS), and an RSA-PSS private key in PKCS #8, raised eASN1Error
    when the key was used, whatever its parameters, and reading the
    parameters of such an AlgorithmIdentifier being built turned its
    algorithm into id-rw

    StreamSec.DSI.PkixCert, StreamSec.DSI.Pkcs8, StreamSec.DSI.Pkcs8Format.

    THE STEP THAT FAILED. The parameters of a SubjectPublicKeyInfo's
    algorithm (tPKAlgorithmID) and of a PKCS #8 privateKeyAlgorithm
    (tPkcs8PrivateKeyAlgorithms) are a CHOICE whose alternative the
    algorithm's OID selects. Three of their accessors selected the
    alternative of another algorithm: AsRsassaPss that of id-rw, AsRw that
    of id-nr, and AsNr that of id-RSASSA-PSS. On a certificate or key that
    was read, and so is read-only, selecting another alternative raises:
      - taking the RSA key out of a certificate whose subjectPublicKeyInfo
        is id-RSASSA-PSS raised eASN1Error ("Attempt to modify ReadOnly
        instance of tPKAlgorithmID"), with parameters or without. That is
        the first step of verifying any signature the key makes, the
        certificate's own included: CheckSignature raised;
      - reading an RSA-PSS private key from PKCS #8, which is what
        "openssl genpkey -algorithm RSA-PSS" writes, raised the same for
        tPkcs8PrivateKeyAlgorithms;
      - id-rw and id-nr keys (Rabin-Williams and Nyberg-Rueppel, under
        StreamSec's own arc 1.3.6.1.4.1.13085) did not read either, and
        writing an RW key to PKCS #8 ended in an access violation.
    On an AlgorithmIdentifier being built, reading AsRsassaPss switched its
    algorithm from id-RSASSA-PSS to id-rw, and AsRw from id-rw to id-nr.
    Since StreamSec.DSI.PkixCert came, in 4.0 beta 0.287
    (StreamSec.DSI.Pkcs8: 4.0 preview 0.282).

    NOW each accessor selects its own algorithm's alternative, and an RW key
    goes into PKCS #8 through the privateKey alternative of id-rw; through
    that of rsaEncryption, as before, it would have come out as an RSA key.
    With this entry alone, a key whose parameters leave maskGenAlgorithm
    out, or leave the parameters out altogether, still raises when it is
    read: entry 28.

    WHO IS AFFECTED. A program that checks a certificate whose key is
    id-RSASSA-PSS, or verifies a signature such a key made, or reads an
    RSA-PSS key from PKCS #8; one that uses RW or NR keys.

    THE DISCRIMINATING TEST. openssl genpkey -algorithm RSA-PSS -pkeyopt
    rsa_keygen_bits:2048 -out k.pem, then openssl req -x509 -key k.pem
    -subj /CN=x -outform DER -out c.der, and CheckSignature(nil) on c.der:
    an affected release raises eASN1Error naming tPKAlgorithmID.

    NOT CHANGED. ImposeRSAPublicKey(..., uaSourceSpecified) still writes
    rsaEncryption for a key whose SignEncoding and EncryptEncoding restrict
    it to RSASSA-PSS or to RSAES-OAEP: this library writes no id-RSASSA-PSS
    or id-RSAES-OAEP subjectPublicKeyInfo.

    PLATFORMS. PssParamsTest, section 2: OpenSSL's certificate
    and PKCS #8 key with id-RSASSA-PSS parameters are read, and
    id-RSASSA-PSS, id-rw and id-nr AlgorithmIdentifiers are built, in both
    classes. All 8 checks are red before this entry and green with it, on
    Win32, Win64 and Linux64; the whole harness goes from 64 of 140 to 74 of
    140 (and to 148 of 148 with entry 28).


28. FIXED - RSASSA-PSS parameters that leave a field out - maskGenAlgorithm
    when it is MGF1 with SHA-1, as OpenSSL writes it - raised from signature
    verification of certificates, CMS SignerInfos and time-stamp tokens,
    from reading an RSASSA-PSS or RSAES-OAEP key, and from issuing under a
    CA that signs that way; and a hash the parameters named that this
    library does not know was passed over

    StreamSec.DSI.Pkcs1, StreamSec.DSI.PkixSigned, StreamSec.DSI.PkixCert,
    StreamSec.DSI.PkixCms, StreamSec.DSI.Tsp, StreamSec.DSI.Pkcs8,
    StreamSec.DSI.Pkcs8Format, stPkixConst. RFC 8017 appendix A.2.3:

        RSASSA-PSS-params ::= SEQUENCE {
            hashAlgorithm      [0] HashAlgorithm      DEFAULT sha1,
            maskGenAlgorithm   [1] MaskGenAlgorithm   DEFAULT mgf1SHA1,
            saltLength         [2] INTEGER            DEFAULT 20,
            trailerField       [3] TrailerField       DEFAULT trailerFieldBC
        }

    and RFC 4055 section 3.1, of maskGenAlgorithm: "implementations MUST
    accept both the default value encoding (i.e., an absent field) and
    mfg1SHA1Identifier to be explicitly present in the encoding".

    THE STEPS THAT FAILED. To learn the MGF1 hash, each of these asked
    maskGenAlgorithm for its MGF1 parameter also when the encoding left
    maskGenAlgorithm out, and reading anything inside a field that is not
    there raises:
      - tSigned.CheckSignature - certificates, CRLs and PKCS #10 requests
        signed with RSASSA-PSS - raised EAssertionFailed (an Assert in
        stASN1Base, in builds with assertions on);
      - TstMPSignedData.VerifySignedData raised eASN1Error ("Attempt to
        modify ReadOnly instance of tASN1ObjectIdentifier");
      - TstTimeStampClient.VerifyToken raised EAssertionFailed;
      - taking an RSAES-OAEP key out of a certificate, or an RSASSA-PSS
        key once entry 27 lets it get that far, or an RSA-PSS key out of
        PKCS #8, raised EAssertionFailed, and eASN1DataError ("Unexpected
        tag in tRSASSAPSSParams" / "tRSAESOAEPParams") when the parameters
        are left out altogether;
      - RSAPSSSign raised EAssertionFailed when the CA certificate's own
        signature left maskGenAlgorithm out, before signing anything;
      - SignatureDigestAlgorithm, which CheckSignature asks first, read
        hashAlgorithm the same way: parameters that leave it out - SHA-1
        throughout, an empty SEQUENCE - raised EAssertionFailed there.
    So no RSASSA-PSS signature with MGF1-SHA-1 was verified, from OpenSSL
    or any signer that leaves the default out, and no RSA-PSS key that
    OpenSSL writes with such restrictions was read. Where the parameters
    named their fields, what they named was not checked: the result of
    OIDToHashAlgorithm was not looked at, so an MGF1 hash this library does
    not know left the one used to whatever the local variable held - and
    CheckSignature and VerifyToken returned True for a signature made with
    MGF1-SHA-1 whose parameters were rewritten to name an MGF1 hash no
    implementation knows, the variable holding SHA-1 on Win32, Win64 and
    Linux64 alike. The trailer field was not read. A PKCS #8 RSA-PSS key
    took its MGF1 hash from maskGenAlgorithm's own OID, which is id-mgf1
    and names no hash, so its MGF1 hash was never set. And on a certificate
    RSAPSSSign had just signed, not yet encoded, SignatureDigestAlgorithm
    answered SHA-1 whatever the hash: the parameters written in memory did
    not report themselves present. Since 4.0 beta 0.287 (certificates and
    keys), 4.0.1.328 (CMS SignedData) and 4.1.2.355 (time-stamp tokens).

    NOW every one of them reads the parameters through RsassaPssParamsGiven
    and RsassaPssParamsValues, RsassaPssParamsHash or
    RsaesOaepParamsHashValues, new in StreamSec.DSI.Pkcs1. They read an
    element only when it is present in what was decoded, or belongs to an
    instance being built; a field left out is its DEFAULT; and parameters
    that name a hash this library does not know, a mask generation function
    other than MGF1 (or MGF1 without its hash), a negative salt length or a
    trailer field other than 1 are refused, without raising:
      - CheckSignature returns False with pcvUnsupportedSignatureAlgorithm,
        also when the parameters of an RSASSA-PSS signature are left out
        altogether, which RFC 4055 section 3.1 does not allow ("The
        parameters MUST be present when used in the algorithm identifier
        associated with a signature value"), and False with
        pcvInterfaceNotSupportedKey when the issuer's key is not one it can
        use;
      - VerifySignedData and VerifyToken refuse the signer as well when the
        parameters' hashAlgorithm is not the SignerInfo's digestAlgorithm,
        RFC 4056 section 3: "The same one-way hash function MUST be used for
        computing the message digest on the signedAttributes and as the
        hashAlgorithm in the RSA-PSS-params structure." VerifyToken says
        which in LastError;
      - VerifySignedData reads the parameters of a countersignature
        (entry 7) as it reads a signer's, and holds them to the
        countersignature's own digestAlgorithm; one it refuses it reports
        through OnBadSignature;
      - no key is returned for parameters that name what this library
        does not know. Parameters of an RSA-PSS or RW key left out
        altogether restrict nothing (RFC 4055 section 3.3): the key comes
        out with no hash chosen, as an rsaEncryption key does. Those of an
        RSAES-OAEP key are SHA-1 and MGF1 with SHA-1 (RFC 4055 section 4);
      - RSAPSSSign and RSAPSSSignEx write the parameters they sign with in
        full, into the certificate and into its tbsCertificate alike, and
        RSAPSSSign refuses a CA certificate whose own parameters are missing
        or name what this library does not know;
      - SignatureDigestAlgorithm answers SHA-1 for a hashAlgorithm left out
        and the hash written for a certificate being built, and haNull, as
        before, for a hash it does not know.
    An RW key written to PKCS #8 names its MGF1 hash as the parameter of
    id-mgf1 (the hash's OID used to be written where id-mgf1 belongs, which
    raises since entry 27), and it reads back.

    WHO IS AFFECTED. A program that verifies certificates, CRLs, CMS
    SignedData or time-stamp tokens signed with RSASSA-PSS by a signer that
    leaves default fields out - OpenSSL does - or reads RSA-PSS keys.

    THE DISCRIMINATING TEST. openssl req -x509 -newkey rsa:2048 -nodes
    -subj /CN=x -sha256 -sigopt rsa_padding_mode:pss -sigopt
    rsa_mgf1_md:sha1 -outform DER -out c.der, and CheckSignature(nil) on
    c.der: an affected release raises, this one returns True.

    NOT CHANGED. RSAPSSSign and RSAPSSSignEx still write every field out,
    the defaults included, where RFC 4055 section 3.1 tells a signer to
    leave them out ("Implementations that perform signature generation MUST
    omit the maskGenAlgorithm field when MGF1 with SHA-1 is used");
    verifiers accept both, OpenSSL among them. A certificate's RSASSA-PSS
    key parameters are not compared with those of the signatures it
    verifies (RFC 4055 section 3.3, RFC 4056 section 3), and the saltLength
    of a key's parameters is not applied to the key. The label of an
    RSAES-OAEP key in a certificate (pSourceAlgorithm) is not read.
    VerifySignedData reads the whole message before it checks a signature,
    and a message in which RSASSA-PSS parameters - a signer's or a
    countersignature's - name a hash, a mask generation function or a
    trailer field this library does not know is not read: VerifySignedData
    returns False, raising nothing, and reports no signer, as before.

    PLATFORMS. PssParamsTest, sections 3 to 8: OpenSSL's certificates,
    keys, CMS SignedData and time-stamp tokens with fields left out
    (SHA-1 throughout included), written out, and rewritten (by a Python
    script) to name an unknown hash, an unknown MGF1 hash, an unknown
    MGF, MGF1 without a hash, trailer field 2, no parameters, or an MGF1
    hash other than the signature's, each of which OpenSSL refuses; an RW
    key through PKCS #8; and certificates issued with RSAPSSSign under
    OpenSSL's CA certificates and with RSAPSSSignEx, checked in memory and
    as read back, which a script has OpenSSL verify. Section 7 also
    has VerifySignedData check countersignatures (entry 7) signed with
    RSASSA-PSS by "openssl dgst", which verifies the ones meant to verify
    and refuses the one with hashAlgorithm left out: one with
    maskGenAlgorithm left out, and one with SHA-384, its own
    digestAlgorithm, under a SHA-256 signer, are reported through
    OnGoodCounterSignature; one with hashAlgorithm left out under SHA-256
    through OnBadSignature; a message whose countersignature names an
    unknown MGF1 hash is not read (NOT CHANGED above). 74 of 140 with
    entry 27 alone, 148 of 148 with this entry, on Win32, Win64 and Linux64.


--------------------------------------------------------------------------------
ASYNC TLS SERVER AND THE HTTPS PLUGINS: LARGE RESPONSES
================================================================================

TsmAsyncTLSServer queues what a connection sends behind the buffer that is
already on its way to the peer, and closes the connection when that queue
would pass MaxSendQueueBytes (1 MiB by default). That bound is what keeps a
peer which stops reading from making the server hold every response for it.
The four entries below are about what it did to large responses from
TsmHTTPSv1dot1 and TsmHTTPSv2, and about what now keeps them under it.


29. FIXED - an HTTP/2 download stopped part-way, after 6 to 9 MiB in a
    browser, and a response of more than 1 MiB to a request sent right
    behind the client's TLS 1.3 Finished arrived empty, over HTTP/1.1 and
    HTTP/2 alike: the transport closed the connection over a send queue it
    had been handed too much at once, and said nothing

    StreamSec.Mobile.AsyncTLSReactor, StreamSec.Mobile.AsyncTLSReactor.IOCP,
    StreamSec.Mobile.AsyncTLSServer, StreamSec.Http.Http2Conn,
    StreamSec.Mobile.HTTPS.

    THE STEP THAT FAILED is tReactorConnection.EnqueueSend, which takes what
    a session hands to Send. With a send already in flight it queues the
    buffer, and if the queue would pass MaxSendQueueBytes it drops the buffer
    and closes the connection. Both HTTPS plugins handed it more than that in
    one call:
      - HTTP/2. tHttp2Conn produced as much response DATA as the flow-control
        windows allowed and passed it on in one Send. A browser opens large
        windows - Chromium 6 MiB per stream and 15 MiB for the connection -
        so a WINDOW_UPDATE released megabytes while the previous ones were
        still being sent, and the connection was closed. Measured with
        Node's http2 client using Chromium's windows: 9,437,184 octets of a
        64 MiB file, then a reset.
      - HTTP/1.1 and HTTP/2 on a new TLS 1.3 connection. The server sends
        its NewSessionTicket messages right after the handshake. A client
        that sends its request directly behind its Finished, as OpenSSL and
        Node do, finds that flight still in flight when the response is
        ready, so the whole response was queued behind it, and any response
        over 1 MiB was dropped whole: the client received 0 octets.
    The server logged nothing, because the close had no event. Raising
    MaxSendQueueBytes above the largest response hid the failure, at the
    cost of letting every connection hold that much.

    NOW THE TRANSPORT SAYS HOW MUCH IT WILL TAKE, AND WHEN IT HAS ROOM.
    Two optional companions, reached by QueryInterface like
    iAppSessionNudge, so a plugin that implements neither is not affected:
      iAppTransportFlow   on the transport. SendCredit is how many octets of
                          application data Send can take now without the
                          ceiling closing the connection - counting the
                          buffer in flight, net of TLS record overhead, and
                          keeping a quarter of the ceiling for what the
                          stack sends on its own. SendPending is what has
                          been handed over and not yet taken by the peer.
      iAppSessionDrain    on the session. Drained(aPending) runs after every
                          completed send.
    Both HTTPS plugins use them. Each keeps at most about 1 MiB of a
    response with the transport, in Sends of at most 512 KiB on HTTP/1.1
    and about 256 KiB on HTTP/2 and never more than SendCredit, and sends
    the next part from Drained. tHttp2Conn produces DATA only while its new
    OnOutputRoom allows and resumes in its new ResumeOutput; a ResumeOutput
    that arrives from inside OnOutput - as a completion can on the POSIX
    reactors, which write inline - is noted and carried out when that call
    returns. HTTP/1.1 holds a pipelined request until the response before
    it has gone, and Connection: close until all of it has.

    AND ON WINDOWS THE CLOSE THAT FOLLOWS NO LONGER LOSES THE END OF IT. A
    response sent in parts finishes from the send-completion arm, where the
    connection has a receive posted, and closesocket on such a socket reset
    the connection and discarded what the kernel had not yet sent: the last
    few hundred kilobytes of a response answered with Connection: close.
    tIOCPReactor.CloseSocketHandle now shuts the sending side down first.
    Every release since the IOCP reactor came, in 4.1.2.355, took the same
    path for a response queued behind something in flight - an answer to a
    0-RTT request, close_notify at Deactivate - and could lose its end the
    same way. The POSIX reactors close with close(), which sends what is queued.

    THROUGHPUT, measured on loopback with a 64 MiB file, with the machine to
    itself (the median of five, seven for OpenSSL, whose output was
    discarded), against 4.1.4.361 with MaxSendQueueBytes = 0 - the only
    setting in which it delivers these at all, as one Send for the whole
    body:
                                 Win32           Win64
                              now    before   now    before
        HTTP/2 (Node)        0.30 s  0.56 s   0.27 s  0.55 s
        HTTP/1.1 (Node)      0.43 s  0.40 s   0.39 s  0.35 s
        behind Finished      0.42 s  0.37 s   0.35 s  0.31 s
        OpenSSL s_client     1.43 s  1.30 s   1.38 s  1.24 s
    The size of each Send sets the pace, because one send is in flight per
    connection: in 64 KiB pieces the same HTTP/1.1 download took 2.4 times
    as long.

    HOW IT WAS TESTED. The new LargeDownloadServer, driven by a
    script with clients that are not this library - Node 24's http2,
    https and tls, and OpenSSL 3.5.7 s_client - downloads a 64 MiB
    file, a 24 MiB body in memory and a copied stream, and checks
    each against the SHA-256 of what was served, in 33 checks: HTTP/2 with
    Chromium's windows, several downloads at once on one HTTP/2 connection,
    HTTP/1.1 kept alive, requests behind Finished, pipelined requests ending
    in Connection: close, OpenSSL on TLS 1.3 and 1.2, and no
    OnSendQueueOverflow (entry 32). On 4.1.4.361's code (main f7c1ce4,
    unchanged in these units since that release) 12 of the 33 pass. With
    entries 29 to 32, 33 on Win32, Win64 and Linux64. With the
    pacing switched off in this code, 11 pass and the server reports 14
    overflows; without the shutdown before the close, 27.

    NOT CHANGED. What MaxSendQueueBytes means, and its default; HTTP/2 flow
    control; a plugin of your own that sends in one piece, which still has
    to keep within the ceiling - it can now ask SendCredit and wait for
    Drained.


30. BEHAVIOUR CHANGE - a response body handed over as a stream is sent from
    that stream instead of from a copy in memory: SetContentStream with
    aOwns = True, SendFile, SendFileRange, HttpSendFile, and HttpSendStream
    and HttpSendStreamRange with aOwns = True

    StreamSec.Http.Server, StreamSec.Http.Http2Conn, StreamSec.Mobile.HTTPS.
    Every one of these copied the body into the response, and the wire
    session copied it again into what it sent: a 37 MB download was more
    than 37 MB of memory before its first octet left. The response now
    keeps the stream, and the wire session reads it in the pieces of entry
    29, so a download costs a file handle and those pieces.

    WHAT CHANGES FOR A CALLER:
      - THE FILE STAYS OPEN until the response has been sent or the
        connection has gone, not just until the handler returns. SendFile,
        SendFileRange and HttpSendFile open it closed to writers
        (fmShareDenyWrite), so a file being downloaded cannot be
        overwritten or replaced until the download ends - and a large file
        sent to a slow client can be open for a long time.
      - SetContentStream(aStream, True) frees aStream later rather than
        before it returns. Nothing may use the stream after the call, as
        before.
      - A file SendFile cannot open - locked, or gone after the test for it
        - answers 404, as SendFileRange always did, instead of raising, which
        the plugins answered with 500.
      - tHttpServerResponse.BodyStream, read by code that inspects a
        response, reads such a body into memory the first time it is used.
    New for this: iHttpResponseSource.SetContentSource(aStream, aOffset,
    aLength), the companion to iHttpResponse that takes a window of a
    stream without reading it (Supports on the response; this library's
    response implements it), and tHttpServerResponse.BodyLength and
    TakeBody, which the wire sessions use.

    NOT CHANGED. aOwns = False still copies: the stream stays the caller's
    and may be gone when the handler returns. Content set with SetContent
    or SetContentText is in memory as before (and counted by entry 31 on
    HTTP/2). Ranges, validators and conditional requests answer exactly as
    before.


31. NEW, BEHAVIOUR CHANGE - HTTP/2 refuses new streams with REFUSED_STREAM
    while the responses a connection, or the server, holds in memory are
    over a bound: TsmHTTPSv2.Limits.ConnResponseBytes (32 MiB) and
    Limits.TotalResponseBytes (256 MiB)

    StreamSec.Http.Http2Conn, StreamSec.Mobile.HTTPS. A response body in
    memory is held until its last DATA frame is out, and a stalled stream -
    a peer that keeps its window shut - holds it for as long as the peer
    likes. The only bound was MaxConcurrentStreams times the largest
    response the application makes: 100 streams of a 16.7 MB response is
    about 1.67 GB on one connection. Now the response octets held in memory
    are counted per connection and across the server, and while either
    bound is reached a new stream is refused with REFUSED_STREAM, which
    tells the client the request was not processed and may be retried (RFC
    9113 section 8.7). Streams already open carry on; bodies sent from a
    file (entry 30) are not counted. TsmHTTPSv2.ResponseBytesHeld and
    ResponseBytesHighWater measure it, and tHttp2Conn has
    MaxConnResponseBytes, ResponseBytes and the OnChargeResponse,
    OnReleaseResponse and OnResponseBudgetFull hooks. 0 switches either
    bound off.

    WHY A BEHAVIOUR CHANGE. It is on by default: a connection with more
    than 32 MiB of responses in memory waiting to be sent has its next
    request refused where it used to be served.


32. NEW - TsmAsyncTLSServer.OnSendQueueOverflow reports the close that
    MaxSendQueueBytes makes, the buffer in flight is counted, and the
    documentation no longer says a single large response is safe from the
    ceiling

    StreamSec.Mobile.AsyncTLSReactor, StreamSec.Mobile.AsyncTLSServer. The
    close for a full send queue was the one close the server makes on its
    own that left no trace. OnSendQueueOverflow fires once per connection,
    just before that close, with what was queued, what was in flight and
    the size of the buffer refused. It is a notification: the close is not
    vetoable. tReactorConnection has SendInFlightBytes, SendPendingBytes,
    SendCredit and the DoSendOverflow hook beneath it.
    AsyncTLSServer.txt section 5.05 and the comment on MaxSendQueueBytes
    said the buffer in flight is excluded, "which is why a single large
    response is never affected"; entry 29 shows why that was wrong. Both
    now say when a response is affected and how a plugin paces itself.


--------------------------------------------------------------------------------
SOCKETS: A CLOSE ON ONE THREAD WHILE ANOTHER WAITS ON THE SOCKET
================================================================================


33. FIXED, BEHAVIOUR CHANGE - a WaitForData or WaitForWrite waiting on a
    socket, or about to, when another thread closed it could sit out its
    whole time, on every platform, and on Windows a Close made while a
    WaitForWrite waited took as long itself, and one made while a blocking
    accept waited lasted until a connection came; and on Windows
    WaitForData on a socket that another thread had closed raised
    EstSocketError, "An operation was attempted on something that is not
    a socket (10038), on API 'select'": every time when the Close came
    first, and now and then when it came during the call. It now answers
    False, at once

    stSocket (tWinSocket, DualWaitForData), stSocket.Posix (tPosixSocket).

    THE STEPS THAT FAILED ON WINDOWS. tWinSocket.WaitForData read the
    socket handle without taking the socket's lock, armed it with
    WSAEventSelect, and waited on the socket's read event.
    tWinSocket.Close, which does take the lock, closed the handle and then
    that event. So:
      - a WaitForData on a closed socket, or on one never opened, handed
        INVALID_SOCKET to WSAEventSelect, which failed with WSAENOTSOCK
        (10038), and WaitForData raised;
      - a WaitForData that read the handle just before a Close on another
        thread armed a socket that was closed by the time WSAEventSelect
        ran, and raised the same;
      - a WaitForData already waiting had its event closed under it, and
        returned False only when its time was up: a 3 s wait, the socket
        closed 0.3 s in, returned 2.7 s after the Close.
    DualWaitForData armed its two sockets the same way and had all three.
    And tWinSocket.WaitForWrite waited in one select for its whole time,
    on a handle that tWinSocket had made without WSA_FLAG_OVERLAPPED; a
    closesocket on such a handle waits for a select on it on another
    thread to end. So a Close made while another thread's WaitForWrite
    waited - for room to send, on a full send buffer, or on a listening
    socket - took as long as that wait had left, holding the socket's
    lock, and a WaitForData waiting on the same socket, and the
    WaitForWrite itself, returned only then: a WaitForWrite of 3 s, the
    socket closed 0.3 s in, kept the Close 2.7 s. The same closesocket
    waited for a blocking accept on the socket - AcceptHandle on a
    listening socket that WaitForData was never called on - so a Close
    made to stop such an accept loop from another thread waited, holding
    the socket's lock, until a connection came, and the accept then
    returned that connection.

    THE STEPS THAT FAILED ON POSIX (Linux, macOS, iOS, Android).
    tPosixSocket.WaitForData and WaitForWrite tested the socket's
    descriptor, drained the socket's wake pipe, and then read the
    descriptor again to poll it. Close shut the socket down, closed it,
    and then marked it closed. So:
      - a Close on another thread between the two reads left poll a
        descriptor of -1, which poll ignores, and the wait sat out its
        whole time: on Linux, a Close landing as a WaitForData or a
        WaitForWrite of 2 s on a listening socket began kept the wait 2 s
        now and then - in the earlier runs of the test below, for example,
        in one round in 9 to 23;
      - a poll already waiting on a connected socket that the shutdown
        ended was read as the end of the connection: on macOS a WaitForData
        of 3 s, the socket closed 0.3 s in, answered True every time; on
        Linux it answered False, but now and then a wait answered True, or
        found the socket still Connected when it returned;
      - on macOS the shutdown and the close did not end a waiting poll at
        all on a listening socket - the same wait returned 2.7 s after the
        Close - nor on a connected socket whose reader had just taken an
        octet: each such reader waited out its own time. And a close()
        made just as a poll on that socket starts can wait for the poll to
        end, so such a Close itself took that long.

    WHO. A program with a reader that loops Connected -> WaitForData ->
    Receive on a socket while another thread closes it: a relay that
    closes both of its sockets when either side ends, or a pump stopped
    from outside. Testing Connected first does not protect it: the Close
    can come between that test and the wait. On Windows how often it
    raised depends on what woke the reader just before. A Send on a socket
    wakes a reader waiting on that same socket, so a relay that sends on a
    socket and then closes it meets it; a reader that has just taken data
    goes straight back to the arming, and meets it far more often. In four
    runs of the test below, for example, the first raised in 10 to 25 of
    1000 rounds, the second in 356 to 749. A writer that waits for room
    with WaitForWrite (SendAll, TLS and mail transports that pass long
    times) while another thread closes the socket: on Windows that Close,
    and everything waiting for the socket's lock behind it, waited out the
    writer's time. On POSIX it cost time, not a failure, and in the
    library's own components it cost time on Windows too, as far as the
    code shows: the SSH port-forwarding threads, whose socket the
    channel's thread may close, end their loop on any exception anyway;
    and the mail servers' accept loop (StreamSec.Mail.Transport), whose
    Stop closes the listening socket to wake it, sat out the rest of its
    one-second wait on Windows and on macOS, and on Linux when the Close
    came as the wait began.

    NOW, ON WINDOWS, WaitForData arms the socket under its lock: a Close
    that comes first leaves a closed socket, and the answer is False at
    once; one that comes after signals the event the call is about to wait
    on. Close no longer closes the read event but signals it, so a
    WaitForData waiting on the socket returns at once, finds it closed and
    answers False. The event lives as long as the tWinSocket and is closed
    by its destructor; a socket opened again on the same object uses it
    again. DualWaitForData arms each socket the same way and answers -1 at
    once when either of the two is closed, before it waits or while it
    waits: a relay between the two is over. It now also resets each read
    event before arming it, as WaitForData always has; before, an event
    that FD_READ or FD_CLOSE had signalled once stayed signalled, and every
    later call answered for that socket at once, data or not.
    tWinSocket makes its sockets with WSA_FLAG_OVERLAPPED, as socket() does
    (accept passes that on to the sockets it accepts), and on such a
    handle a closesocket ends a select or a blocking accept waiting on it
    at once; the accept returns INVALID_SOCKET. Close marks
    the socket closed and signals the read event first and closes the
    handle last. WaitForWrite selects in slices of 10 ms (or the system
    timer's tick when that is longer, 15.6 ms by default) and reads the
    socket before each, without the lock, so a WaitForWrite that read the
    socket just before a Close, or that waits on a handle made elsewhere
    without WSA_FLAG_OVERLAPPED and given to the constructor, ends within
    a slice of the Close - and on such a handle the Close waits for that
    slice. Measured on Win32, for example: a Close with a WaitForWrite
    waiting took 0.1 ms on average and 0.2 ms at most in 40 rounds, and
    the WaitForWrite was back within 0.2 ms of it; on a handle made
    without WSA_FLAG_OVERLAPPED 5.6 ms and 16.3 ms. A WaitForWrite with
    nothing to wake it costs about 7 ms of processor time per 3 s, about
    0.2% of one core, as QueryThreadCycleTime measures it (GetThreadTimes
    counts whole timer ticks of 15.6 ms, and shows it as one tick or
    none). A Close on another thread ended a blocking accept in 0.3 ms.

    NOW, ON POSIX, WaitForData and WaitForWrite read the descriptor once,
    after draining the wake pipe, and a closed socket answers False at
    once. Close marks the socket closed first, then writes an octet to the
    wake pipe, then shuts the socket down and closes it. A Close that comes
    before the read leaves a closed socket, and the answer is False at
    once. One that comes after it leaves its octet in the pipe, which the
    drain can no longer take, so the poll ends at once, whether it is
    waiting yet or not, and also when the system has given the closed
    descriptor's number to another socket or file meanwhile. The octet
    stays in the pipe while the socket is closed - a wait that drains the
    pipe and finds the socket closed puts it back - so it ends every wait
    on the socket, not only the first to wake. It goes in before the
    close(), which on macOS can wait for a poll that only the octet ends.
    A wait that the shutdown ends finds the socket closed and answers
    False. As before, neither takes the socket's lock to wait: a wait does
    not stand in line behind a writer that holds it. POSIX has no blocking
    accept to end, as before: tPosixSocket makes every socket
    non-blocking, so AcceptHandle answers cInvalidSocket at once when no
    connection is waiting, and an accept loop waits in WaitForData, which
    a Close now ends as above.

    WHY A BEHAVIOUR CHANGE. On Windows, a loop that relied on the
    exception to end on a closed socket - one that tests neither Connected
    nor a stop flag of its own - now goes round instead, as it always did
    on POSIX. On Windows too, test Connected. The library's own loops do.
    On POSIX a wait that a Close ends answers False where it could answer
    True; the Receive that followed a True read 0 from the closed socket.
    On Windows the sockets tWinSocket makes are overlapped now: blocking
    send, recv, connect and accept behave as before, but a Close on
    another thread ends a select or a blocking accept on the socket at once
    instead of waiting for it, and the accept then returns INVALID_SOCKET.
    WaitForWrite no longer waits for a Send in progress on another thread
    before it begins.

    THE DISCRIMINATING TEST: on Windows, Close a socket and then call its
    WaitForData. An affected release raises EstSocketError 10038; this one
    answers False at once. On Windows, with the send buffer of a connected
    socket full, wait 3 s in WaitForWrite and Close the socket on another
    thread 0.3 s in: in an affected release the Close takes 2.7 s, in this
    one it returns at once. On Windows, wait in AcceptHandle on a
    listening socket that WaitForData was never called on, and Close it on
    another thread: in an affected release the Close waits until a
    connection comes, in this one the accept returns INVALID_SOCKET at
    once. On macOS, wait 3 s on a listening socket that another thread
    closes 0.3 s in: an affected release returns 2.7 s after the Close,
    this one at once.

    PLATFORMS. The new SockCloseTest (battery rows Win32, Win64
    and Linux64): a WaitForData of 3 s on another thread, on an
    accepted, a client and a listening socket closed 0.3 s in, must return
    within 1 s of the Close, raise nothing and answer False, and the
    waiting thread must find the socket no longer Connected; WaitForData
    on a closed socket, and on one never opened, must answer False at
    once; 1000 rounds each of a reader looping on WaitForData while its
    socket is closed, right after a Send on it and right after the peer
    sends an octet, must raise nothing; 3000 rounds each of a Close that
    lands as a WaitForData or a WaitForWrite of 2 s on a listening socket
    begins - the wait or the Close a random 0 to 30 us after the other -
    with another socket made at once after the Close, must each end within
    1 s and answer False; a WaitForData and a WaitForWrite parked on the
    same socket - listening; accepted, its send buffer full; on Windows a
    handle made without WSA_FLAG_OVERLAPPED - must both end within 1 s of
    the Close and the Close return within 1 s, and the same in 1000 rounds
    of both beginning as the Close lands; an accept on a listening socket
    closed 0.3 s in - on Windows a blocking AcceptHandle, on POSIX an
    accept loop of WaitForData and AcceptHandle - must return within 1 s
    of the Close, and the Close within 1 s, raise nothing and return no
    connection; and on Windows DualWaitForData the same ways as
    WaitForData, with a control that it waits once the data it answered
    for has been read. Controls: 200 cycles of open, wait, close, reopen
    and free leave the process's handle count (Windows) or descriptor
    count (Linux, macOS) where it was, and a socket closed and opened
    again waits as a new one does. The library before this change fails,
    for example, 29 of the 49 checks on Win32 and on Win64 and 7 of the 39
    on Linux64 (the counts vary from run to run, and each part of steps 7,
    8 and 9 stops after 3 late rounds); on macOS (Apple M1, macOS 26.5,
    not a battery row) it fails steps 1, 7, 8 and 9, but a full run shows
    only step 1: the watchdog stops it in step 3b (or 3a), and steps 7, 8
    and 9 fail in a run that leaves step 3 out. This one passes all 49 on
    Win32 and Win64, and all 39 on Linux64 and on macOS.

    NOT CHANGED: Accept and ReceiveLength on Windows, which still read the
    handle without the lock (Accept so that a blocking accept does not
    hold it), and on a socket closed meanwhile answer INVALID_SOCKET and
    0, as before. GetLocalAddress and GetLocalPort, which read it without
    the lock too and do not look at what getsockname answers: on a closed
    socket what they return means nothing, so ask them while it is open.
    A WaitForData on another thread still waits for a Send in progress to
    finish. A Wake raised while a WaitForWrite is already waiting still
    does not end it on Windows (it ends the next one, as before). On
    POSIX, AcceptHandle, ReceiveLength, GetLocalAddress and GetLocalPort,
    which read the descriptor without the lock: on a socket closed
    meanwhile they answer cInvalidSocket, 0, '' and 0, unless the number
    has been given to another descriptor in between, which they then ask
    instead.


--------------------------------------------------------------------------------
SSH CLIENT: CLOSE FROM ANOTHER THREAD WHILE IT CONNECTS OR LOGS IN
================================================================================


34. BEHAVIOUR CHANGE - Close on a TstSSHSocketClient or TstSSHClient, and
    TsnipClient.Stop, called on another thread while ConnectToHost, Login or
    RequestService runs, cancel that call: the call's own thread sends
    SSH_MSG_DISCONNECT, closes the connection and raises. Close used to
    close the connection itself, under the call, and could free the
    transport while the call still ran on it. And each end reads at most
    1,024 lines before the other's version string

    StreamSec.SSH.Client, StreamSec.SSH.Transport, StreamSec.Snip.Client.

    THE POSITION UNTIL NOW. The SSH client was made to be used from one
    thread until it has logged in. ConnectToHost, Login and RequestService
    use the transport without a lock - there is none until a login makes
    the channel broker - and Close was written on that assumption, which
    entry 78 of the 4.1.4.361 notes states: "Before there is one [a broker],
    no other thread uses the transport, and Close sends the DISCONNECT
    without it." Nothing promised more. TsnipClient.Stop was documented for
    another thread only while Start waits for the server to answer the SSH
    channel open, which comes after the login, and entry 34 of those notes
    says so: a Stop "while Start is still making the SSH connection and
    logging in, before that wait, is not covered by this entry". Before the
    version strings, either end took any number of other lines from its
    peer.

    WHY IT CHANGES. A program that connects on a worker thread and lets the
    user cancel - a Cancel button, a form that closes, TsnipClient.Stop -
    calls Close on another thread during exactly those calls, and a caller
    of TsnipClient.Start cannot see when Start has passed the SSH login. The
    server had the same shape until entry 115 of the 4.1.4.361 notes left a
    client's login to the connection's own thread; this entry does the same
    for the client.

    THE STEP THAT FAILED, for a program that did call Close on another thread
    during one of those calls, was Close itself:
      - it sent SSH_MSG_DISCONNECT and closed the socket from its own thread
        while the connecting thread was inside a read or a send on the same
        connection, and both threads encrypted with the same cipher;
      - it dropped its reference to the transport, which during ConnectToHost
        and RequestService was the only one: the transport was destroyed
        while the connecting thread still ran on it, and written to after its
        destruction (2 to 39 octets of it in the test below);
      - during the TCP connect it dropped the transport too, and once the
        connect was done the server was sent the client's version string
        and then its KEXINIT or Close's DISCONNECT, the connecting thread
        writing to the transport that had been destroyed;
      - a Close after Login had read SSH_MSG_USERAUTH_SUCCESS left Login to
        make the channel broker on a transport that was gone, and Login
        raised EAccessViolation, a read of address 0;
      - a Close while Login was making the broker, whose thread already read
        under the transport's lock, closed the connection without that lock,
        and Login then gave the client a broker of a closed connection, which
        stayed after Close;
      - on Windows, while ConnectToHost waited for the version string of a
        server that had sent nothing yet, the connecting thread was inside
        the socket's read, which holds the socket's lock until data comes:
        Close waited on that lock to send its SSH_MSG_DISCONNECT and close
        the socket - 7.7 s in the test below, until the server gave up -
        and the server never read the DISCONNECT.
    And with no Close at all, a server that sent line after line before its
    version string, faster than the client read them, held ConnectToHost for
    as long as it went on; a client doing so held a server's login past its
    LoginGraceTime, which was looked at only when nothing had arrived.

    NOW, from the start of ConnectToHost, Login or RequestService until it
    returns, the connection is the calling thread's to send on and to close.
    Close on another thread, and so TsnipClient.Stop, cancels the call and
    returns at once without touching the connection; a Close made inside any
    event handler the call runs on its thread (OnServerHelloString, OnSetKey,
    OnDebug, OnSetBanner, OnGetClientPassword or a raw event) cancels it the
    same way. The calling 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 event handler under way returns - or when the call ends; it
    sends the server nothing else, takes the transport off the client, and
    the call raises eSSHOutgoingDisconnect, or what the step under way
    raised. A call cancelled while the TCP connection is being made sends
    nothing at all, not even its version string, the first thing each end
    sends (RFC 4253 section 4.2), and raises eSSHOutgoingDisconnect once the
    connect is over. Login and RequestService make the channel broker as
    the call ends, under a lock of the client's own that Close takes too: a
    cancelled call makes none, and a Close that comes after it closes the
    connection under the transport's lock, as after a Login. The server's
    version string is read only as it arrives: on Windows a
    TstSSHSocketClient's socket waits for data, and ConnectToHost waited
    inside the socket's read for a server that had sent nothing yet, where
    no cancellation could reach it. And at either end, at most 1,024 lines
    other than the version string are read before it; the next ends the
    connection with SSH_MSG_DISCONNECT reason 8 (protocol version not
    supported).
    New for this: iSSHClientCall in StreamSec.SSH.Transport (BeginCall,
    EndCall, CancelCall), which tSSHClientTransport implements and the
    client asks for with Supports.

    WHAT CHANGES FOR A CALLER:
      - A Close on another thread during a call returns before the
        connection is closed. Connected stays True until the call has
        returned; by then the call has raised and SocketClient is closed.
      - A Close while the TCP connection is being made does not cut the
        connect short on Windows, where a TstSSHSocketClient's socket waits
        for it inside the system: ConnectToHost ends when the connect does,
        with eSSHOutgoingDisconnect and nothing sent if it has connected,
        or with the connect's own error when the system gives up. On the
        other platforms the client's first send waits for the connect, and
        a Close ends that wait at once.
      - A Close inside an event handler of a call (OnServerHelloString,
        OnSetKey, OnDebug, OnSetBanner, OnGetClientPassword or a raw event)
        closes the connection once the handler has returned, not inside it.
      - A Login cancelled after the server's USERAUTH_SUCCESS raises
        eSSHOutgoingDisconnect instead of EAccessViolation, and leaves no
        broker.
      - A Close with no call under way, after Login too, takes the transport
        off the client before it sends the DISCONNECT rather than after:
        Connected reads False while the DISCONNECT goes out, in OnRawSend
        and OnRawClose handlers too.
      - On Windows, a TstSSHSocketClient whose server takes the connection
        and sends nothing gives up after 30,000 looks - about 8 minutes at
        the default timer resolution - with SSH_MSG_DISCONNECT reason 8
        (protocol version not supported), as the client on the other
        platforms always did, and as a server does when its LoginGraceTime
        has not ended the login first; before, its ConnectToHost waited
        for as long as the connection stayed open. Meanwhile it looks for
        the version string between sleeps of 1 ms, which on Windows last
        to the timer's next tick (about 16 ms by default), so a version
        string that has to be waited for is read up to that much later.
      - A peer that sends more than 1,024 lines before its version string
        is disconnected with reason 8 - by a client, and ConnectToHost
        raises eSSHOutgoingDisconnect; by a server, which ends that login.
        RFC 4253 section 4.2 lets a server send such lines, and sets no
        number.

    WHO. Every program that calls Close on a TstSSHSocketClient or
    TstSSHClient, or Stop on a TsnipClient, on another thread while the
    client connects or logs in, on every platform. On one thread: a program
    that calls Close inside an event handler that ConnectToHost, Login or
    RequestService runs (OnServerHelloString, OnSetKey, OnDebug, OnSetBanner,
    OnGetClientPassword or a raw event), and one that reads Connected
    inside an OnRawSend or OnRawClose handler while Close runs, also after
    Login. And a program whose peer does not keep to the version exchange:
    a TstSSHSocketClient on Windows whose server never sends its version
    string, and a client or server whose peer sends more than 1,024 lines
    before it. A program that connects, logs in and closes on one thread,
    outside those handlers, sees no other change than that of the read of
    the version string on Windows.

    THE DISCRIMINATING TEST: wrap the client's raw events (override
    InitTransport), hold the connecting thread inside OnSetKey and call Close
    on another thread. In an affected release Close sends SSH_MSG_DISCONNECT
    from its own thread while ConnectToHost runs, and the transport is
    destroyed while ConnectToHost still runs on it and then written to; in
    this one Close makes no raw call, the connecting thread sends the
    DISCONNECT, reason 11, once OnSetKey returns and nothing else, the
    server reads it, and ConnectToHost raises eSSHOutgoingDisconnect.

    PLATFORMS. New test SshClientConnectCloseTest (battery rows Win32, Win64
    and Linux64, floor 208) records which thread makes each raw call on the
    client's connection and what the connecting thread sends after the
    Close, sees the transport destroyed (keeping it, and a copy of its
    memory, until the step ends) and sees what the server reads. It holds
    the connecting thread inside its first read, OnSetKey and its NEWKEYS
    (steps 2 to 4), OnGetClientPassword, the read of the answer to its
    password request, the send of that request and after the read of
    USERAUTH_SUCCESS (5 to 8), the wait of RequestService (13), the
    construction of the broker (14), RawConnect before the TCP connect (19)
    and OnServerHelloString while the server goes on sending lines before
    its version string (21). TsnipClient.Stop is called while Start is in
    OnSetKey (9) and after its Login has read USERAUTH_SUCCESS (15); in
    step 16 the server's answer comes one octet every 100 ms, in 17 OnSetKey
    calls Close itself, in 18 the server takes the connection and sends
    nothing, in 20 the listener's accept queue is full and the connect does
    not complete, and in 22, with no Close, the server sends 4,096 lines
    before its version string; step 1, a Close after the login, is the
    control. With the code of 4.1.4.361, which these three units still had,
    66 of the 208 checks fail in every run on all three platforms (three
    runs on each): Close's raw calls come during the call in steps 2 to 9,
    13, 15, 16, 18 and 21 and overlap the connecting thread's in 2, 4, 6,
    7, 8, 13 and 15, and the connecting thread sends no DISCONNECT after the
    Close there; in 19 and 20 the server reads the client's version string
    and more; the transport is destroyed under the call in 2, 3, 4, 9, 13,
    17, 19 and 21; the call ends with an exception other than
    eSSHOutgoingDisconnect in steps 2 to 9, 13, 15 to 19 and 21 - Login's
    with EAccessViolation in 8 and 15 - and step 22's ConnectToHost takes
    all 4,096 lines and ends 5 s later, with reason 10; a broker is left
    after Close in 14. Seven more fail in every run on
    Windows: in step 18 Close waits 7.7 s, its raw calls overlap the
    connecting thread's and the server reads no DISCONNECT, the server
    reads none in steps 2 and 16 either, and in step 20 the version string
    goes out and the transport is destroyed. Four more on Linux64: in step
    20 Close's raw calls come during the connect, overlapping, and the call
    ends with eSSHTransportRawError; in 18 the transport is destroyed. Some
    runs fail one or two more (an overlap in step 14, the transport
    destroyed in 18 on Windows and in 20 on Linux64, no DISCONNECT read in
    step 6): in all, 74 or 75 of the 208 fail on Win32 (exit 217 at
    shutdown) and on Win64, and 70 or 71 on Linux64. With this change, 208
    of 208 on all three in every run (three on each). Entry 33 changes how
    a Close on another thread ends a wait on a socket; during a call this
    Close makes no raw call at all (the test checks it), and with 33 in as
    well, 208 of 208 on Win32, Win64 and Linux64 (one run each). Single-change
    mutants, run twice each on Win32 (the two of the TCP connect on Linux64
    too): Close ending the call and closing the
    connection itself fails 59 checks; a broker made after a cancel fails
    steps 8 and 15 (a broker left after Close); a wait without the look at
    the cancellation fails step 16 (the call ends 4.5 s after Close, when
    the packet is complete, instead of at once); the version string read
    with the socket's own read again fails step 18 (the call ends 7.7 s
    after Close, when the server gives up, and sends no DISCONNECT); a
    cancelled call that returned closed without its DISCONNECT fails steps
    4, 8 and 15 (no packet after the Close, and the server reads no
    DISCONNECT); Send not looking at a client's cancellation fails step 5
    (the password request goes out after the Close and the server checks
    it); no look at the cancellation once RawConnect has returned fails
    steps 19 and 20 on Win32 and step 19 on Linux64 (the version string
    and a DISCONNECT go out after the Close, and the server reads them);
    the version string's send waiting for the connect without that look
    passes on Win32, whose connect waits inside the system, and fails step
    20 on Linux64 (the call ends 0.7 s after Close, when the connect
    completes at the next SYN, and the version string and a DISCONNECT go
    out); ReadPeerVersion looking at the cancellation only when nothing
    has arrived fails step 21 (the client takes 1,023 more lines after the
    Close and ends with reason 8); no limit on those lines fails step 22
    (all 4,096 lines, and reason 10 5.7 s later); a client's call that
    waits as a server's login does, with no 5 s limit, passes this test
    and fails step 5 of SshKexGuessWaitTest (no packet after the server's
    KEXINIT: the client had not given up when that test's server closed
    the connection, 12.1 s later, and sent no SSH_MSG_DISCONNECT reason
    10), which passes, 22 of 22, with this change.
    SshLoginGraceTest has a new step 17 (floor 60): with LoginGraceTime
    3000 a raw client sends line after line before its version string,
    and the server must close the connection within 4.5 s of the connect.
    With the code of 4.1.4.361 the server still holds it after 15 s on all
    three platforms (one run on each), 160,000 to 200,000 lines on, and so
    it does on Win32 with neither the limit on the lines nor the look at
    the grace time with every octet (two runs); with this change it closes
    the connection 0.2 s after the connect, and the test passes, 60 of 60,
    on all three.

    NOT CHANGED:

    - Freeing the client while a call runs on another thread is not
      supported, before or now: the call would go on with a client that
      has been freed. Close it, and let the call return, first.
    - A Close on the connecting thread outside an event handler, and a Close
      after Login has returned, close the connection at once as before -
      under the transport's lock when there is a broker.
    - A Close does not stop a call that begins after it. One that comes
      before ConnectToHost has made its transport - also in the moment just
      after ConnectToHost was called - finds no connection, as before, and
      ConnectToHost then connects; a TsnipClient.Stop before Start has begun
      to connect does not stop Start. One that comes between two calls
      closes the connection itself, and the next call finds none: a Stop
      between Start's ConnectToHost and its Login makes Start raise
      eSSHClientChannelError. A program that cancels from another thread
      keeps its own flag for that, as it had to before.
    - CreateChannel, GlobalRequest and AddListener on one thread and Close
      on another are not covered, before or now: those use the channel
      broker that Close stops and frees. So neither is a TsnipClient.Stop
      in the moment between Start's login and its wait for the channel
      open, nor one during the Snif login after that wait.
    - A send that waits for room in a full send buffer still waits for up
      to SendTimeout (entry 36 of the 4.1.4.361 notes). A Close during a
      call that is inside such a send cancels the call, which ends when the
      send does. Closing SocketClient ends that wait at once off Windows,
      and on Windows once WaitForData has been called on SocketClient; a
      Windows socket that waits inside the system's own send waits without
      a limit, and a Close of SocketClient waits for it, as before.


--------------------------------------------------------------------------------
SOCKETS AND MAIL: AN APPLICATION-CHOSEN OUTBOUND SOURCE ADDRESS
================================================================================

35. NEW - tAbstractSocket.Open(address,port,sourceIP) binds the local source
    address before connecting, with an OS-assigned ephemeral port. The original
    two-argument Open is unchanged. Empty sourceIP keeps automatic selection.
    A source must be an ASCII IP literal of the destination's family, and must
    be a local address. Endpoint syntax (including a zero port) and embedded NUL
    are refused. Failure raises and closes the socket; it never retries
    unbound. Windows supports IPv4 and IPv6; the POSIX transport remains IPv4.

    TsmCustomTLSClient.SourceIP exposes it to the TLS client components,
    including SMTP. It cannot change while connecting or connected.
    tSmtpMxAgent.SourceIP applies it to every MX attempt;
    tSmtpSmarthostAgent.SourceIP applies it to both delivery and Probe;
    TsmCustomSMTPServer.SmarthostSourceIP exposes the built-in agent's setting.
    Set a custom DeliveryAgent's own SourceIP when using one.

    Existing tAbstractSocket descendants need not implement the new overload:
    the base delegates an empty source to their original Open, and refuses a
    non-empty one instead of silently ignoring it. Rebuild dependent packages.

    SocketBindTest checks the peer-observed source on distinct loopback
    addresses, default and legacy calls, invalid/nonlocal sources, family
    mismatch, no unbound retry and reuse after failure. SmtpSourceBindTest
    checks it through SMTP client, MX, smarthost delivery and Probe, and checks
    SourceIP mutation and component streaming.

36. NEW - an SMTP application with an OnMessage handler may start without a
    spool or local mailbox. Its handler owns the delivery decision and SMTP
    acknowledgement. An onward message without a spool still defaults to
    refusal; merely attaching a handler does not make it accepted. A deployment
    with no handler, spool or local delivery still refuses to start.


--------------------------------------------------------------------------------
OUTBOUND TLS, HTTP AND DNS: ABSOLUTE DEADLINES
================================================================================

37. NEW - Absolute outbound TLS/HTTP deadlines and bounded name resolution

    TsmCustomTLSClient.DeadlineTick sets one absolute monotonic deadline
    (stTlsUtils.GetTickCount64) across TCP connect, TLS handshake and later
    reads and writes, including buffered reads and partial sends. Zero keeps
    the existing behaviour. With a deadline the socket remains non-blocking;
    drip-fed progress cannot extend the operation. Raw TLS users requiring a
    bound across name resolution supply a pre-resolved Host literal and keep
    the certificate hostname in ServerName; the deadline is checked after
    lookup.

    The four-argument tAbstractSocket.Open adds a connect timeout in
    milliseconds and preserves source binding. Its base implementation refuses a
    finite timeout on an older descendant rather than claiming a bound it cannot
    enforce. Zero delegates to the existing overload. A bind failure still
    raises if a historical Windows socket-error callback logs and returns.

    tHttpClient.RequestTimeout and DeadlineTick additionally bound the HTTP
    request's name-resolution wait. With DnsServers empty, resolution uses the
    operating system, including its hosts file, through LookupHostWithin.
    HostResolver optionally replaces the resolver on the same bounded worker
    path; SourceIP selects the family. Address literals bypass DNS. A lookup
    failure reports the host, lookup step and native error, without retrying
    through the socket's unbounded lookup path. Explicit DnsServers uses only
    those literal server addresses over TCP, without system-resolver fallback.
    Invalid server entries are refused. Requests without a deadline retain
    their existing name-resolution behaviour.

    LookupHostWithin includes worker creation in the budget, checks cancellation
    in short slices, and limits all live native workers to 32, including work
    abandoned by a caller. A caller may stop waiting, but native resolution
    itself cannot be forcibly stopped. Worker data retains no client or socket
    references; native threads are reaped before their slots are reused.

    Windows DLL/package and Linux shared-library hosts stop issuing requests,
    call ShutdownHostLookups outside initialization/finalization and resolver
    callbacks, and join their own callers before unloading. True permits unload;
    False keeps admission closed and ownership intact, so the module must remain
    loaded and shutdown can be retried. Zero performs a nonblocking poll.
    Resolver callback modules must remain loaded too. Subsequent lookups return
    hlrStopped; the HTTP deadline path reports the stopped service. Finalization
    does not block under the Windows loader lock. Executable finalization gives
    pending work at most 20 seconds. Other POSIX targets conservatively refuse
    the unload barrier after admitting a lookup. HostLookupShutdown.txt
    documents integration.

    An exception from tSmtpMxAgent.OnConfigure is a transient failure of that
    host, allowing the next MX to be tried. SocketBindTest, SmtpSourceBindTest
    and the native lookup/shutdown harnesses cover source binding, deadline and
    cancellation boundaries, admission, native-thread cleanup and actual
    unload/reload cycles.

38. NEW - tDnsTcpResolver.DeadlineTick bounds TCP connect, query writes and
    reply reads by one absolute stTlsUtils.GetTickCount64 deadline. A resolver
    streaming a few bytes cannot keep a direct delivery alive indefinitely.
    Zero retains the old per-progress timeouts. Configure it while idle;
    deadline-bound servers must be address literals so no unbounded platform
    hostname lookup can escape the limit. Expiry is a temporary DNS failure.

    DnsDeadlineTest uses loopback TCP responses to cover normal delivery,
    slow progress, zero-deadline compatibility and refusal before connecting.


39. FIXED - an SMTP peer that sent an oversized reply without a newline could
    make the TLS client's line buffer grow without reaching SMTP's reply-line
    size check. ReadLine(out line,timeout,maxBytes) now refuses an accumulated
    first line over that bound, before a newline arrives. CRLF is excluded;
    later buffered lines do not count against a short first line. SMTP passes
    cSMTPMaxReplyLine to this overload. The original ReadLine overload still
    delegates with zero/unlimited, preserving existing consumers' behaviour.

    SmtpSourceBindTest checks an unterminated oversized SMTP greeting, a short
    first line followed by an oversized buffered tail, and CRLF at exactly the
    permitted length. The SMTP Open failure tears down the transport.

40. FIXED - the HTTP/1.1 client now enforces header and body limits while
    receiving, streams framed body bytes without retaining encoded chunks,
    bounds chunk size lines and trailers, and handles a coalesced header and
    body without counting body bytes against HeaderBytes. The shared chunk
    parser keeps one-shot and persistent framing aligned.

    HttpsH11LimitsTest exercises raw-wire responses without TLS fixtures and
    covers the incremental bounds and coalesced data on Win32 and Win64.


41. FIXED - tWinSocket.Accept(nil), used by AcceptHandle, supplied a 16-byte
    IPv4 address buffer to accept even for an IPv6 peer. Winsock refused the
    connection because that peer address needs a larger buffer. Accept now
    omits the address output when no caller requested it. The existing non-nil
    caller buffer contract and accepted-socket event cleanup are unchanged.

    SocketBindTest exercises IPv6 AcceptHandle through both ordinary and timed
    source-bound connections on Windows.

42. NEW - TsmAcmeClient exposes its HTTP client and supports Cancel/ResetCancel.
    Authorization/order polling uses an absolute monotonic PollTimeout and an
    interruptible wait, including long Retry-After responses. Cancellation also
    reaches an in-flight HTTP request rather than waiting for its idle timeout.

    tHttpClient adds RequestTimeout for a total DNS/connect/TLS/HTTP/redirect
    budget, DeadlineTick for a caller's shared absolute budget,
    Cancel/ResetCancel, an optional explicit TLSServer, SourceIP and
    configurable DNS server literals. Defaults preserve existing callers.
    Bounded requests resolve names within the deadline as entry 37 describes
    and use finite connect timeouts; no unbounded platform hostname lookup
    escapes the deadline. Configure these properties while no request is
    running.

    FIXED - issued-certificate persistence retains the live PFX until the new
    file is atomically replaced. Archiving copies the predecessor rather than
    removing it before the replacement.

    AcmeHttpDeadlineTest exercises cancellation, Retry-After, shared polling
    deadlines, slow HTTP responses, source binding and certificate persistence.


--------------------------------------------------------------------------------
SNIP OVER TLS: FREEING A CLIENT THAT IS STILL CONNECTED
================================================================================


43. FIXED - freeing a TsnipTLSClient that was still connected, without
    calling Stop first, used the connection's TLS layer after the client had
    freed it: depending on what the program had done since connecting,
    nothing showed, or Free raised an access violation executing a garbage
    address

    StreamSec.Snip.TLSClient. TsnipTLSClient creates and owns the
    TsmSimpleTLSInternalServer its connection runs on, and the connection's
    TLS content layer belongs to that engine. THE STEP THAT FAILED is the
    ORDER of the teardown in Free. The client's destructor did not stop the
    connection, so the inherited TComponent.Destroy freed the engine first -
    it is a child component - and the engine released the layer with it.
    Only after that did the client release the connection, the last thing
    holding it, and the connection's destructor closed itself the usual way:
    it asked the layer whether it was still active, encoded a close_notify
    through it and released it - three uses of a freed object. The same
    happens when the client is freed by its Owner, such as the form it was
    dropped on, while it is connected. Every release since TsnipTLSClient
    came, in 4.1.2.355, tore down in this order.

    What that did depended on what had become of the freed memory, which is
    why it came and went. Freed memory that still reads back as it was gives
    no sign. When it had been reused - a few remote calls between connecting
    and freeing were enough - sending the close raised an access violation,
    which the connection's Close swallows, so neither the snip close nor the
    socket close happened, and releasing the layer then called through a
    pointer that was no longer there: "Access violation ... Execution of
    address 00000000FFFFFFFF" was seen, out of Free. Calling Stop before
    Free avoided all of it in every release, because Stop closes the
    connection while the engine is still alive. The TLS handshake, the KAPA
    login, the server and the calls made on the connection were not
    involved; only freeing a connected client without Stop.

    Now TsnipCustomTLSClient.Destroy stops a live connection first, before
    anything is freed, and never raises from it. Both tiers do it: for
    TsnipAdvancedTLSClient, whose engine is the application's and normally
    outlives the client, this is the close its connection's destructor made
    anyway, made earlier.

    HOW IT WAS TESTED. The new SnipClientFreeTest connects each
    client to a server in the same process, logs in with KAPA and
    frees it without Stop, with the connection made on guarded memory
    pages, where a freed block cannot be read. Without the fix freeing a
    TsnipTLSClient raised EAccessViolation every time - connected only,
    logged in, and freed through its Owner - and the server never saw the
    connection end: 34 of its 40 checks on Win32, Win64 and Linux64. With
    it, 40 of 40.

    NOT CHANGED. A TsnipAdvancedTLSClient whose engine is freed while it is
    still connected loses its layer with the engine, before it can do
    anything about it: stop the client first, as the TLSServer property
    says. TsnipClient, the snip client over SSH, was not affected - its SSH
    client is freed after the connection is closed - and is tested beside
    the TLS clients.


--------------------------------------------------------------------------------
SSH: LINES BEFORE THE PEER'S VERSION STRING
================================================================================


44. FIXED, BEHAVIOUR CHANGE - an SSH client failed to connect to a server
    that sent a line before its version string, as RFC 4253 allows, when
    the version string came even a moment after that line: it took '' for
    the server's version string and read the version string as the start
    of a packet. A server failed the same way with a client that sent such
    a line. A server that sends lines and then nothing is now waited for as
    one that sends nothing at all

    StreamSec.SSH.Transport.

    RFC 4253 section 4.2: "The server MAY send other lines of data before
    sending the version string." Such lines must not begin with "SSH-".
    Both ends read the other's version string with
    tSSHTransport.ReadPeerVersion, which takes such lines from a client as
    well and hands each one to the component - on a client, to
    OnServerHelloString. Every release from 4.1.1.349, the first with
    StreamSec.SSH.Transport, to 4.1.4.361 has it.

    THE STEP THAT FAILED is the read after such a line. ReadPeerVersion went
    on to the next line only when more had arrived already; when the socket
    was empty, it returned at once with '' as the peer's version string. The
    connection then went on to the peer's SSH_MSG_KEXINIT, and what came
    next - the version string, or the next line - was read as a binary
    packet, its first four octets as the packet's length ("SSH-" gives
    0x5353482D). Whether a connection worked depended on timing alone: a
    line that arrived together with the version string worked; a version
    string that came after the line in a send of its own, in a TCP segment
    of its own, or after the reader had caught up with the sender, did not.
    A server that writes a banner and its version string in two writes
    fails some of the time, and one that writes the banner, pauses and then
    writes the version string fails every time.

    WHAT IT LOOKED LIKE, the same on Win32, Win64 and Linux64:
    - TstSSHSocketClient.ConnectToHost raised eInternalRecvError ("An error
      occured while decoding an inbound packet") when a line was followed
      200 ms later by the version string, and ERangeError ("Range check
      error"; on Win32 also in a build with range and overflow checks off)
      when it was followed by another line. OnServerHelloString had been
      called with the first line only, and the client sent the server no
      SSH_MSG_DISCONNECT.
    - A version string that has to be refused, such as "SSH-1.5-...", sent
      after the pause was read as a packet the same way: eInternalRecvError
      instead of SSH_MSG_DISCONNECT reason 8 (protocol version not
      supported) and eSSHOutgoingDisconnect.
    - A TstSSHSocketServer ended such a connection without
      SSH_MSG_DISCONNECT, and its client saw eSSHConnectionLost. Sent a line
      every 250 ms and no version string, with LoginGraceTime 3000, it
      ended the connection 0.25 to 0.29 s after the connect, with no
      DISCONNECT, instead of at LoginGraceTime with reason 10.

    NOW ReadPeerVersion reads line after line until the version string
    comes, whether anything more has arrived after a line or not. It ends
    without one where it ends for a peer that has sent no line at all
    (entry 34): with SSH_MSG_DISCONNECT reason 8 when the wait for the next
    line runs out of looks or a 1,025th line comes, with eSSHConnectionLost
    when the peer closes or resets the connection, on a server at
    LoginGraceTime (reason 10), and on a client when Close cancels the call
    (reason 11).

    WHY A BEHAVIOUR CHANGE. A client whose server sent one or more lines and
    then nothing at all, not even its version string, gave up 5.0 to 5.8 s
    after the last line in the test, with SSH_MSG_DISCONNECT reason 10
    (connection lost). That was no design: it was the wait for the server's
    SSH_MSG_KEXINIT that followed the empty version string. Such a server is
    now waited for as one that sends nothing at all is (entry 34): until it
    closes the connection, or for 30,000 looks - about 8 minutes on Windows
    at the default timer resolution, at least 30 s elsewhere - and then
    reason 8. A TstSSHSocketServer ends the login of a client that sends
    lines and no version string at LoginGraceTime, with reason 10 (step 10
    below).

    WHO. Every SSH client of this library - TstSSHClient,
    TstSSHSocketClient and TsnipClient - that connects to a server that
    sends lines before its version string, such as a banner, in writes of
    their own; and TstSSHServer and TstSSHSocketServer with clients that do
    so, which RFC 4253 does not provide for. It ends in a failed connection
    and nothing more: the misread comes before the key exchange, and only
    the peer the connection is with can cause it.

    THE DISCRIMINATING TEST: have a server send one line, wait 200 ms and
    then send its version string, and connect to it with ConnectToHost. An
    affected release raises eInternalRecvError after calling
    OnServerHelloString with the line; this one connects. The same line in
    the same send as the version string connects with both, so a test that
    sends them together cannot tell them apart.

    PLATFORMS. New test SshPeerVersionLinesTest (battery rows
    Win32, Win64 and Linux64, floor 55; ports the system assigns on
    127.0.0.1). A TstSSHSocketClient connects to a TstSSHSocketServer
    through a relay that puts lines in front of one end's version string:
    none (step 1), one in the same send (step 2), one and 200 ms (step 3),
    three with 200 ms after each (step 4), 50 sends 10 ms apart (step 5),
    and one and 200 ms in front of the client's (step 6); both ends must
    connect and log in, read each other's version string and be given the
    lines. A raw server and a raw client send a line, 200 ms and
    "SSH-1.5-..." (steps 7 and 8: SSH_MSG_DISCONNECT reason 8 from either
    end); a raw server a line, 200 ms and an orderly close (step 9), a reset
    (step 11), or 8 s of nothing and an orderly close (step 12) -
    ConnectToHost must raise eSSHConnectionLost after the close and within
    2 s of it; a raw client a line every 250 ms for 2 s to a server with
    LoginGraceTime 3000 (step 10: reason 10, 2.5 to 4.5 s after the
    connect). Before this change, on main with entry 34, 21 of the 55
    checks fail on Win32, Win64 and Linux64, the same checks on each, in
    steps 3 to 8, 10 and 12; with it, 55 of 55 on each. Steps 1, 2, 9 and
    11 pass either way. Without entry 34 (main d06ba1d) the same checks of
    steps 1 to 10 fail, 19 of their 49. Step 11 needs entry 34 as well: with
    this entry and without 34, a Windows client that waited for the next
    line inside a socket read raised EstSocketError (10054) at the reset.

    NOT CHANGED:
    - Lines and a version string that arrive together are read as before,
      and a server still takes lines from a client as from a server.
    - A version string other than SSH-2.0- or SSH-1.99- is refused with
      SSH_MSG_DISCONNECT reason 8, as before; steps 7 and 8 check it after
      a line and a pause.
    - Where the lines go: a client's OnServerHelloString, and on a server
      nowhere unless a descendant overrides ServerHelloString.


--------------------------------------------------------------------------------
HTTPS PLUGINS: A REQUEST BODY OVER THE LIMIT
================================================================================

TsmHTTPSv1dot1 and TsmHTTPSv2 refuse a request body over their Limits:
BodyBytes for the body of one request, ConnBodyBytes for the bodies on one
HTTP/2 connection, and TotalBodyBytes for the bodies across the server. The
two entries below are about how an HTTP/2 client learns that its upload was
refused, and how the server learns it.


45. FIXED, BEHAVIOUR CHANGE - an HTTP/2 upload whose content-length was over
    Limits.BodyBytes, or over Limits.ConnBodyBytes, was taken in up to the
    limit and then reset, with no response: the client could report nothing
    but a dropped upload, and the server logged nothing. It is now answered
    413 at once, before any of the body is taken in

    StreamSec.Http.Http2Conn, StreamSec.Mobile.HTTPS.

    THE STEP THAT FAILED is where tHttp2Conn holds a request body against
    its caps, MaxBodyBytes and MaxConnBodyBytes, which TsmHTTPSv2 sets from
    Limits.BodyBytes and Limits.ConnBodyBytes. It did so only as DATA frames
    arrived, and never looked at the content-length in the request's
    HEADERS. A request that declared a body over the limit was accepted, its
    body read up to the limit, and its stream then reset with
    RST_STREAM(ENHANCE_YOUR_CALM). No response was sent, so the client had
    nothing to show but a failed upload, after sending the limit's worth of
    the body for nothing, and nothing on the server reported it (entry 46).
    Seen with a browser uploading 60 MB, content-length 62,915,565, against
    a limit of 50 MB: reset after exactly 52,428,800 octets, no response.
    HTTP/1.1 answered the same request 413 as soon as its head had arrived,
    and still does. Every release with HTTP/2, from 4.1.2.355 to 4.1.4.361,
    has it. The limits themselves, TLS, flow control and the request handler
    were not involved: a body under the limit was served whole before and
    is now.

    NOW tHttp2Conn reads the content-length at the end of the request's
    header block - after any CONTINUATION frames - and when it is over
    MaxBodyBytes or MaxConnBodyBytes it answers at once: a response with
    status 413 and END_STREAM, so the response is complete, and then
    RST_STREAM with NO_ERROR, which tells the client to stop sending without
    calling it an error. RFC 9113 section 8.1: "A server can send a complete
    response prior to the client sending an entire request if the response
    does not depend on any portion of the request that has not been sent and
    received. When this is true, a server MAY request that the client abort
    transmission of a request without error by sending a RST_STREAM with an
    error code of NO_ERROR after sending a complete response (i.e., a frame
    with the END_STREAM flag set). Clients MUST NOT discard responses as a
    result of receiving such a RST_STREAM".
      - A request whose HEADERS already ended its side gets the 413 and no
        reset: the 413 closes its stream, and section 5.1 says "An endpoint
        MUST NOT send frames other than PRIORITY on a closed stream." Such a
        request used to reach the handler with an empty body.
      - The DATA the client had sent before the 413 reached it is discarded
        but counted back to the connection's flow-control window. Section
        5.4.2: the endpoint that resets "MUST be prepared to receive any
        frames that were sent or enqueued for sending by the remote peer.
        These frames can be ignored, except where they modify connection
        state (such as the state maintained for field section compression
        (Section 4.3) or flow control)."
      - The connection carries on: the 413 is for that request alone.
      - ConnBodyBytes is held against the declared length as well, because a
        body over it could never be taken on the connection; when the length
        is over both, the lower bound is the one reported. TotalBodyBytes is
        not: it is shared by every connection, and a body that does not fit
        it now may fit a moment later.
      - A content-length that is not a run of digits is not read, and leaves
        the request to the limit on DATA, as before (entry 49 then resets
        the request when it ends: it is malformed). One too long for a
        64-bit integer is over every limit.

    WHY A BEHAVIOUR CHANGE. Such a request is answered 413, where its stream
    used to be reset part-way, and one whose HEADERS ended the request is
    no longer passed to the handler. Neither depends on the defaults alone:
    with them (8 MiB for both bounds), any HTTP/2 request declaring more
    than 8 MiB is now answered 413 before its body.

    WHO. Every program that takes uploads over HTTP/2 with TsmHTTPSv2, or
    with tHttp2Conn directly, from clients that send a content-length -
    browsers do for a form or file upload - larger than Limits.BodyBytes or
    Limits.ConnBodyBytes.

    THE DISCRIMINATING TEST: send an HTTP/2 POST whose content-length is
    over Limits.BodyBytes and see what comes back before the body is sent.
    An affected release sends nothing until BodyBytes octets have arrived and
    then resets the stream with ENHANCE_YOUR_CALM (11); this one answers 413
    at once and resets with NO_ERROR (0). A POST without a content-length is
    reset the same way by both, so it cannot tell them apart.

    HOW IT WAS TESTED. New BodyRefusalTest (battery rows Win32,
    Win64 and Linux64, floor 153) drives tHttp2Conn with hand-built frames,
    and TsmHTTPSv2 and TsmHTTPSv1dot1 through a transport that is only a
    buffer: a content-length over BodyBytes, over ConnBodyBytes, in a
    CONTINUATION, too long for 64 bits, and on HEADERS that end the request;
    the DATA already sent after the 413, the next request on the connection
    and the client's HPACK table; and as controls a length exactly at the
    limit, limits of 0, and content-lengths that are not digits (abc, -5,
    1e9). On main a4aa00d, before this entry, 16 of the 61 checks it can
    make there fail on Win32, Win64 and Linux64 - the same checks on each;
    with entries 45 and 46, 153 of 153 on each. A new script drives the
    new BodyRefusalServer, with a limit of 1 MiB, with Node 24's http2
    and https clients, which are not this library. Before: a
    3 MiB upload with its content-length got no response, and
    RST_STREAM(ENHANCE_YOUR_CALM) after the client had sent 1,097,728
    octets - the limit and three frames in flight - just as one without a
    content-length; 7 of the 14 checks failed on Win32, Win64 and Linux64,
    three on that upload and the four on what the server reported (entry
    46). Now it gets 413 and then RST_STREAM(NO_ERROR) after sending 49,152
    octets, and the connection serves the next request: 14 of 14 on each.

    NOT CHANGED:
    - A body without a content-length, or longer than the one it declared,
      is still stopped when it reaches BodyBytes, with
      RST_STREAM(ENHANCE_YOUR_CALM) and no response - there is nothing to
      answer it from in advance - as is one that reaches ConnBodyBytes with
      other bodies on the connection, or the server-wide TotalBodyBytes.
      Entry 46 reports these too. (Entry 49 resets a body longer than its
      content-length as soon as it passes it, unless the frame that does so
      also reaches the limit.)
    - HTTP/1.1, which already answered 413 from the head.
    - A content-length that disagrees with the DATA that follows is not
      checked (RFC 9113 section 8.1.1 calls such a request malformed); only
      the limits are. Entry 49 checks it.
    - A HEADERS frame - trailers - on a stream after it was refused or
      reset still ends the connection with PROTOCOL_ERROR, where section 5.1
      asks for it to be decoded and discarded. Browsers send no trailers
      with an upload. Entry 48 decodes and drops it.


46. NEW - OnBodyRefused on TsmHTTPSv1dot1 and TsmHTTPSv2, and on tHttp2Conn,
    reports every request body a limit refused, with the peer, the request,
    the declared size and the limit

    StreamSec.Http.Server, StreamSec.Http.Http2Conn, StreamSec.Mobile.HTTPS.
    A refused body left no trace on the server. The protocol components
    answered 413 or 503, or reset the stream, and told no one; the request
    never reached a handler, so the application could not log it either.
    OnBodyRefused fires once per refusal, on either wire, after the answer
    is on its way:
      - a Content-Length over BodyBytes: 413, on HTTP/1.1 followed by the
        close, on HTTP/2 by RST_STREAM(NO_ERROR) (entry 45); on HTTP/2 also
        one over ConnBodyBytes;
      - on HTTP/1.1, a Content-Length that TotalBodyBytes has no room for:
        503;
      - on HTTP/2, a body that reaches BodyBytes, ConnBodyBytes or
        TotalBodyBytes as it arrives: the stream reset with
        ENHANCE_YOUR_CALM, and Status 0.
    Its tHttpBodyRefusal (StreamSec.Http.Server) gives the peer
    (RemoteAddress), the wire (Protocol, 'h2' or 'http/1.1'), Method and
    Path - taken from a request head that has not been validated in full
    yet, so every control character in them is replaced by '?', and a log
    line written from them stays one line - the HTTP/2 StreamID, which
    bound refused (Limit: hblBodyBytes, hblConnBodyBytes or
    hblTotalBodyBytes) and its value (LimitBytes), the content-length
    (Declared, -1 when there was none), the body octets taken in before the
    refusal (Received), and the status answered (Status).
    It is a notification: nothing the handler does changes the answer, and
    an exception it raises is dropped. It runs on the I/O thread that read
    the request, with the connection's gate held: log and return. On
    tHttp2Conn, for a program that drives the engine itself, Sender is the
    engine and LimitBytes is 0 for hblTotalBodyBytes, a figure only the
    component holds. Tested by BodyRefusalTest on both components and the
    engine, and by the REFUSED lines BodyRefusalServer prints from it, which
    the script that drives it checks (entry 45).

    NOT CHANGED. The other refusals of the HTTP/1.1 plugin - 431 for a
    header block over HeaderBytes, 400, 501 and 505 for a head it will not
    parse - are not about a body and are not reported here.


--------------------------------------------------------------------------------
SMTP SERVER: THE RECEIVED STAMP OF AN AUTHENTICATED SUBMISSION
================================================================================


47. FIXED - TsmSMTPServer stamped a message submitted after a successful
    AUTH "with ESMTPS" in its Received header, not "with ESMTPSA"; a
    message whose sender a client certificate vouched for was stamped the
    same way. Over a connection without TLS, "with ESMTP" was written for
    "with ESMTPA"

    StreamSec.Mail.SMTPEngine.

    RFC 3848 registers a keyword for each of the four ways a message can
    arrive - ESMTP, ESMTPA, ESMTPS and ESMTPSA - so that the trace says how
    it was received. The authentication itself was enforced as before, and
    OnMessage, the spool and the envelope's Authenticated and AuthUser
    recorded it correctly; only the Received header was wrong. Every release
    from 4.1.2.355, the first with StreamSec.Mail.SMTPServer, to 4.1.4.361
    has it.

    THE STEP THAT FAILED is the stamp, built at DATA from the transaction's
    envelope. The server describes the connection when it opens, and again
    when AUTH succeeds or a client certificate matches the reverse path, by
    setting tSmtpSession.TransportInfo. That property wrote only the
    session's own field. The envelope took its copy of the field in Start,
    and again after STARTTLS, and at no other time - so the description
    written after AUTH never reached the envelope, and the stamp said what
    was known before the client authenticated.

    WHAT IT LOOKED LIKE: a receiving server that reads the Received header
    to tell an authenticated submission from an unauthenticated one took
    the message as one sent from the client's address without
    authentication. Filters that check that address against lists of
    end-user address ranges (such as the Spamhaus PBL) then scored the
    message as spam from a dial-up or consumer client.

    tSmtpSession.TransportInfo now sets the envelope's TransportInfo as
    well, so a description set at any time reaches the next stamp. A
    program that drives tSmtpSession itself and sets TransportInfo after
    Start gets the same. Tested by SmtpRelayTest, which submits
    with AUTH over implicit TLS and checks the stamp for "with ESMTPSA (TLS"
    and the envelope's TransportInfo: 48 of 50 checks on main 2e66523, the
    two new ones failing; 50 of 50 with the change.


--------------------------------------------------------------------------------
HTTP/2: STREAM ERRORS, FRAMES AFTER A RESET, AND MALFORMED REQUESTS
================================================================================

tHttp2Conn and TsmHTTPSv2 apply RFC 9113 handling to malformed or refused
requests and frames arriving after a reset, while keeping unrelated streams
and the shared HPACK state synchronized.


48. FIXED, BEHAVIOUR CHANGE - an HTTP/2 client that sent trailers, or any
    other HEADERS frame, on a request the server had just refused or reset
    lost its whole connection: tHttp2Conn answered GOAWAY(PROTOCOL_ERROR),
    and every other request in flight on the connection failed with it.
    Such a block is now decoded and dropped, and the connection carries on

    StreamSec.Http.Http2Conn.

    THE STEP THAT FAILED is where tHttp2Conn looks up the stream a HEADERS
    frame belongs to. A stream leaves the engine's table as soon as the
    server resets it: the 413 and RST_STREAM(NO_ERROR) of entry 45, a body
    reset at BodyBytes, ConnBodyBytes or TotalBodyBytes
    (ENHANCE_YOUR_CALM), a new stream refused over MaxConcurrentStreams or
    the response budget (REFUSED_STREAM), a stream window overrun
    (FLOW_CONTROL_ERROR), a malformed length (entry 49). A client that had
    sent more of the request before the reset reached it - typically the
    trailer section that ends the request - then sent a HEADERS frame for a
    stream the engine no longer knew. The engine took that for a client
    opening a stream with an identifier it had used already, and ended the
    connection with GOAWAY(PROTOCOL_ERROR). RFC 9113 section 5.1, "closed":
    "An endpoint that sends a RST_STREAM frame on a stream that is in the
    "open" or "half-closed (local)" state could receive any type of frame.
    The peer might have sent or enqueued for sending these frames before
    processing the RST_STREAM frame. An endpoint MUST minimally process and
    then discard any frames it receives in this state. This means updating
    header compression state for HEADERS and PUSH_PROMISE frames."
    DATA frames on such a stream were discarded correctly, and still are.
    Every release with HTTP/2, from 4.1.2.355 to 4.1.4.361, has it; entry
    45 added one more way to reach it. The refusals themselves were right,
    and HPACK, TLS, flow control and the request handler were not involved:
    the refused request stayed refused, and the other requests on the
    connection were served as before - until the GOAWAY.

    NOW the engine keeps the identifiers of the streams it reset while the
    client could still be sending on them. A HEADERS frame on one of them,
    with any CONTINUATION frames, is decoded through the connection's HPACK
    decoder, so that the dynamic table both ends share stays in step, and
    then dropped. Nothing is sent on the stream (section 5.1: "An endpoint
    MUST NOT send frames other than PRIORITY on a closed stream."), and the
    block costs one token of MaxUnproductiveFrames, as a refused HEADERS
    does.
      - HOW LONG A STREAM IS KEPT. Not by time - section 5.1: "Endpoints
        SHOULD NOT use timers for this purpose." A stream leaves the list
        when the client ends its side of it - with END_STREAM on a DATA or
        HEADERS frame that was dropped, or with a RST_STREAM of its own, a
        cancel that crossed the server's reset - or when newer resets push
        it out of a list as long as MaxConcurrentStreams (100 when that is
        0). A client counts a stream the server reset as open until it has
        read the RST_STREAM or reset the stream itself, and it reads the
        resets in the order they were sent. Take a reset that finds the
        list full, and the newest stream the client opened among the listed
        ones and the one being reset - not always the one being reset, which
        may be reset on its DATA after newer streams were opened. A client
        that keeps to the SETTINGS_MAX_CONCURRENT_STREAMS the server
        announced cannot have counted all the others as open when it opened
        that newest stream, so it had read the oldest reset by then; and
        whatever it sent on the oldest stream came before that HEADERS,
        which has arrived. Identifiers are kept in a bounded hash-backed set
        with insertion order. Expected per-step cost is independent of its
        length; stream-ID hash collisions can lengthen lookups within the bound.
      - WHERE THAT DOES NOT HOLD: a client that ignores the limit; a server
        with MaxConcurrentStreams 0, which announces no limit while the list
        still stops at 100; and a client's first flight, sent before it has
        read the server's SETTINGS - section 6.5.2: "Initially, there is no
        limit to this value." There a HEADERS frame on a stream pushed out
        of the list is still the GOAWAY(PROTOCOL_ERROR) of before.
      - A HEADERS frame on any other stream identifier at or below the
        highest one the client has used is still GOAWAY(PROTOCOL_ERROR): an
        identifier the client skipped, a stream both sides ended, one the
        client reset itself, and one whose client had ended its side
        already. On none of these can a client have anything left to send.

    WHY A BEHAVIOUR CHANGE. A HEADERS frame that used to end the connection
    is now taken in and dropped without an answer.

    WHO. Programs serving HTTP/2 with TsmHTTPSv2, or with tHttp2Conn
    directly, whose clients send request trailers, or have more of a
    request in flight when the server refuses it. Browsers send no trailers
    with an upload, so a browser upload answered 413 (entry 45) is not
    affected; HTTP/2 clients that stream request bodies with trailers can
    be.

    THE DISCRIMINATING TEST: on one HTTP/2 connection, send a POST with a
    content-length over Limits.BodyBytes and without END_STREAM, then a
    trailer section on the same stream (a HEADERS frame with END_STREAM),
    then a second request. An affected release answers the trailers with
    GOAWAY(PROTOCOL_ERROR) and never serves the second request; this one
    sends nothing for the trailers and serves it.

    HOW IT WAS TESTED. BodyRefusalTest section 9: trailers after a
    413, after a reset at the limit (in a HEADERS and a CONTINUATION) and on
    a stream refused with REFUSED_STREAM, each followed by a request with a
    field the client's HPACK encoder sends as an index into the entry the
    dropped block added - only a server that decoded the block reads that
    field right; the list's bound at MaxConcurrentStreams 2 and 0; and, as
    controls, a HEADERS on an identifier never opened, on a stream both
    sides ended, and on a reset stream after its client's END_STREAM,
    which stay GOAWAY(PROTOCOL_ERROR). On main af8d7c6, before entries 48
    and 49, 177 of the harness's 211 checks pass on Win32, Win64 and
    Linux64, the same 34 failing on each: 18 of them are this entry's (all
    in section 9), 15 are entry 49's, and one, in section 10, needs both.
    With both entries, 211 of 211 on each. Added in review: the cancel that
    crosses the reset (with MaxConcurrentStreams 2, uploads 1 and 3 refused
    with 413, 3 cancelled by the client, 5 refused, then trailers on 1) and
    a HEADERS on 3 after that cancel. Without the RST_STREAM step the
    trailers on 1 ended the connection: on the first version of this entry
    (work/h2fields 0604fbc), 286 of the harness's 293 checks pass on each
    platform, those 5 among the 7 failing; with it, 293 of 293 (battery
    rows, floor 293). And a client that is not this library:
    the script of entry 45 now has Node 24's http2 client send a
    POST over the limit with one chunk of its body and a trailer section,
    written at once, so that the trailers reach the server after its 413.
    Against a BodyRefusalServer (Win32) built on main af8d7c6 the trailers
    end the connection and the next request is never served: 17 of 18
    checks; with this entry, 18 of 18. That request is malformed itself -
    its content-length of 3 MiB is not the 16 KiB it sends - so it shows a
    real client's HPACK and framing of a trailer block arriving on a stream
    the server has reset, not the conforming case this entry is about; and
    its check that the trailers were sent shows only that the client's
    sendTrailers() was called.

    NOT CHANGED:
    - DATA on a stream the server reset is discarded and counted back to
      the connection's flow-control window, as before.
    - A HEADERS frame without END_STREAM after a request's header block, on
      an open stream, is still ignored, where RFC 9113 section 8.1 calls the
      request malformed; trailers are still not passed to the handler, and
      pseudo-header fields in them are not checked. Entries 51 and 52 change
      the first and the last.
    - Two paths still send RST_STREAM and keep the stream: a WINDOW_UPDATE
      of 0 on a stream, and a PRIORITY frame that is not 5 octets long.
      Entry 50 drops the stream.


49. FIXED, BEHAVIOUR CHANGE - tHttp2Conn passed an HTTP/2 request to the
    handler whatever its content-length said: with a body shorter or longer
    than the length it declared, or with a content-length that is not a
    number. Such a request is malformed, and its stream is now reset with
    RST_STREAM(PROTOCOL_ERROR) without calling the handler

    StreamSec.Http.Http2Conn; StreamSec.Mobile.HTTPS (comments only).

    THE STEP THAT FAILED is the end of the request, where tHttp2Conn hands
    the request to the router once END_STREAM has arrived. It never held
    the content-length field against the DATA that had come; entry 45 reads
    the length only to hold it against the limits. A request whose
    content-length said 1000 and whose DATA came to 999 octets, or 1001,
    reached the handler with those octets and the field still saying 1000;
    so did one with content-length 5 and no DATA, one with two
    content-length fields that disagree, and one with a value such as abc,
    -5 or 1e9. RFC 9113 section 8.1.1: "A request or response is also
    malformed if the value of a content-length header field does not equal
    the sum of the DATA frame payload lengths that form the content, unless
    the message is defined as having no content." and "Malformed requests
    or responses that are detected MUST be treated as a stream error
    (Section 5.4.2) of type PROTOCOL_ERROR." A request is never a message
    defined as having no content; that exception is for responses. HTTP/1.1
    answers a Content-Length that is not a number, or two of them, with
    400, and still does. Every release with HTTP/2, from 4.1.2.355 to
    4.1.4.361, has it. The limits, flow control and the handler were not
    involved: a request whose content-length is its length, or that has
    none, is served as before.

    NOW every content-length field of a request is held to the octets its
    DATA frames carried (padding not counted), and a value that is not a
    run of digits is a length no body has. A request that fails is reset
    with RST_STREAM(PROTOCOL_ERROR), on that stream alone: the handler is
    not called, the body is let go, and the connection carries on.
    OnBodyRefused is not told; no limit refused the body.
      - At END_STREAM: on the last DATA frame, on a trailer section, and on
        the request's own HEADERS, where any length but 0 is wrong.
      - At once, when the body already runs past the largest content-length
        it declared: the reset goes out with the frame that passes it, not
        after the rest of the body. What the client sends on the stream
        after that is dropped, as on any stream the server reset (entry 48).
      - The limits come first, as in entry 45: a length over BodyBytes or
        ConnBodyBytes is still answered 413 at HEADERS, and a body that
        passes its length in the frame that reaches a limit is still reset
        there with ENHANCE_YOUR_CALM and reported.
      - Two fields with the same value, and leading zeros (0001000), are the
        length they say. One field of "1000, 1000" is not a run of digits,
        and so is malformed, where two fields of 1000 are served; RFC 9110
        section 8.6 lets a recipient refuse either form. HTTP/1.1 on this
        server refuses both.

    WHY A BEHAVIOUR CHANGE. Requests the handler used to be given are reset
    before it, and a body longer than its content-length is reset where it
    passes that length, not at the limit or its end. Among them is a
    content-length that is not a run of digits, which entry 45 leaves to
    the limit on DATA: the request is now reset when it ends.

    WHO. Programs serving HTTP/2 with TsmHTTPSv2, or with tHttp2Conn
    directly, whose clients send a content-length that is not the length of
    what they send. Browsers, curl and the usual HTTP/2 client libraries
    send the true length, or none. A handler that read the content-length
    field instead of the body's size was given a number the body did not
    match; one that passed the request on to an HTTP/1.1 server with that
    field framed the body there by a length it did not have.

    THE DISCRIMINATING TEST: send an HTTP/2 POST with content-length: 10 and
    5 octets of DATA with END_STREAM. An affected release gives it to the
    handler with a 5-octet body; this one resets the stream with
    RST_STREAM(PROTOCOL_ERROR) (1), and the handler never sees it. A request
    whose content-length is right is served by both, so it cannot tell them
    apart.

    HOW IT WAS TESTED. BodyRefusalTest section 10: 999 and 1001
    octets against 1000, 5 on a HEADERS that ends the request, 600 octets
    and then trailers against 1000, two fields of 1000 and 999, and a first
    DATA of 16384 against 1000, reset at once; and as controls, served:
    1000 in two frames, 1000 and then trailers, two fields of 1000, 0,
    0001000, and no content-length. Added in review, for "padding not
    counted": a PADDED DATA frame of 1000 octets and 50 of padding, a
    payload of 1051, is served against content-length 1000 and reset
    against 1051; and one field of "1000, 1000" is reset. All three pass
    with this entry as first written. Section 2 now expects abc, -5 and 1e9
    to be reset when the request ends, where it expected them served, and
    its limits-of-0 control declares and sends 9,000,000 octets, where it
    declared 10^12 and sent 1000. Section 5's body longer than its length
    now declares the limit, so it still passes its length in the frame that
    reaches the limit, and is reset there with ENHANCE_YOUR_CALM. The
    numbers before and after are in entry 48. The ten HTTP test suites and
    Http2ConnTest, HpackTest and Http2FramesTest give the same results as on
    main af8d7c6.

    NOT CHANGED:
    - A request without a content-length is not checked: its length is what
      its DATA carries, up to BodyBytes.
    - The engine still writes its own content-length on a response,
      replacing any the handler set.


50. FIXED - after a stream error the client caused - a WINDOW_UPDATE with an
    increment of 0, or a PRIORITY frame that is not 5 octets long -
    tHttp2Conn sent RST_STREAM but kept the stream and went on using it: a
    response waiting for flow-control window was sent after the reset, and a
    request whose body was still coming was served. The stream is now
    dropped with its reset, and RST_STREAM is no longer sent on a stream
    that is idle or closed

    StreamSec.Http.Http2Conn.

    THE STEP THAT FAILED is the handling of those two frames. RFC 9113
    section 6.9: "A receiver MUST treat the receipt of a WINDOW_UPDATE frame
    with a flow-control window increment of 0 as a stream error (Section
    5.4.2) of type PROTOCOL_ERROR"; section 6.3: "A PRIORITY frame with a
    length other than 5 octets MUST be treated as a stream error (Section
    5.4.2) of type FRAME_SIZE_ERROR." The engine queued the RST_STREAM and
    did nothing else: the stream stayed in its table with its state and its
    response. Section 5.4.2: "A RST_STREAM is the last frame that an
    endpoint can send on a stream." Yet a response larger than the client's
    window - its first 65,535 octets sent, the rest waiting - was sent to
    the end as soon as the client gave more window, after the RST_STREAM;
    and a request still being sent was dispatched when its END_STREAM came,
    and its response sent on the stream already reset. A client drops what
    comes on a stream it has been told is reset, or - section 5.1 allows it
    - ends the connection with STREAM_CLOSED; either way the server did the
    work and sent the octets for nothing. The same frames on a stream not
    opened yet, or closed already, got a RST_STREAM there too. Section 6.4:
    "RST_STREAM frames MUST NOT be sent for a stream in the "idle" state. If
    a RST_STREAM frame identifying an idle stream is received, the recipient
    MUST treat this as a connection error (Section 5.4.1) of type
    PROTOCOL_ERROR." Every release with HTTP/2, from 4.1.2.355 to 4.1.4.361,
    has it. Flow control, the other frames and the request handler were not
    involved: a WINDOW_UPDATE of 1 or more, and a PRIORITY of 5 octets, are
    handled as before.

    NOW a stream error on a live stream resets the stream and drops it at
    once: the response it held is let go, with its share of
    MaxConnResponseBytes and of the server-wide response budget; nothing more
    is sent on it; and what the client still sends on it is dropped, as on
    any stream the server reset (entry 48). On a closed stream nothing is
    sent - section 5.1 allows only PRIORITY there. On an idle stream, which
    RST_STREAM may not name, the stream error is a connection error with the
    same code, GOAWAY(PROTOCOL_ERROR) or GOAWAY(FRAME_SIZE_ERROR); section
    5.4.1: "an endpoint MAY choose to treat a stream error as a connection
    error."

    WHO. Programs serving HTTP/2 with TsmHTTPSv2, or with tHttp2Conn
    directly, whose clients send either frame, which a correct client does
    not. Browsers and the usual client libraries do not; a test tool or a
    hostile client can.

    THE DISCRIMINATING TEST: request a response larger than 65,535 octets
    without enlarging the client's initial window, send WINDOW_UPDATE with
    an increment of 0 on its stream, then WINDOW_UPDATEs of 100,000 on the
    connection and on the stream. An affected release answers
    RST_STREAM(PROTOCOL_ERROR) and then sends the rest of the response on
    that stream; this one sends the RST_STREAM and nothing after it.

    HOW IT WAS TESTED. BodyRefusalTest section 11: each frame on a
    stream holding a 100,000-octet response for window (reset, response let
    go, nothing more when the window comes), on a stream whose request is
    still coming (its body and trailers dropped, the next request in step),
    on a closed stream (nothing sent) and on an idle one (GOAWAY, no
    RST_STREAM); as controls, a PRIORITY of 5 octets on open, idle and
    closed streams and a WINDOW_UPDATE of 1000 on a closed one, with nothing
    sent. On work/h2conform ac6312d, which has entries 48 and 49, 235 of the
    harness's 255 checks pass on Win32, Win64 and Linux64, the same 20
    failing on each: 10 of them are this entry's, 10 are entries 51 and
    52's. With entries 50 to 52, 255 of 255 on each. The battery rows'
    floor with entries 48 to 53 is in entry 48.

    NOT CHANGED:
    - A WINDOW_UPDATE that overflows a stream's window was already a stream
      reset that dropped the stream, and still is.
    - The content of a 5-octet PRIORITY frame is still ignored; RFC 9113
      deprecates the priority scheme.
    - Whether a stream is idle is judged, as everywhere in the engine,
      against the highest stream identifier the client has used.
    - What a reset the client provokes costs the client - this entry's two,
      and the malformed requests of entries 49 and 51 to 53. Entry 54
      charges each to MaxUnproductiveFrames, as the client's own RST_STREAM
      is charged.


51. FIXED - a second HEADERS frame on an HTTP/2 request that did not end the
    request was ignored by tHttp2Conn, and the request was served when it
    ended. Such a request is malformed, and its stream is now reset with
    RST_STREAM(PROTOCOL_ERROR)

    StreamSec.Http.Http2Conn.

    THE STEP THAT FAILED is where tHttp2Conn takes a second header block on
    a request that has had its own. It took any such block for trailers,
    and acted on it only when it carried END_STREAM. One without END_STREAM
    was decoded and thrown away, the stream stayed open, and the DATA after
    it went into the body as if the block had not been there. RFC 9113
    section 8.1: "An endpoint that receives a HEADERS frame without the
    END_STREAM flag set after receiving the HEADERS frame that opens a
    request or after receiving a final (non-informational) status code MUST
    treat the corresponding request or response as malformed (Section
    8.1.1)." Every release with HTTP/2, from 4.1.2.355 to 4.1.4.361, has it.
    A trailer section - a second block with END_STREAM - is handled as
    before, except as entry 52 says.

    NOW the request is malformed at that block: RST_STREAM(PROTOCOL_ERROR),
    no dispatch, the body let go, and what the client still sends on the
    stream dropped (entry 48).

    WHO. Programs serving HTTP/2 whose clients send such a block, which no
    correct client does.

    THE DISCRIMINATING TEST: send a POST's HEADERS without END_STREAM, some
    DATA, a second HEADERS without END_STREAM, then DATA with END_STREAM. An
    affected release serves the request; this one resets the stream with
    RST_STREAM(PROTOCOL_ERROR) at the second HEADERS and serves nothing.

    HOW IT WAS TESTED. BodyRefusalTest section 11: that sequence -
    the reset at the second block, the DATA that would have ended the
    request dropped, and the next request in step. The numbers before and
    after are in entry 50.


52. FIXED - tHttp2Conn did not check the fields of a request's trailer
    section: trailers with a pseudo-header field, a connection-specific
    field, an uppercase name, or CR, LF or NUL in a name or value did not
    stop the request from being served. Such a request is malformed, and its
    stream is now reset with RST_STREAM(PROTOCOL_ERROR)

    StreamSec.Http.Http2Conn.

    THE STEP THAT FAILED is the end of a request with trailers. tHttp2Conn
    decoded the trailer section and discarded it - trailers are not handed
    to the handler - without the checks it makes of the request's own
    fields. RFC 9113 section 8.1: "Trailers MUST NOT include pseudo-header
    fields (Section 8.3). An endpoint that receives pseudo-header fields in
    trailers MUST treat the request or response as malformed (Section
    8.1.1)." The other rules are for every field of a request: section
    8.2.1, "A request or response that contains a field that violates any
    of these conditions MUST be treated as malformed (Section 8.1.1).", and
    section 8.2.2, "Any message containing connection-specific header fields
    MUST be treated as malformed (Section 8.1.1)." As the trailers never
    reached the handler, nothing in them was acted on; what was wrong is
    that the request was served at all. Every release with HTTP/2, from
    4.1.2.355 to 4.1.4.361, has it.

    NOW a trailer section is held to the checks the engine already makes of
    the request's own regular fields: no pseudo-header field, a lowercase
    name, no NUL, CR or LF in a name or value, none of connection,
    keep-alive, proxy-connection, transfer-encoding and upgrade, and te only
    with the value trailers. A section that fails one makes the request
    malformed: RST_STREAM(PROTOCOL_ERROR), no dispatch, the body let go. A
    trailer section that passes them, or is empty, ends the request as
    before. Entry 53 adds the rest of section 8.2.1's rules for names and
    values, here and in the request's own fields.

    WHO. Programs serving HTTP/2 whose clients send such trailers, which no
    correct client does.

    THE DISCRIMINATING TEST: end a POST with a trailer section holding
    connection: close. An affected release serves the request; this one
    resets the stream with RST_STREAM(PROTOCOL_ERROR).

    HOW IT WAS TESTED. BodyRefusalTest section 11: trailers with
    :path, :status, connection, transfer-encoding, te: gzip, CR LF in a
    value, NUL in a value, and an uppercase name (an HPACK literal this
    library's encoder would not write); as controls, served: an ordinary
    field, and an empty trailer section. The numbers before and after are
    in entry 50. The ten HTTP test suites and Http2ConnTest, HpackTest and
    Http2FramesTest give the same results as before entries 50 to 52.

    NOT CHANGED:
    - The checks are the engine's existing ones, and so are their gaps: a
      field name with a space, a colon or another octet that RFC 9113
      section 8.2.1 also forbids, and a value that begins or ends with a
      space or a tab, are not refused - in trailers or in the request's own
      fields. Entry 53 refuses them.
    - Trailers are still not passed to the handler.


53. FIXED, BEHAVIOUR CHANGE - tHttp2Conn held the fields of an HTTP/2
    request to only part of the checks RFC 9113 section 8.2.1 requires of
    every field: a name with a space, another control octet, an octet from
    0x7f to 0xff or a colon inside it, and a value that began or ended with
    a space or a tab, were accepted and reached the handler - and so was an
    empty name, which RFC 9110 rules out. Such a request is malformed, and
    its stream is now reset with RST_STREAM(PROTOCOL_ERROR)

    StreamSec.Http.Http2Conn.

    THE STEP THAT FAILED is the check of each field when tHttp2Conn builds
    the request for the handler, and the same check of a trailer section
    (entry 52). It refused an uppercase letter in a name and NUL, CR or LF
    anywhere, and nothing else of what section 8.2.1 calls the "minimal
    validation of field names and values":
      "A field name MUST NOT contain characters in the ranges 0x00-0x20,
      0x41-0x5a, or 0x7f-0xff (all ranges inclusive)."
      "With the exception of pseudo-header fields (Section 8.3), which have
      a name that starts with a single colon, field names MUST NOT include a
      colon (ASCII COLON, 0x3a)."
      "A field value MUST NOT start or end with an ASCII whitespace
      character (ASCII SP or HTAB, 0x20 or 0x09)."
    and "A request or response that contains a field that violates any of
    these conditions MUST be treated as malformed (Section 8.1.1)." The
    section gives its reason: "Failure to validate fields can be exploited
    for request smuggling attacks. In particular, unvalidated fields might
    enable attacks when messages are forwarded using HTTP/1.1 [HTTP/1.1],
    where characters such as carriage return (CR), line feed (LF), and COLON
    are used as delimiters." The library forwards no request itself, and CR
    and LF, which split a line, were refused already; a handler that passed
    such a field on to an HTTP/1.1 server passed on a name or a value that
    server could read differently. Every release with HTTP/2, from 4.1.2.355
    to 4.1.4.361, has it.

    NOW every field of a request - in its header section or its trailer
    section, pseudo-header fields included - is held to all four rules: a
    name with no octet from 0x00 to 0x20, from 0x41 to 0x5a or from 0x7f to
    0xff, and no colon but a pseudo-header field's first; a value with no
    NUL, CR or LF, and no space or tab at its start or end. A request that
    breaks one is reset with RST_STREAM(PROTOCOL_ERROR) and not dispatched;
    the connection carries on. This completes entry 52's checks of a trailer
    section.
      - An empty field name is refused too. It is not on that list, but RFC
        9110 section 5.1 makes a field name a token, of one character at
        least, and HPACK can carry a name of none.
      - THE RESET ALONE, NO 400. Section 8.1.1 requires the reset -
        "Malformed requests or responses that are detected MUST be treated
        as a stream error (Section 5.4.2) of type PROTOCOL_ERROR" - and
        allows a response before it: "For malformed requests, a server MAY
        send an HTTP response prior to closing or resetting the stream."
        Section 8.2.1 asks for that response with a SHOULD: "When a request
        message violates one of these requirements, an implementation
        SHOULD generate a 400 (Bad Request) status code (see Section 15.5.1
        of [HTTP]), unless a more suitable status code is defined or the
        status code cannot be sent (e.g., because the error occurs in a
        trailer field)." The engine sends no response to a malformed
        request, for these rules as for an uppercase name and NUL, CR or LF
        before them and its other malformed requests. So for a field in the
        request's header section it does not do what that SHOULD asks - for
        one in a trailer section the sentence itself excuses it - and the
        client gets RST_STREAM(PROTOCOL_ERROR) with no status to say why.
      - A space or a tab inside a value, an empty value, octets from 0x80 to
        0xff in a value, and a colon in a value are allowed, as section 8.2.1
        allows them.

    WHY A BEHAVIOUR CHANGE. Requests the handler was given are now reset
    before it. A client library may pass a value on as the application set
    it: Go's x/net HTTP/2 client refuses only control characters in a
    value - DEL, and octets below 0x20 but HTAB - so space and tab pass,
    and a Go program that sets a header to a value ending with a space had
    its requests served, and now gets RST_STREAM.
    The same request over HTTP/1.1 to TsmHTTPSv1dot1 is served, because the
    HTTP/1.1 parser trims a value, so the two wires of one server answer it
    differently. The other way was open: Apache's mod_http2 turns nghttp2's
    version of this check off on its server, to strip the whitespace as its
    HTTP/1.1 parser does, and curl turns it off on its client. This library
    keeps to the MUSTs of section 8.2.1, this one among them.

    WHO. Programs serving HTTP/2 with TsmHTTPSv2, or with tHttp2Conn
    directly, whose clients send such fields - most likely values that an
    application builds and a client library passes on unchanged.

    THE DISCRIMINATING TEST: send an HTTP/2 request with a field x-v whose
    value ends with a space. An affected release serves it; this one resets
    the stream with RST_STREAM(PROTOCOL_ERROR) (1). A field name with an
    uppercase letter is reset by both, so it cannot tell them apart.

    HOW IT WAS TESTED. BodyRefusalTest section 12: names with a
    space, HTAB, 0x01, DEL, 0xe9 and a colon inside them; values that start
    or end with a space or a tab, a value of one space, and a :path that
    ends with a space; in trailers, a name with a space and a value that
    ends with one. As controls, served: a value with a space and a tab
    inside it, a name of digits and -_.~!, an empty value, a value with
    octets 0x80-0xff and a value with a colon; and the HPACK tables in step
    after all of it. On work/h2gaps d17b81c, which has entries 48 to 52, 264
    of the harness's 278 checks pass on Win32, Win64 and Linux64, the same
    14 failing on each, all of them this entry's; with it, 278 of 278 on
    each. Added in review: an empty name, in the request's own fields and in
    trailers - 2 of the 7 checks failing on the first version of this entry
    (work/h2fields 0604fbc), 293 of 293 with it (the numbers are in entry
    48). The ten HTTP test suites and Http2ConnTest, HpackTest and
    Http2FramesTest give the same results as before.

    NOT CHANGED:
    - The rest of RFC 9110's grammar for field names and values - a name of
      token characters only, a value of visible characters, space, tab and
      obs-text - which section 8.2.1 asks for with a SHOULD, is not checked:
      a name with "(" or "@", or a value with another control octet, passes
      as before.
    - HTTP/1.1 is not affected.


54. BEHAVIOUR CHANGE - a stream that tHttp2Conn resets because of what the
    client sent - a stream error, a malformed request, a body over a limit -
    now costs the client a token of MaxUnproductiveFrames, as a RST_STREAM
    the client sends itself always has. A client that provokes resets and is
    served nothing runs out, and its connection ends with
    GOAWAY(ENHANCE_YOUR_CALM)

    StreamSec.Http.Http2Conn.

    WHAT CHANGES. MaxUnproductiveFrames (TsmHTTPSv2.Limits, and tHttp2Conn)
    is a budget of 1000 tokens per connection, spent by the frames that make
    the server work without advancing a request - PING, SETTINGS, PRIORITY,
    RST_STREAM, empty DATA, unknown frame types, a refused HEADERS - and
    refilled by 8 for every request served. When it runs out, the connection
    ends with GOAWAY(ENHANCE_YOUR_CALM). A RST_STREAM the client sent cost a
    token; a reset the client made the SERVER send cost nothing, although it
    leaves the server the same work - a header block decoded, a stream set
    up and torn down, nothing served - and a RST_STREAM to send besides.
    Those resets are:
      - the stream errors: a WINDOW_UPDATE with an increment of 0 (entry 50)
        or one that takes a stream's window past 2^31-1, a PRIORITY that is
        not 5 octets long (entry 50), and DATA on a request that has already
        ended;
      - a malformed request (RFC 9113 section 8.1.1): a content-length that
        is not the length of the content (entry 49), a second HEADERS
        without END_STREAM (51), trailers or fields that break sections
        8.1, 8.2.1 or 8.2.2 (52, 53), and the other checks made when the
        request is built;
      - a body reset as it arrives because it reached BodyBytes,
        ConnBodyBytes or TotalBodyBytes (entry 45). One over BodyBytes by
        its content-length, answered 413 at HEADERS, cost a token already.
    Each now costs one token, once per stream, so a connection that does
    nothing else is ended as one sending nothing but PINGs is. With the
    limits as shipped that is after 999 resets - the 1000 tokens less the
    one the client's SETTINGS cost - where the connection used to end with
    GOAWAY(NO_ERROR) when the client opened its 1001st stream; with
    MaxStreamsPerConnection 0, which means no limit, it used not to end.

    NOT A SECURITY FIX. This is the shape CERT/CC published as "MadeYouReset",
    CVE-2025-8671 (VU#767506, 2025-08-13): a client opens streams and makes
    the server reset them with malformed frames or flow-control errors. Its
    harm, in CERT/CC's words, is that "Streams reset by the server are
    considered closed, even though backend processing continues", so that
    the server handles more concurrent requests than it counts. That chain
    does not reach this engine. tHttp2Conn dispatches a request on the
    thread that read it, when its last frame arrives, and reads nothing more
    until the handler has returned, so no handler is at work on a stream
    when it is reset: a reset lets go of a response that has been made, or
    of a request that was never dispatched. What a client got for nothing
    was the server's per-stream work and one RST_STREAM per stream, up to
    MaxStreamsPerConnection streams per connection - work a refused HEADERS
    already costs a token. Go's statement to CERT/CC (2025-06-25) makes the
    same point for its server, whose Rapid Reset limits count running and
    queued handlers, whether the client resets a stream or "induces the
    server to issue a reset". nghttp2 answered with a rate limit of its own
    in 1.67.0 (2025-09-02): every stream error it raises is counted by a
    "glitch" limiter, and too many end the connection with
    GOAWAY(ENHANCE_YOUR_CALM). This entry does the same with the budget this
    engine already has.

    A REQUEST SERVED AND THEN RESET. The frames the CVE's reporters test with
    send a whole request and then the frame that provokes the reset; here
    that request has been served when the reset comes. Its dispatch refunded
    8 tokens and the reset takes one, so such a client does not run out, and
    MaxStreamsPerConnection bounds it, as it bounds a request the client
    cancels with a RST_STREAM of its own. That is on purpose: charging the
    reset more would not lower what such a client can cause - left out, the
    reset changes nothing about the requests served - and a reset that comes
    after the handler has returned only lets go of its response.

    THE DETAILS:
      - One token per stream reset, whichever frame caused it, taken after
        the RST_STREAM is queued: when it is the last token, the GOAWAY
        comes after the reset.
      - A stream error on a stream that has closed - a WINDOW_UPDATE of 0
        after the response has gone - costs a token too, although nothing is
        sent: whether the stream was still open depends on how soon the
        server finished the response, not on the client.
      - A PRIORITY that is not 5 octets costs two tokens, one as every
        PRIORITY does and one for the stream error: what a PRIORITY and a
        RST_STREAM from the client cost.
      - A reset the server causes itself - RST_STREAM(INTERNAL_ERROR) when a
        response body read from a file fails after its length was sent -
        costs nothing.

    WHY A BEHAVIOUR CHANGE. Connections that provoke resets now end sooner,
    and with ENHANCE_YOUR_CALM. A correct client does not send the frames
    that cause a stream error or a malformed request. One whose bodies are
    refused at a limit as they arrive is charged a token for each refusal,
    where only a 413 at HEADERS was before; with 8 refunded for every
    request served, it takes some 1000 refusals on one connection with
    nothing served in between to run out. Limits.MaxUnproductiveFrames 0
    switches the budget off, for these as for every other frame it counts.

    WHO. Programs serving HTTP/2 with TsmHTTPSv2, or with tHttp2Conn
    directly, whose clients provoke resets. With the limits as shipped a
    client has to provoke 999 resets on one connection, with nothing served,
    to see a difference.

    THE DISCRIMINATING TEST: open a stream with a HEADERS frame without
    END_STREAM and send a WINDOW_UPDATE with an increment of 0 on it, on one
    new stream after another. Both releases reset each stream with
    RST_STREAM(PROTOCOL_ERROR). An affected release ends the connection
    with GOAWAY(NO_ERROR) when the 1001st stream is opened; this one ends it
    with GOAWAY(ENHANCE_YOUR_CALM) after the 999th reset. On tHttp2Conn,
    UnproductiveTokens falls by one at each reset here and stays where it
    was there.

    HOW IT WAS TESTED. BodyRefusalTest section 13, each kind of
    reset with the reset it gets and the tokens it costs: a WINDOW_UPDATE of
    0 on a stream holding a response, on one whose request is still coming,
    and on one that has closed; a PRIORITY of 6 octets; a WINDOW_UPDATE that
    takes a window past 2^31-1; DATA after END_STREAM; a second HEADERS
    without END_STREAM; trailers with :path; a content-length against the
    content three ways; a field name with a space; a body that reaches
    BodyBytes. As controls, a 5-octet PRIORITY, a 413 at HEADERS and the
    client's own RST_STREAM cost one token as before, and a request served
    costs none. Then two connections that provoke nothing but resets: five
    kinds in turn with MaxUnproductiveFrames 50 and MaxStreamsPerConnection 0
    (GOAWAY(ENHANCE_YOUR_CALM) after 49 resets), and one kind with the
    limits as shipped (after 999). As a control, MaxStreamsPerConnection 100
    with each request served and then reset by a WINDOW_UPDATE of 0 ends
    with GOAWAY(NO_ERROR) after 100 requests, with tokens left. On main
    1ff60ca, which has entries 48 to 53, 315 of the harness's 331 checks
    pass on Win32, Win64 and Linux64, the same 16 failing on each, all of
    them this entry's; with it, 331 of 331 on each (battery rows, floor
    331). The ten HTTP test suites and Http2ConnTest, HpackTest and
    Http2FramesTest give the same results as before.

    NOT CHANGED:
    - The budget's size (1000) and refund (8), and MaxStreamsPerConnection
      (1000).
    - A refused HEADERS - REFUSED_STREAM at open, or STREAM_CLOSED on a
      request that has ended - and trailers dropped on a stream the server
      reset (entry 48) cost one token, as before. So does the client's own
      RST_STREAM.
    - HTTP/1.1 is not affected.


--------------------------------------------------------------------------------
SOCKETS AND THE ASYNC REACTOR: DATAGRAMS (UDP)
================================================================================


55. NEW - a UDP datagram socket: tAbstractDatagramSocket and NewDatagramSocket
    in stSocket, and the endpoint address type tSocketAddress in the new unit
    stSocketAddress

    stSocket, stSocket.Posix, stSocketAddress (new; in every StrSecIV
    runtime package that contains stSocket).
    The socket layer had no datagram socket at all: tAbstractSocket is TCP
    on every platform. NewDatagramSocket returns a non-blocking UDP socket
    (tWinDatagramSocket on Windows, tPosixDatagramSocket on POSIX) that
    binds to an IPv4 or IPv6 address - port 0 for one the system picks -
    and sends and receives one whole datagram per call, each with its own
    peer:
      - SendTo hands the datagram to the system or reports why not (a full
        send buffer is a would-block, error 0); ReceiveFrom returns the next
        datagram and its sender, 0 octets being a real, empty datagram;
      - a datagram larger than the receive buffer is DROPPED and reported
        as cDatagramTruncated, never passed on in part;
      - NO ERROR CLOSES THE SOCKET. An ICMP report about an earlier
        datagram, a truncation, a refused destination happen to one
        datagram; only Close closes it. On Windows the system's habit of
        failing the next RECEIVE with WSAECONNRESET after a send drew an
        ICMP port-unreachable is switched off (SIO_UDP_CONNRESET, and
        SIO_UDP_NETRESET), so one peer that went away cannot disturb a
        socket that serves many;
      - an IPv6 socket is IPv6-only on every platform (the platform
        defaults differ); bind a second socket for IPv4;
      - WaitForData, Wake and Close follow tAbstractSocket: a Close on
        another thread ends a wait at once.
    The same calls exist at the handle level (OpenDatagramHandle,
    SendDatagram, ReceiveDatagram, DatagramHandleAddress,
    SetDatagramBufferSizes, SocketAddressToNative/FromNative) for code
    that drives a handle itself, such as a reactor backend.
    SendSegmentsTo sends several datagrams of one size from one buffer to
    one peer, the last possibly shorter, and returns how many whole
    datagrams the system accepted - always the first ones; the error code
    describes the first one it did not accept. A socket class without its
    own SendSegmentsTo sends them one at a time through SendTo, so a custom
    backend keeps working. On Windows two or more go to the system in one
    WSASendMsg with UDP segmentation offload (UDP_SEND_MSG_SIZE), all or
    none; a system without that option gets one datagram per call.
    SendDatagramSegments is the same call at the handle level.
    tSocketAddress holds an IPv4 or IPv6 endpoint without any platform
    type. Its text is parsed and printed by the unit itself, the same on
    every platform: IPv4 as a dotted quad without leading zeros, IPv6 as
    RFC 5952 prints it - lower case, "::" for the longest run of two or
    more zero fields, mixed notation for the IPv4-mapped prefix only - with
    an optional numeric zone ("%3"). A name is never resolved.
    Tested by UdpTest on Win32, Win64 and Linux64: the text
    against the system's own inet_ntop and inet_pton on 2,560 random
    addresses (the two places the systems print differently by design are
    named there), RFC 5952 vectors, literals that must be refused, and the
    socket over IPv4 and IPv6 loopback with datagrams of 0 to 65,507 and
    65,527 octets. Without the SIO_UDP_CONNRESET switch-off the
    port-unreachable check is red on Windows (10054).
    SendSegmentsTo is tested by DatagramSegmentTest over IPv4 and IPv6
    loopback: batches of 1 to 10 datagrams of 500, 1,200 and 1,452 octets,
    with and without a shorter last one, arrive whole, in order and
    unchanged; invalid sizes and a closed socket are refused; a socket class
    without the override stops at the datagram that fails, with its error.


56. NEW - a datagram path in the asynchronous reactor:
    tReactorDatagramEndpoint, driven by the IOCP, epoll and kqueue backends

    StreamSec.Mobile.AsyncTLSReactor, StreamSec.Mobile.AsyncTLSReactor.IOCP,
    StreamSec.Mobile.AsyncTLSReactor.Poll.
    A tReactorDatagramEndpoint is a bound UDP socket (entry 55) that the
    reactor reads for you: each datagram arrives whole, with its sender, in
    HandleDatagram on an I/O thread; SendTo sends from any thread and never
    waits. There is no send queue: a datagram the system will not take now
    is dropped and counted (SendsDropped), as a datagram protocol expects.
    ReceiveDepth 1 (the default) serializes HandleDatagram in arrival
    order; on IOCP a larger depth keeps that many receives posted and lets
    HandleDatagram run on several threads at once, for a server whose
    handler dispatches to per-peer state with its own locks. A receive
    failure and an exception raised by HandleDatagram are counted
    (ReceiveErrors, HandlerFaults) and the endpoint goes on. Close is safe
    from any thread and waits for a system call in progress on the handle;
    Stop closes every endpoint still attached.
    tAsyncReactor has SupportsDatagrams, AttachDatagram, DetachDatagram,
    SendDatagram and DatagramEndpointCount. They are virtual, not abstract,
    as Nudge is: a backend written outside the library before this release
    still compiles, and answers that it has no datagram path.
    SendSegmentsTo sends several datagrams of one size in one call where the
    backend can (IOCP: the segmentation offload of entry 55); datagrams it
    does not take are dropped and counted as for SendTo. Its backend method,
    tAsyncReactor.SendDatagramSegments, is virtual too, and by default sends
    the datagrams one at a time through SendDatagram.
    Tested by UdpTest on IOCP (Win32, Win64) and epoll (Linux64):
    2,000 datagrams echoed whole, serialization at depth 1, concurrency at
    depth 4 on IOCP, a raising handler survived, SendTo and Close from a
    foreign thread, an endpoint freed without Close releasing its port, and
    Stop with endpoints attached. The kqueue backend (macOS, iOS) shares the
    epoll code path and has been compiled, not run.


--------------------------------------------------------------------------------
SOCKETS AND MAIL: THE WINSOCK CODE OF A FAILED CALL, AND EACH MX ATTEMPT
================================================================================


57. NEW - EstSocketError carries the Winsock code of a failed call in a
    read-only ErrorCode, and tSmtpMxAgent makes the client of each MX
    attempt in a protected virtual CreateClient and reports the attempt to a
    new OnAttempt event

    stSocket, StreamSec.Mail.SMTPMx.

    EstSocketError has a read-only ErrorCode, and a CreateCode constructor
    that sets it. When a Winsock call made by tWinSocket (its constructor
    and destructor included), by DualWaitForData, or by entry 55's
    tWinDatagramSocket and OpenDatagramHandle fails and raises, the
    exception now carries the Winsock code apart from its message, so that a
    caller can tell WSAEADDRNOTAVAIL from WSAECONNREFUSED without parsing
    text. A bounded connect that runs out of time carries WSAETIMEDOUT.
    Otherwise ErrorCode is 0:
      - for a Listen address that is not an IP address literal, and for an
        Open host name that does not resolve, which still raises
        "No address specified": the resolver's code is not kept;
      - for a socket that is already open;
      - for a SourceIP that is not an IP address literal, or not of the
        destination's address family;
      - for a datagram bind address that is neither IPv4 nor IPv6, for a
        datagram that was larger than the receive buffer, and for a
        datagram socket that is not bound (cDatagramTruncated and
        cDatagramClosed);
      - for an EstSocketError made with another constructor;
      - on POSIX, whose transport does not set it.
    The messages are the same as before. An error procedure set with
    SetErrorProc, or an aErrorCode argument to Receive, Send, SendTo or
    ReceiveFrom, still gets the code in place of an exception where it did
    before; the source bind and the connect of a source-bound or timed Open
    raise regardless, as they did.

    tSmtpMxAgent makes the client of each MX attempt in CreateClient, which
    a descendant can override to use its own TsmAdvancedSMTPClient
    descendant. It returns a new client, not yet connected; the agent sets
    it up and frees it after the attempt. The attempt begins there: an
    exception CreateClient raises, a nil result, and a client that refuses
    the agent's settings - one handed back still connected refuses a new
    Host - fail that MX like any other failure, so the next MX is tried and
    the reason is in the delivery error. OnAttempt is called once for each
    attempt that has a client, which is every attempt but one whose
    CreateClient raised or returned nil. After a delivery it gets aDelivered
    True and aError nil, before the QUIT, with the session still open. A
    failed attempt is reported after the client has sent QUIT (when the
    session was open) and disconnected, so Secure is False, and the client's
    reply code and reply text are what its last read of a reply left. They
    need not describe the failure: after a refusal that ends Open - of the
    greeting, HELO, STARTTLS or AUTH - they are the refusal's, but once a
    QUIT is answered they are the QUIT's. The exception describes the
    failure - its message, and the ReplyCode of an eSMTPClientError or the
    ErrorCode of an EstSocketError - and the client's Stage says how far the
    attempt got. The client and the exception are lent for the call only: a
    handler must not keep, free or raise either. An exception a handler
    raises is swallowed, the one it was lent included, and changes neither
    MX fallback, nor the delivery, nor whether a failure is permanent. An
    exception after the delivery, from the disconnect, does not report the
    attempt again as failed, and the message counts as delivered; Close
    already ignores a QUIT reply that is refused, late or missing. One that
    an OnLog handler raises goes no further than the handler (entry 60).

    HOW IT WAS TESTED. SocketMxDiagnosticsTest, on Win32 and Win64,
    125 of 125 checks on each. A source bind to 192.0.2.1, which is
    not a local address, reports WSAEADDRNOTAVAIL and never connects
    unbound; a bounded and an unbounded Open of a loopback port that is
    bound but not listening report WSAECONNREFUSED; a datagram socket's bind
    to 192.0.2.1 reports WSAEADDRNOTAVAIL, and a SendTo of 70,000 octets
    WSAEMSGSIZE. Eight MX scenarios run over loopback against a scripted
    SMTP server, through a CreateClient override, with an OnAttempt handler
    that raises: a delivery; a fallback to the next MX after OnConfigure
    fails; a refusal at RCPT, which is permanent, never reaches DATA, and is
    reported with Stage sdsRcpt and the QUIT's 221 as the client's last
    reply; a greeting refused with 554, which is permanent and is reported
    with Stage sdsSession and the refusal's code and text as the client's
    last reply; a source bind that fails, reported with the EstSocketError
    and its WSAEADDRNOTAVAIL; an OnLog handler that raises after the
    delivery; and two with a handler that raises the exception it was lent -
    the fallback, where that exception is freed once and the next MX still
    delivers, and the refusal at RCPT, which stays permanent with its reply
    text intact. SmtpMxLogRaiseTest (entry 60) starts the first of
    two MX attempts with a CreateClient that raises, one that returns nil,
    and one that hands back a client still connected to another loopback
    server: each attempt fails, the next MX delivers, and the connected
    client is reported to OnAttempt after its QUIT, with its own
    eTLSClientError. The other raise sites - a bounded connect that fails
    before it waits, the deadline's WSAETIMEDOUT, Receive, Send, WSASocket,
    WSAStartup, WSACleanup, and the datagram socket's other calls - were not
    made to fail: what they carry rests on reading the code. On Linux64,
    where the harness does not run, a program of the same shape - a handler
    that raises the exception lent to it, from inside the handler that owns
    it - freed that exception once, at the end of the owning handler, as on
    Windows.


--------------------------------------------------------------------------------
HTTP/2: RESET-STREAM STORAGE
================================================================================

58. REDACTED - Reset-stream storage details
    consolidated into entry 48. This number is retained for reference.


--------------------------------------------------------------------------------
SOCKETS: tWinSocket.LookupName AND A NAME THAT DOES NOT RESOLVE
================================================================================


59. FIXED - tWinSocket.LookupName raised an access violation, not an
    EstSocketError, for a name that does not resolve, and for an IPv4
    address it copied 12 octets from past the end of getaddrinfo's answer
    into the record it returned

    stSocket (Windows: tWinSocket).

    THE STEP THAT FAILED is the test of getaddrinfo's result. LookupName
    handed it to CheckSocketResult, which is for the Winsock calls that
    answer SOCKET_ERROR (-1) and leave the code to WSAGetLastError, and
    which raises only for a negative result. getaddrinfo answers 0, or the
    error code itself - a positive number, such as 11001
    (WSAHOST_NOT_FOUND) for a name no DNS server knows. So a failure passed
    the test, and LookupName then read the address out of the answer list
    that getaddrinfo had left nil: "Access violation ... Read of address
    00000018" on Win32, 0000000000000020 on Win64, where an EstSocketError
    was due. An error procedure set with SetErrorProc was never called, so
    it changed nothing. A name that resolves never reached this step.

    The second step is the copy. TSockAddrIn holds either address family,
    so it is 28 octets, the size of an IPv6 sockaddr_in6, and LookupName
    copied 28 octets of getaddrinfo's first answer whatever its family. An
    IPv4 answer is 16 octets, so octets 16 to 27 of the record were
    whatever followed it in memory - not zero, on Win32 and on Win64.
    sin_family, sin_port, sin_addr and sin_zero, the whole IPv4 part of the
    record, were right: a caller that reads only those got the right
    address. An IPv6 answer is 28 octets and was copied correctly.

    Nothing in the library calls LookupName. Its own name lookups - Open by
    host name, LookupHost, and the SSH socket units - go through
    LookupNameEx, which tests getaddrinfo's result itself, copies only the
    answer's own length, and was not involved. Only an application that
    calls tWinSocket.LookupName is affected. To tell: look up a name that
    cannot exist, such as nonexistent.invalid; an EAccessViolation out of
    LookupName is this defect.

    Now LookupName tests getaddrinfo's result itself. A failure raises
    EstSocketError with getaddrinfo's code in ErrorCode (entry 57) and the
    message every failed Winsock call has, for example "Windows socket
    error: No such host is known (11001), on API 'getaddrinfo'" - also with
    an error procedure set, which is not called: there is no address to
    return. Of an answer it takes the first entry that is an IPv4 address of
    16 octets or an IPv6 address of 28, copies that many octets and zeroes
    the rest of the record; an answer with neither raises EstSocketError,
    ErrorCode 0.

    HOW IT WAS TESTED. The new LookupNameTest, on Win32 and Win64,
    calls getaddrinfo itself with LookupName's arguments and holds
    LookupName to its answer. nonexistent.invalid (RFC 6761 reserves the
    .invalid domain never to resolve), a 312-octet name under .invalid, and
    nonexistent.invalid with an error procedure set that returns must each
    raise EstSocketError naming getaddrinfo, with getaddrinfo's own code in
    the message and in ErrorCode; 127.0.0.1, ::1 and localhost must come
    back as getaddrinfo's first answer, equal over that answer's length,
    with nothing past it. Without the fix 16 of its 29 checks passed on each
    platform: every name that does not resolve raised EAccessViolation, and
    octets 16 to 27 of 127.0.0.1 were not zero. With it, 29 of 29.

    NOT CHANGED. LookupName still returns getaddrinfo's first answer, of
    either family, so which address a name resolves to is the same as
    before. A name with both kinds of address may come back as IPv6 - on
    the Windows 11 machine the test ran on, localhost answers ::1 first -
    so read sin_family before sin_addr; LookupNameEx and LookupHost, which
    prefer an IPv4 address, are unchanged. An Open by a host name that does
    not resolve still raises "No address specified", with ErrorCode 0
    (entry 57). The lookup still takes as long as the system resolver does:
    no timeout applies to it.


--------------------------------------------------------------------------------
MX DELIVERY: AN OnLog HANDLER THAT RAISES
================================================================================


60. FIXED, BEHAVIOUR CHANGE - an exception raised by the OnLog handler of
    a tSmtpMxAgent left Deliver from four of the agent's five log lines, so
    a failing logger decided the delivery: the next MX was not tried, a
    message that every MX had refused for good was deferred rather than
    bounced, and for a domain with an MTA-STS policy no MX was dialled at
    all

    StreamSec.Mail.SMTPMx.

    Four of the lines are written outside any MX attempt's handler: the
    domain's MTA-STS verdict, "skipping" for an MX that an enforce policy
    does not name, "verifying the certificate of" before an attempt that
    must verify, and "MX ... failed" after each failed attempt. An
    exception from the handler on any of them left Deliver, and tSmtpSpool,
    which takes an agent that raises for one that failed, deferred the
    message with the handler's exception as the reason. The fifth line,
    "delivered to", is written inside the attempt: there the message still
    counted as delivered, but the handler's message became the delivery
    error. Every release from 4.1.2.355, the first with
    StreamSec.Mail.SMTPMx, to 4.1.4.361 has it.

    THE STEP THAT FAILED is tSmtpMxAgent.Log, which called the handler
    with no exception handler of its own.

    WHAT IT LOOKED LIKE: a log handler that fails - on a full disk, or a
    log file that is locked or gone - stops MX delivery. Each retry defers
    the message again, with the log handler's exception as the reason,
    until it expires and is bounced as undeliverable; a 550 from the
    domain's only MX is retried in the same way instead of bounced at once.

    Log now swallows an exception its handler raises, as the agent does for
    OnAttempt (entry 57): nothing an OnLog handler does changes MX fallback,
    the outcome, or whether a failure is permanent, and a handler that
    raised is still called for the lines after it. A program that raised
    in OnLog to stop a delivery can no longer do so.

    HOW IT WAS TESTED. SmtpMxLogRaiseTest, on Win32 and Win64:
    ten MX scenarios over loopback against a scripted SMTP server, with
    MTA-STS from a scripted resolver and a stub fetcher, each check stating
    the outcome tSmtpSpool would record. An OnLog handler raises on the
    MTA-STS line, and the message is delivered; on the skipping line, and
    the MX the enforce policy names is still dialled; on the verifying
    line, and the MX is still dialled - the server offers no STARTTLS, so
    in both nothing is sent in the clear; on the MX failed line after a
    451, and the next MX delivers, and after a 550, which stays permanent;
    on the delivered line, whose exception is not the delivery error; and
    on every line, all three of which reach it. The other three scenarios
    are entry 57's start of an attempt. 42 of 88 checks on work/codexdiag
    4031b3c, the same 46 failing on each platform, with nine of the ten
    scenarios leaving Deliver by the exception; 88 of 88 with this entry
    and entry 57.


--------------------------------------------------------------------------------
MAIL AND ACME RENEWAL: AN OnLog HANDLER THAT RAISES
================================================================================

Four more Log methods called their handler with no exception handler of their
own, the same shape as entry 60's tSmtpMxAgent.Log. Each now swallows an
exception its OnLog handler raises, as that one does and as
TsmCustomMailRetrievalServer.Log has always done: a logger that fails - on a
full disk, or a log file that is locked or gone - no longer changes what the
component does. A program that raised in OnLog to steer the component can no
longer do so.


61. FIXED, BEHAVIOUR CHANGE - an exception raised by the OnLog handler of a
    tSmtpSpool left the queue's own work, so a failing logger stranded a
    message with no retry and no bounce, sent a refused message or a second
    bounce after a restart, killed the delivery thread, or abandoned a
    delivery in progress to a use-after-free

    StreamSec.Mail.SMTPSpool.

    Most of the spool's log lines are written where an exception from the
    handler does more than lose the line. In tSmtpSpool.Attempt the
    unreadable-body line is logged BEFORE GiveUp, so a raise skipped GiveUp:
    the item stayed claimed in the queue, never retried, never expired, and
    OnUndeliverable was never told; after a restart its envelope, now without
    a body, was discarded just as silently. GiveUp logs the "abandoned with
    no bounce" line, and EnqueueBounce the "queued a bounce" line, before the
    message is removed from the queue and its files discarded, so a raise left
    the refused message on disk and a restart delivered it again - or, with a
    bounce already stored, bounced it a second time - and the "queued a
    bounce" line raising was then reported as "could not queue a bounce",
    which it had. The worker's backstop logs "delivery attempt raised"; a
    handler that raised on every line raised there too and the delivery thread
    died at the first deferral, with nothing more delivered until a restart
    and Stop none the wiser. Start logs the count of messages recovered from
    disk before it sets Active and starts its workers, so a raise left a spool
    with queued mail unable to start. Stop logs the DrainTimeout line while a
    delivery is still running; a raise left Stop by the exception with the
    workers not joined, and freeing the spool then freed the lock and the
    events under the live worker - the use-after-free Stop's own comment
    exists to prevent. Every release from 4.1.2.355, the first with
    StreamSec.Mail.SMTPSpool, to 4.1.4.361 has it.

    THE STEP THAT FAILED is tSmtpSpool.Log, which called the handler with no
    exception handler of its own.

    Log now swallows an exception its handler raises. The deferred, abandoned,
    bounce, recovered and drain lines, and the worker's backstop, no longer
    pass a logger's failure on to the queue. Nothing an OnLog handler does
    changes whether a message is delivered, deferred, bounced or retried, and
    a handler that raised is still called for the lines after it.

    HOW IT WAS TESTED. SmtpSpoolLogRaiseTest, on Win32 and Win64:
    seven scenarios over a spool in a temporary directory with an in-process
    delivery agent, an OnLog handler raising on one line each - the deferred,
    unreadable-body, abandoned and both bounce lines, every line, the
    recovered line of Start and the drain line of Stop - and a check per
    scenario for the outcome the queue should reach. 11 of 32 checks passed
    on main 90b8ed8, the same checks failing on each platform; 32 of 32 with
    this entry.


62. FIXED, BEHAVIOUR CHANGE - an exception raised by the OnLog handler of a
    TsmCustomSMTPServer (TsmSMTPServer) failed Start with a listener already
    bound, or dropped a session where a 550 or a 451 was due

    StreamSec.Mail.SMTPServer.

    The server's Log also carries every line of its spool (entry 61) and its
    listeners (entry 63), through SpoolLog and ListenerLog, so a handler that
    raises reaches the queue and the accept loop through here as well. Of its
    own lines, the "listening for" line is logged at the end of
    StartOneListener, after the listener has bound its port and started
    accepting but before the result is assigned to the server's field, so a
    raise orphaned a running listener that StopListeners could not then find:
    Start failed, Active stayed False, the port went on answering SMTP, Stop
    did not stop it, and the next Start met it with a bind error (WSAEADDRINUSE,
    10048). The "mail will be sent UNSIGNED" warning is logged early in Start,
    so a raise there failed Start outright. At end of data,
    tSmtpServerSession.MessageComplete logs a spam-filter refusal, and an
    inbound message-authentication refusal, before returning False, and logs a
    failed store inside its except handler before setting the 451; a raise on
    any of these left MessageComplete by the exception, so the reply - the 550
    the filter asked for, or the 451 for the storage failure - was never sent
    and the connection was dropped instead. Every release from 4.1.2.355, the
    first with StreamSec.Mail.SMTPServer, to 4.1.4.361 has it.

    THE STEP THAT FAILED is TsmCustomSMTPServer.Log, which called the handler
    with no exception handler of its own.

    Log now swallows an exception its handler raises, as the retrieval
    server's Log already did. Start completes and the listener is recorded,
    the end-of-data reply is sent, and the spool and listener lines routed
    through here no longer carry a logger's failure into the queue or the
    accept loop.

    HOW IT WAS TESTED. MailServerLogRaiseTest, on Win32 and Win64
    (shared with entry 63): the server on a loopback inbound port with an
    OnLog handler raising on the listening line, the UNSIGNED warning, the
    spam-filter refusal line and the failed-store line, a loopback client
    driving one transaction, and a check that the port stops answering after
    Stop and that the session is answered rather than dropped. 11 of 27 checks
    passed on main 90b8ed8, the same checks failing on each platform; 27 of 27
    with entries 62 and 63.


63. FIXED, BEHAVIOUR CHANGE - an exception raised by the OnLog handler of a
    tMailListener leaked an accepted socket, or killed the accept thread and
    left the port bound with nothing accepting on it

    StreamSec.Mail.Transport.

    tMailListener.Accepted logs the line that reports an OnPeerConnect handler
    that itself raised, after the socket has been accepted but before it is
    closed, so a raise from the OnLog handler there leaked that socket: the
    peer held an open connection that was never greeted and never closed. The
    accept loop in tMailAcceptDaemon.Execute catches whatever Accepted raises
    and logs "accept loop: ..."; a handler that raised on that line too ended
    the loop and the accept thread, leaving the listener reporting itself
    active with its port bound and nothing accepting on it - the "alive, and
    deaf" state the loop's own comment exists to prevent. The SMTP and POP3/
    IMAP servers route this through their own Log (entries 62 and the
    already-guarded retrieval server), so this reaches a listener used on its
    own. Every release from 4.1.2.355, the first with StreamSec.Mail.Transport,
    to 4.1.4.361 has it.

    THE STEP THAT FAILED is tMailListener.Log, which called the handler with
    no exception handler of its own.

    Log now swallows an exception its handler raises. A refused connection is
    closed, the accept loop goes on, and a logger that fails can no longer
    make a bound port deaf.

    HOW IT WAS TESTED. MailServerLogRaiseTest, on Win32 and Win64
    (shared with entry 62): a fixture listener on a loopback port whose
    OnPeerConnect raises for the first connection, with an OnLog handler
    raising on the refusal line and on every line, and a check that the
    refused connection is closed and the next one greeted. Counted with entry
    62 above.


64. FIXED, BEHAVIOUR CHANGE - an exception raised by the OnLog handler of a
    TsmAcmeRenewalManager ended a renewal pass, skipped OnRenewed after the CA
    had issued, or killed the renewal worker while Running still read True

    StreamSec.Mobile.AcmeRenewal.

    The manager's scheduling and renewal lines are written across a pass that
    its worker, or EvaluateOnce, drives. EnsureSchedule logs the issuing-now,
    ARI and no-ARI lines and Renew the "issuing"/"renewing" line before an
    order is placed; a raise from the handler on any of them was caught by
    Tick's own per-certificate handler as a failed renewal, so the
    certificate was backed off and OnRenewalFailed was told the log handler's
    message as the error, with no order ever placed. Renew logs "renewed"
    after the CA has issued and the leaf has been updated but before OnRenewed
    fires, so a raise there left the renewed certificate uninstalled in
    host-driven mode and reported a failure for a success. The backoff and
    give-up lines are logged by HandleFailure, which runs inside Tick's
    handler and logs before it calls OnRenewalFailed, so a raise there escaped
    Tick: EvaluateOnce left by the exception, OnRenewalFailed - the alert -
    never fired, the rest of the pass's certificates were skipped, and on the
    worker thread, whose loop does not guard Tick, the thread died while
    Running still reported True and RetryNow and Poke did nothing. Manage logs
    a line for a certificate it found in the client's PFX, so with
    ManageClientCertificate set a raise there failed Start. Every release from
    4.1.1.354, the first with StreamSec.Mobile.AcmeRenewal, to 4.1.4.361 has
    it.

    THE STEP THAT FAILED is TsmAcmeRenewalManager.Log, which called the
    handler with no exception handler of its own.

    Log now swallows an exception its handler raises. A pass runs to its end,
    OnRenewed fires for a certificate the CA issued, OnRenewalFailed is told
    of a real failure, and the worker survives a logger that fails.

    HOW IT WAS TESTED. AcmeRenewalLogRaiseTest, on Win32 and Win64:
    seven scenarios against a plain-HTTP stub CA on loopback that speaks
    enough ACME for a host-driven issuance and can answer with a transient or
    a permanent problem, an OnLog handler raising on each line in turn, and a
    check per scenario for whether the order was placed, OnRenewed fired, the
    certificate was backed off or given up, and the worker kept running. 15 of
    38 checks passed on main 90b8ed8, the same checks failing on each
    platform; 38 of 38 with this entry.


--------------------------------------------------------------------------------
MAIL AND ACME RENEWAL: AN EVENT HANDLER OTHER THAN OnLog THAT RAISES
================================================================================

The OnLog fixes of entries 61 and 64 left the same components' other events
unguarded, and those are reached on paths that then finish the work - a
delivery, a bounce, an issuance, a renewal pass - so an exception from one of
them changed what the component did, exactly as a raising OnLog used to. Each
such call is now wrapped the same way.


65. FIXED, BEHAVIOUR CHANGE - an exception raised by the OnDelivered,
    OnDeferred or OnUndeliverable handler of a tSmtpSpool left the queue's own
    work, so a failing handler delivered a message a second time after a
    restart, stranded a refused message with no bounce, or logged a false
    fatal

    StreamSec.Mail.SMTPSpool.

    These three events are the siblings of the OnLog handler of entry 61, and
    each is called on a path that then finishes the message, so an exception
    from the handler did more than lose a notification. Complete calls
    OnDelivered BEFORE DiscardFiles, the list removal and the Free, so a raise
    left the delivered message on disk and in the queue, Delivered did not
    count it, and after a restart it was delivered again. GiveUp calls
    OnUndeliverable before the bounce (or the abandoned line), DiscardFiles and
    the list removal, so a raise sent no bounce - the sender was never told -
    left the files on disk, and a restart re-attempted the refused message
    every time. Defer calls OnDeferred after the claim is released and the
    retry is saved, so a raise there could not lose the message, but the
    "deferred" line was skipped and the worker's backstop logged a false fatal
    "delivery attempt raised" in its place. Every release from 4.1.2.355, the
    first with StreamSec.Mail.SMTPSpool, to 4.1.4.361 has it.

    THE STEP THAT FAILED is tSmtpSpool.Complete, Defer and GiveUp, each of
    which called its event handler with no exception handler of its own.

    Each now wraps its handler call in try/except, as entry 61 did for Log.
    DiscardFiles, the list removal, the Free and the bounce all run whatever
    the handler does, so nothing an OnDelivered, OnDeferred or OnUndeliverable
    handler does changes whether a message is delivered once, deferred,
    bounced or retried.

    HOW IT WAS TESTED. SmtpSpoolEventRaiseTest, on Win32 and Win64:
    four scenarios over a spool in a temporary directory with an in-process
    delivery agent, a handler raising from OnDelivered, OnDeferred or
    OnUndeliverable (the last on a bounce and on an abandon), and a check per
    scenario for the outcome the queue should reach, including that a restart
    neither re-delivers a delivered message nor re-refuses a bounced one. 6 of
    24 checks passed before this entry, the same checks failing on each
    platform; 24 of 24 with it.


66. FIXED, BEHAVIOUR CHANGE - an exception raised by the OnRenewed,
    OnRenewalFailed or OnClassifyError handler of a TsmAcmeRenewalManager
    turned an issued certificate into a backed-off failure, or escaped Tick and
    killed the renewal worker while Running still read True

    StreamSec.Mobile.AcmeRenewal.

    These three events are the siblings of the OnLog handler of entry 64. Renew
    calls OnRenewed after the CA has issued and the leaf has been updated; a
    raise there was caught by Tick's own per-certificate handler as a failed
    renewal, so the certificate was backed off and OnRenewalFailed was told the
    handler's message - a success reported as a failure, and in host-driven
    mode the new certificate, installed from OnRenewed, was never installed.
    Backoff and GiveUp call OnRenewalFailed, and HandleFailure calls
    OnClassifyError before the verdict, all inside Tick's handler, so a raise
    there escaped Tick: EvaluateOnce left by the exception, the rest of the
    pass's certificates were skipped, and on the worker thread, whose loop does
    not guard Tick, the thread died while Running still reported True and
    RetryNow and Poke did nothing; OnClassifyError raising also skipped the
    backoff or give-up and the OnRenewalFailed alert entirely. Every release
    from 4.1.1.354, the first with StreamSec.Mobile.AcmeRenewal, to 4.1.4.361
    has it.

    THE STEP THAT FAILED is TsmAcmeRenewalManager.Renew, Backoff, GiveUp and
    HandleFailure, each of which called its event handler with no exception
    handler of its own.

    Each now wraps its handler call in try/except, as entry 64 did for Log. An
    issuance stands and OnRenewed's failure does not back the certificate off;
    a raise from OnRenewalFailed or OnClassifyError no longer escapes Tick, so
    the pass runs on and the worker survives, and OnClassifyError's failure
    leaves the built-in transient/permanent verdict to stand.

    HOW IT WAS TESTED. AcmeRenewalEventRaiseTest, on Win32 and Win64:
    four scenarios against a plain-HTTP stub CA on loopback that speaks enough
    ACME for a host-driven issuance and can answer with a transient or a
    permanent problem, a handler raising from OnRenewed, OnRenewalFailed (under
    EvaluateOnce and on the worker thread) or OnClassifyError, and a check per
    scenario for whether the issuance stood, the certificate was backed off,
    OnRenewalFailed was told, the pass tried every certificate and the worker
    kept renewing after RetryNow. 9 of 21 checks passed before this entry, the
    same checks failing on each platform; 21 of 21 with it.


--------------------------------------------------------------------------------
HTTP CLIENT: SYSTEM NAME RESOLUTION WITH A REQUEST DEADLINE
================================================================================

67. REDACTED - Bounded system name resolution
    consolidated into entry 37. This number is retained for reference.


--------------------------------------------------------------------------------
TLS: RECORD-FREE TLS 1.3 HANDSHAKES FOR QUIC
================================================================================

68. NEW - TLS 1.3 sessions can exchange QUIC CRYPTO data and traffic secrets
   without creating a TLS record layer

   TsmStreamSecII.TLSAddQUICClientSession and TLSAddQUICServerSession reuse the
   existing TLSOptions, certificate validation, client authentication, exporter,
   retry and PSK resumption support. TTLS_ContentLayer.StartQUIC and
   ReceiveQUICHandshake drive the handshake; iQUICTLSHandler receives raw
   handshake bytes and direction-specific traffic secrets at explicit QUIC
   encryption levels. The sessions require TLS 1.3, ALPN and QUIC transport
   parameters, and reject TLS-only messages. They create no TLS records.

   TTls13KeySchedule.QUICInitialSecrets and QUICPacketKeys derive protection
   material for QUIC v1 and v2. The transport supplies the wire version and
   connection ID, validates its transport parameters and handles packets,
   streams, retransmission and key discard. See TLS.txt for the callback and
   buffer contracts. QUIC early data is opt-in; entry 119 describes it. TLS
   record sessions retain their existing behavior. Entry 95 adds the QUIC and
   HTTP/3 server components.

   FPC builds exclude legacy stDES imports and dependent DES/3DES class
   mappings, reject explicit DES/3DES selections and do not offer 3DES cipher
   suites. This exclusion is required only for FPC compatibility. Delphi and
   the other TLS providers retain their existing linking policy; FPC stDES
   support for legacy encrypted files remains a separate backlog item.


--------------------------------------------------------------------------------
ASN.1: FPC SOURCE COMPATIBILITY
================================================================================

69. FPC COMPATIBILITY - explicitly compare pointers when unregistering an
   ASN.1 mapped class

   This source adjustment is only required for FPC compatibility. Delphi
   accepts the comparison between an untyped pointer and a class reference in
   tASN1Base.UnregisterMappedClass; FPC 3.3.1 rejects it. The class reference is
   now explicitly converted to Pointer before comparing addresses. The mapping
   operation and pointer width are unchanged.


70. FPC COMPATIBILITY, BEHAVIOUR CHANGE - define the tag metadata of an
   unselected ASN.1 CHOICE without calling an abstract ancestor

   This source adjustment is only required for FPC compatibility. Delphi
   already compiled the old source, but FPC 3.3.1 rejects the direct call to
   abstract tASN1Base.GetCls in tASN1CustomChoice.GetCls.

   The CHOICE accessors GetCls, GetConstructed and GetTag consistently describe
   an unselected value as Universal class, not constructed, and undefined tag,
   matching the existing generic CHOICE metadata. GetConstructed already
   returned False; GetTag's undefined fallback is now explicit. GetCls now
   returns Universal instead of reaching an abstract-method error on Delphi
   when queried before selection. A tag remains undefined until a choice is
   selected. Metadata reads neither select alternative zero nor force pending
   input to be decoded. Selected choices continue to report their data's class,
   constructed flag and tag.


--------------------------------------------------------------------------------
ASN.1: NON-WINDOWS CLASS MAPPING
================================================================================

71. FIXED - search only populated ASN.1 mapped-class entries on non-Windows
   platforms

   RegisterAsMappedClass now bounds its binary search by fClassCount, matching
   GetPlaceHolderVMTAddress. It previously searched Length(fClasses), including
   unused zero-filled capacity allocated in blocks of 1,024 entries. That range
   is not sorted by class address: a search could miss an existing mapping and
   append a duplicate instead of replacing it, leaving lookup and subsequent
   unregistering or re-registration using the old entry.

   The non-Windows mapping table now preserves its sorted populated range and
   updates an existing entry when overriding a mapped class. The separate
   Windows implementation is unchanged. This is a non-Windows runtime fix,
   independent of the FPC source compatibility adjustments in entries 69-70.


--------------------------------------------------------------------------------
FPC: DSI ARITHMETIC TARGET
================================================================================

72. FPC COMPATIBILITY - exclude the legacy MP backend from FPC targets

   The FPC profile in ver.inc now defines DSI_ONLY automatically. Existing
   conditional sections exclude the legacy stMPArithTypes/stMPPKTypes path and
   its ASN.1 overloads. FPC targets use the DSI arithmetic backend; the legacy
   MP backend is outside the supported FPC target.

   This also removes the FPC 3.3.1 assembler-symbol collisions between the two
   EC-point overload families in tASN1Base. The DSI interfaces and overloads
   retain their existing names and signatures. This profile adjustment applies
   only to FPC; Delphi retains its existing backend selection.


--------------------------------------------------------------------------------
FPC: BASE64 TABLE INITIALIZATION
================================================================================

73. FPC COMPATIBILITY - initialize the Base64 table through the string overload

   This source adjustment is only required for FPC compatibility. InitCharTable
   now explicitly converts the fixed character table to UnicodeString before
   calling TEncoding.ASCII.GetBytes. FPC requires TUnicodeCharArray for its
   array overload, while Delphi also accepts a fixed array through an open
   array parameter. The string overload converts the complete 65-character
   alphabet, including its final '=' padding character, to the same ASCII bytes.


--------------------------------------------------------------------------------
SSH: THE APPLICATION SELECTS ITS ASYMMETRIC PROVIDERS
================================================================================

74. NEW, BEHAVIOUR CHANGE - linking SSH key agreement no longer links the
    asymmetric implementations

    Applications that relied on StreamSec.SSH.KeyAgreement to pull in their
    public-key engines must now add the needed implementation units to a uses
    clause. Fixed-group DH needs StreamSec.DSI.FFC; X25519, X448 and NIST ECDH
    need StreamSec.DSI.ECC; sntrup761/X25519 needs StreamSec.DSI.Sntrup761 and
    StreamSec.DSI.ECC. Pure ML-KEM needs StreamSec.DSI.MLC. The ML-KEM hybrids
    need StreamSec.DSI.CompositeKEM, StreamSec.DSI.MLC and StreamSec.DSI.ECC.
    Host and user key types have their own provider requirements.

    Each built-in KEX option now implements SuggestRequiredUnits for its
    providers, hash and random source. The SSH component's existing
    SuggestRequiredUnits mechanism collects those requirements from its
    selected KexOptions, so the IDE can add the application dependencies.
    KEX availability also checks the registered providers and required curve;
    an exchange whose engine is missing is excluded from the available offer.

    StreamSec.SSH.KeyFormat no longer links EC arithmetic merely to obtain
    OID constants. Its availability checks return an unavailable format when
    a provider is absent, rather than raising a missing-provider exception
    while the component is being constructed.

    The finite-field parameter interface iFFSystemParams is now declared in
    StreamSec.DSI.PKTypes. StreamSec.DSI.FFC retains an alias with the same
    interface identity and signatures. SSH's fixed groups obtain parameters
    from the registered provider instead of inheriting its implementation.

    VERIFIED with standalone Win32 and Win64 applications linking no PK
    provider, individual provider families and the providers for hybrid KEX;
    required-unit suggestions, availability and fixed-group DH are checked.

    Required-unit suggestions include configured cipher and MAC implementations.
    A selected Edwards SSH algorithm suggests its own hash; a generic EdDSA key
    component suggests both hashes because its curve may be chosen at run time.

75. NEW, BEHAVIOUR CHANGE - SSH Snip components obtain their PK providers
    from the application and report them through SuggestRequiredUnits

    TsnipClient and TsnipServer no longer force-link the RSA, finite-field,
    elliptic-curve, EdDSA, ML-KEM or composite-KEM implementations. Applications
    using the default ML-KEM/X25519 exchange must link StreamSec.DSI.MLC,
    StreamSec.DSI.ECC and StreamSec.DSI.CompositeKEM. The default RSA server
    host key also needs StreamSec.DSI.IFC. A client's default verification
    choices additionally need StreamSec.DSI.EdDSA for Edwards host keys.

    SuggestRequiredUnits on the high-level components forwards the configured
    SSH algorithm requirements. The server includes the key component selected
    by HostKeyKind; client host-key choices report their selected formats and
    hashes. A client authentication key contributes its requirements when
    publickey login is selected, without loading private key material. The
    lower-level TsnipSSHClient and TsnipSSHServer forward requirements from
    their assigned SSH components. The standard component editor can now reach
    these hooks through TstBaseComponent.

    Configured KEX and host-key names remain available for discovery when their
    providers are absent, including after assignment and component streaming.
    They are excluded from negotiation until their engines are registered.
    Replacing or clearing the configuration updates the suggested units.

    The shared KAPA helper also uses the registered composite-KEM provider
    instead of linking its implementation through the authentication unit.
    Applications calling those helpers directly must link their providers.

    TLS retains its intentional forced linking inherited from the original
    implementation. Its provider imports and selection policy are preserved.

    VERIFIED on Win32 and Win64: isolated no-provider, suggested-provider and
    TLS-control applications pass 1,166 assertions. Full Snip connection and
    restart tests pass 12 checks per target; SSH host-key pinning passes 331
    checks per target. Runtime packages build with XE3 and Delphi 13 for both
    targets. A script reproduces the focused provider matrix.

    The Delphi 13 SSH and Snif demos now explicitly link their configured PK
    providers in the application uses clauses. Examples selecting all KEX
    algorithms include the RFC 9941 SNTRUP761 provider. In-memory examples and
    the forwarding DLL need no additional PK implementation. All 16 demo and
    example projects build against the updated library for Win32 and Win64
    (32 successful builds); their developer readmes describe the dependency
    policy. TLS provider linking is unchanged.

    Snip suggestions include the signature hashes selected by HostKeyKind.
    Cipher, MAC and key-file requirements remain discoverable and streamable
    without their providers; loading an unpinned client preserves its declared
    verification choices. Assigning or destroying an option list preserves other
    pending declarations with the same algorithm name. Cleanup unregisters the
    specific option and tolerates changes to initialization lists during
    release.

--------------------------------------------------------------------------------
FPC: CERTIFICATE COLLECTION TEXT OVERRIDES
================================================================================

76. FPC COMPATIBILITY - match the RTL string type in certificate collections

   This source adjustment is only required for FPC compatibility.
   TCertificateItem.GetDisplayName and TCertificateCollection.GetAttr and
   GetItemAttr now return tRtlString, matching the AnsiString results of FPC's
   Classes ancestors. Delphi retains its native Unicode string signatures.

   Certificate subject values remain Unicode internally. Display names are
   assembled as Unicode and converted at the collection text boundary, using
   the RTL's configured string conversion. The collection labels and the
   existing CN, O and OU display format are unchanged.


--------------------------------------------------------------------------------
SNIP CLIENT: NESTED OPTION STREAMING
================================================================================

77. FIXED - TsnipClient preserves its nested SSHClient options in component
    files

    The owned SSHClient is now a Delphi subcomponent. Its nested design-time
    options are saved in the form and survive reloading instead of reverting
    to constructor defaults. The published SSHClient and SelectedOptionNames
    properties already existed in release 4.1.4.361; their streaming contract
    is preserved. Provider discovery belongs to the new policies in 74 and 75.

--------------------------------------------------------------------------------
FPC: LINUX SOCKET BACKEND
================================================================================

78. FPC COMPATIBILITY - enable the POSIX socket backend for FPC Linux

   This source adjustment is only required for FPC compatibility. The socket
   factories and datagram helpers now select the existing POSIX backend on
   FPC Linux, using the target RTL types and native operating-system bindings.
   Delphi retains its existing backend selection and native calls.

   The FPC bindings preserve system hostname resolution and the existing
   nonblocking TCP, poll/self-pipe wake, close, source binding and UDP behavior.
   IPv4/IPv6 datagrams retain zero-length messages, truncation reporting and
   explicit IPv6-only binding. Native errors come from the same thread-local
   errno as the operating-system calls. FIONREAD uses the target RTL constant,
   including the distinct value required on MIPS Linux. The FPC MIPS bindings
   also use the Linux MIPS socket-option constants where FPC 3.3.1 supplies
   generic Linux values that the MIPS kernel does not accept.


--------------------------------------------------------------------------------
QUIC: PACKET WIRE FORMAT AND PROTECTION
================================================================================

79. NEW - native QUIC packet and header-protection primitives

   StreamSec.Quic.Wire provides bounded variable-length integer and packet
   header parsing, coalesced-packet boundaries, packet-number reconstruction
   and unprotected header encoding for QUIC v1 and v2.

   StreamSec.Quic.Protection reuses the existing AES-GCM and ChaCha20-Poly1305
   implementations for packet protection, AES/ChaCha header protection and
   version-specific Retry integrity. Authenticated output buffers are
   independent; rejected packets return explicit empty outputs. The existing
   ChaCha block routine is available to protocol subclasses for this use.

   These units are building blocks for the native QUIC transport and HTTP/3
   implementation. Packet-number spaces, connection policy and stream/recovery
   state remain the responsibility of the transport layer.


--------------------------------------------------------------------------------
QUIC: CONNECTION HANDSHAKE TRANSPORT
================================================================================

80. NEW - QUIC connection state, CRYPTO reassembly and transport parameters

   StreamSec.Quic.Connection tracks independent packet-number spaces,
   directional encryption-key availability, TLS handshake completion and
   QUIC confirmation. Initial and Handshake keys are discarded at their
   protocol milestones. Peer transport parameters remain tentative until
   TLS completion; authenticated ALPN is required before activation.

   StreamSec.Quic.Crypto provides bounded, ordered CRYPTO delivery from
   reordered and overlapping frames, with independent offsets per encryption
   level. Byte and range limits bound buffering; conflicting buffered bytes
   and new data at a previous TLS encryption level are rejected. Output
   chunks retain their original level for the packet and recovery layer.

   StreamSec.Quic.Parameters encodes and validates the RFC 9000 parameters,
   including duplicate identifiers, required and forbidden fields, value
   limits and observed Initial/Retry connection IDs. Unknown parameters are
   skipped within the extension's size limit. Returned parameter snapshots
   are independent of their inputs.

   These are transport building blocks. Entry 119 adds opt-in early data.


--------------------------------------------------------------------------------
SNIP SSH SERVER: HOST-KEY SELECTION AFTER RESTART
================================================================================

81. FIXED - changing HostKeyKind between Stop and Start retires the previous
    owned host-key selection

    Restarting the same TsnipServer with a different HostKeyKind no longer
    continues to offer the previously selected owned RSA, ECDSA or EdDSA key.
    Start removes those old associations after setting up the new host key,
    before selecting the available signature algorithms.

    Generated key material is retained for reuse when switching back to an
    earlier kind. Host keys explicitly assigned through SSHServer for other
    host-key kinds are preserved when they are not the component's corresponding
    owned key.

    VERIFIED on Win32 and Win64: all six key-kind transitions, same-kind
    restarts, key reuse and external-key preservation (327 checks per target).

--------------------------------------------------------------------------------
QUIC: FRAMES, ACKNOWLEDGEMENTS AND STREAMS
================================================================================

82. NEW - QUIC frame dispatch, ACK tracking, streams and flow control

   StreamSec.Quic.Frames encodes and validates core QUIC frames, including
   encryption-level and sender restrictions. Validated frame views retain
   read-only packet storage and locate Data by offset/count. Packet
   construction, outgoing validation, ACK/loss retirement and
   CID/path/key-update bookkeeping avoid copying payload bytes. Existing owning
   frame decoding and inbound application delivery keep independent Data
   storage. Per-method comments specify retained references, read-only aliases
   and release/rebinding rules. Packet/frame/range bounds, complete validation
   before dispatch and Commit's canonical re-encoding guard remain in force.
   Metadata, borrowed slices, retaining views and owning decoding share direct
   frame validation without intermediate retaining-view copies. Owning Data is
   materialized once; partial outputs are explicitly cleared on failure.
   Outgoing batches use bounded metadata slots without per-frame packet
   references. StreamSec.Quic.Transport dispatches authenticated payloads,
   suppresses duplicate packet effects and schedules ACKs separately in each
   packet-number space. ACK triggers are retained until a covering
   acknowledgement is actually transmitted.

   StreamSec.Quic.Ack tracks bounded receive ranges and sent-packet history.
   ACKs covering packet numbers never sent are rejected; acknowledged stream
   bytes, FIN and reset state are retired once. ACK-only packets retain sent
   history without retaining unnecessary retransmission buffers.
   Recording a sent packet, retiring acknowledged ones and finding a pending
   packet do not copy the other pending packets: an acknowledgement visits
   only the packets up to its Largest Acknowledged and allocates only the list
   it returns. Before, every packet sent rebuilt the whole pending list, so
   the cost per packet grew with the packets in flight; over Wi-Fi, where far
   more are in flight than on loopback, that took half of the sending
   server's CPU time. Measured on that LAN, the server sends 53-55% faster at
   45-50% less CPU per byte.

   StreamSec.Quic.Streams provides sparse bidirectional and unidirectional
   stream state, ordered bounded reassembly, final-size validation and
   connection/stream flow limits. Reading data and releasing managed buffer
   references do not grant more credit; advertised maxima change explicitly.
   Send buffers remain available until acknowledged or reset acknowledgement.
   Immutable send slices retain const TBytes with offset/count metadata. ACK
   trimming and splitting preserve the backing array without copying tails;
   packet assembly reads the selected slice into independent output storage.
   The caller may release or replace its array variable, but neither party
   may modify shared elements through another alias while retained.
   Physical allocation charges remain until the last fragment retires, separate
   from logical buffered-byte counters, and constrain send and receive
   admission. Partial sends copy only their slice when retaining a larger
   allocation would exceed the physical budget. FIN-only sends retain no
   unrelated buffer.

   These units are transport building blocks. Packet scheduling, loss/PTO,
   congestion control and the host's CID/path management remain separate.

   Packet frame storage grows geometrically from a small allocation up to the
   existing frame-count bound. Complete-packet validation precedes dispatch:
   malformed or over-limit batches cannot partially reach application callbacks.
   The dispatcher caches validated scalar ACK and stream limits, while retaining
   authentication, phase/key checks and early-to-fresh parameter transitions.
   Public transport-parameter snapshots remain independent; recurring stream
   access needs no new snapshots after creation or fresh-limit application.

   The stream manager finds a stream through a hashed index in constant
   expected time instead of scanning every retained stream. Peers choose stream
   IDs, so each connection keys the index with its own random value; a
   standalone manager uses a fixed key. The manager also keeps a first-in,
   first-out queue of the streams that need the application: data or FIN
   readable now, a received reset, a first STOP_SENDING, or the first input on
   a locally initiated stream. A stream is queued at most once and stays queued
   while readable data remains; queuing never allocates. Creation order,
   enumeration and stream state are unchanged.

   A stream can be retired once its data, resets and acknowledgements are
   settled in both directions and the application has released it. Its record
   is freed and its ID is remembered in a per-type floor or a sparse range, so
   a late frame for it, a conflicting final size included, is ignored and
   cannot reopen it. Retirement never grants credit. Only materialized records
   and retired ranges count against MaxStreams.

   An ACK frame carries at most the eight newest ranges, starting with the
   largest packet received; up to 64 ranges are still retained for duplicate
   detection and accepted in incoming ACKs. The receive history is pruned as
   RFC 9000 section 13.2.4 describes: the dispatcher saves the Largest
   Acknowledged of each ACK frame it sends, and once the peer acknowledges a
   packet that carried one, every range at or below that value is released and
   a late packet below it is treated as too old. A history emptied that way
   leaves no acknowledgement pending. Before, no range was ever released: under
   sustained loss the history filled to 64 ranges and every ACK frame repeated
   all of them. tQuicClient and TsmAsyncQUICServer both use the dispatcher.

--------------------------------------------------------------------------------
QUIC: LOSS RECOVERY AND CONGESTION CONTROL
================================================================================

83. NEW - QUIC loss recovery, RTT estimation, PTO and NewReno

   StreamSec.Quic.Recovery detects packet-threshold and time-threshold loss
   independently in each packet-number space. RTT estimation and NewReno
   congestion accounting are shared across the current path. RTT samples
   account for peer ACK delay and handshake confirmation; timers saturate
   instead of wrapping on overflow.

   Probe timeouts request a bounded number of ack-eliciting probes and apply
   exponential backoff. A PTO alone neither declares packets lost nor reduces
   the congestion window. Old-key discard removes flight state without a loss
   signal. Address-validation and amplification blocking constrain PTO use.

   StreamSec.Quic.Congestion supplies slow start, congestion avoidance,
   recovery epochs and persistent-congestion reduction. Packet lengths include
   QUIC headers and authentication overhead. Explicit application/flow-limited
   sends do not grow the congestion window when acknowledged.

   The frame dispatcher integrates recovery with validated ACKs, actual sends
   and key discard. It exposes loss notifications, timer deadlines and finite
   probe permission. Late ACKs cannot subtract flight bytes twice. An old lost
   packet association can be retired after its recovery obligations have been
   transferred or satisfied; sent-number history remains valid for late ACKs.

   Packet assembly, retransmission selection, pacing, path validation and ECN
   validation remain host responsibilities. Entry 119 adds opt-in early data.

   Congestion-window utilization is classified across the whole send burst and
   all packet-number spaces. A short application- or flow-limited burst cannot
   grow the window through its earlier ACKs. ACKs retire bytes in flight at
   once; growth credit waits until demand proves utilization. Pacing, socket
   pressure and a finite send budget do not falsely classify busy work as
   limited. Loss, validated ECN, path changes and key-space discard invalidate
   pending credit, and probes cannot manufacture ordinary demand. Both UDP hosts
   enable the accounting; direct recovery users may opt in with
   EnableUtilizationEpochs and report utilization. Existing per-packet entry
   points remain supported.

--------------------------------------------------------------------------------
DELPHI: COMPILER WARNINGS
================================================================================

84. FIXED - define the fallback result for out-of-range OID extraction

   stDERUtils.ExtractSubIden uses a runtime bounds condition for its assertion
   and explicitly assigns the fallback result. Assertions still fail for an
   out-of-range cursor when enabled; disabling assertions still returns zero.
   The runtime predicate avoids relying on compiler analysis of Assert(False)
   before the fallback, for compatibility with earlier compilers.

85. FIXED - avoid an implicit Unicode-to-ANSI conversion in PEM signature lookup

   TstPEMMessage.CheckMICInfo supplies the signature algorithm identifier
   through OSToASCIIA, matching the lookup's AnsiString argument.

86. FIXED - construct CAdES DER identifiers from explicit bytes

   SHA-256, SHA-384 and SHA-512 AlgorithmIdentifiers and the archive timestamp
   attribute OIDs use ByteConstToOS with byte constants. Their binary octets no
   longer pass through implicit Unicode-to-byte string conversions.

87. CHANGED - localize platform-warning handling in design-time registration

   StreamSec.DSI.PKIReg disables UNIT_PLATFORM around its deliberate Windows
   certificate-store import and re-enables it immediately after the uses clause.

   VERIFIED for 84-87: full StrSecIV370 and DStrSecIV370 Debug/Win32 builds
   completed with no errors or warnings (26 existing runtime hints).
   Focused ExtractSubIden checks passed with compiler versions 27, 36 and 37,
   with assertions enabled and disabled, without warnings or hints.

--------------------------------------------------------------------------------
QUIC: TLS/UDP CLIENT AND RECOVERABLE OUTPUT
================================================================================

88. NEW - QUIC client integrates record-free TLS, UDP and recoverable output

   StreamSec.Quic.Client drives the existing TLS engine and UDP socket on a
   bound UDP path. Authenticated packets enter frame dispatch before TLS
   consumes reassembled CRYPTO data. Bounded deferred packets allow handshake
   encryption levels to arrive out of order. TLS configuration and certificate
   validation continue to use the existing host and session objects.

   StreamSec.Quic.Output assembles protected-packet headers and plaintext
   payloads within an exact UDP budget, including authentication overhead and
   header-protection sampling. Client Initial datagrams receive authenticated
   padding to at least 1200 bytes. A separate helper validates coalescing.

   Loss and PTO select retained CRYPTO ranges, unacknowledged stream bytes,
   FIN/reset state and current flow-control advertisements. Late ACKs suppress
   queued retransmissions. UDP would-block and failed sends leave work queued;
   replacement packets use fresh packet numbers. Only actual transmission
   updates flight accounting, ACK triggers and encryption-key discard.

   The client supports QUIC v1/v2 and exposes ordered streams. Entry 95 adds
   the server and listener, and entry 119 opt-in early data. Intentional TLS
   cryptographic provider linking is preserved.

   Packet/header and CRYPTO/STREAM fit calculations use byte counts and minimal
   integer widths, retaining validation, MTU/padding limits and canonical wire
   output. Output readiness and stale-stream pruning inspect range metadata
   without copying payload slices or altering staged sends and fair cursors.
   Utilization observation keeps application/flow limits distinct from
   congestion, pacing and socket backpressure. Buffer ownership and protocol
   budgets are unchanged by these internal choices.

--------------------------------------------------------------------------------
QUIC: SEND SCHEDULING, PACING AND CLIENT NEGOTIATION
================================================================================

89. NEW - QUIC client schedules streams, paces packets and handles Retry and
   version negotiation

   StreamSec.Quic.Client exposes the next send, ACK or recovery deadline for
   an external event loop. Stream selection rotates after actual sends and
   alternates queued control frames with stream data. CRYPTO remains a higher
   priority. Pacing limits in-flight traffic to the congestion window divided
   by smoothed RTT. A burst holds what that rate delivers in 1 ms: at least
   two and at most ten datagrams, and never more than the RFC 9002 initial
   window, so a fast path sends up to ten datagrams back to back and a slow
   one two (tQuicPacer's new maximum-burst parameter; without it the bucket
   stays a fixed one). Pure ACK packets bypass
   pacing; padded packets consume credit. PTO probes use finite recovery credit
   and retain pacing debt. A blocked or failed UDP send commits no pacing or
   output state.

   Integrity-validated Retry updates Initial keys and carries the server token
   into later Initial packets, preserving the ClientHello, source connection ID
   and packet-number sequence. Invalid, repeated or late Retry packets are
   ignored. Recovery and congestion accounting restart without reporting
   discarded packets as acknowledged or lost.

   A valid Version Negotiation packet can restart the client once on another
   configured QUIC v1/v2 version, using fresh connection IDs and a fresh TLS
   session. Authenticated version_information transport parameters detect
   inconsistent version selection and negotiation downgrade before the TLS
   handshake completes. The client advertises its current version and does not
   switch to a compatible version within a handshake.

--------------------------------------------------------------------------------
DELPHI: OPT-IN PACKAGE PLATFORM WARNINGS
================================================================================

90. CHANGED - make Windows package platform-warning suppression opt-in

   StrSecIV370 uses ST_SUPPRESS_PACKAGE_PLATFORM_WARNINGS to suppress W1005 only
   at its PkixKeyStorageWinCert, stCryptoAPI and CAPIExtKey package references.
   Each reference saves and restores the previous compiler warning settings with
   PUSHOPT/POPOPT. The units retain their platform directives, and omitting the
   define preserves the selected warning policy.

   The runtime package enables the define only for Debug/Win64, preserving
   inherited conditional defines and other build configurations.

   VERIFIED: full StrSecIV370 and DStrSecIV370 Debug/Win64 builds completed
   with no errors or warnings (32 existing runtime hints, no design-time
   hints).

--------------------------------------------------------------------------------
QUIC: CONNECTION IDENTITIES, PATHS AND CONNECTION LIFETIME
================================================================================

91. NEW - QUIC client manages connection IDs, validates migration paths,
   discovers path size and enforces idle and close timers

   Connection IDs have bounded identity histories, active limits and reliable
   issue/retirement controls. An ID is committed as used only after actual UDP
   transmission and is not reused on another path. Stateless reset detection
   checks used, unretired tokens for the peer address, even when the datagram
   header cannot be parsed. A separate helper constructs a reset smaller than
   its triggering datagram; active connections send CONNECTION_CLOSE.

   tQuicClient.Migrate validates a caller-bound socket with a fresh peer ID.
   Application traffic continues on the active path until a 1200-byte challenge
   succeeds. Failed validation leaves that path usable. Migration respects the
   authenticated peer policy and preferred address. Unsolicited server address
   changes are ignored. Path responses return on their receive tuple. Old
   packets retain delivery records without changing the new path's RTT or
   congestion window.

   The path starts at 1200 bytes. ConfigurePathMtu enables bounded growth before
   Start; only an authenticated acknowledgement of an exact probe establishes a
   larger size. Probe loss narrows the search without a congestion-window cut,
   and confirmed base-size delivery can recover from a path-size black hole.
   QUIC requests do-not-fragment from the socket backend. Other UDP callers
   retain their existing defaults.

   The negotiated idle timeout expires silently. Closing permits bounded,
   rate-limited replies; draining sends nothing. The fixed close/drain retention
   deadline releases packet keys and the TLS session. NextWakeup exposes these
   deadlines along with path validation and PMTU work. Sockets remain borrowed.

--------------------------------------------------------------------------------
SOCKETS: BOUNDED HOST LOOKUP SHUTDOWN
================================================================================

92. REDACTED - Host-lookup shutdown and unload policy
    consolidated into entry 37. This number is retained for reference.


--------------------------------------------------------------------------------
QUIC: ECN VALIDATION, KEY UPDATES AND SESSION RESUMPTION
================================================================================

93. NEW - QUIC client validates ECN feedback, updates packet keys and resumes
   bound TLS sessions

   QUIC uses native IPv4/IPv6 datagram ECN metadata and validates authenticated
   ACK_ECN counters against actual transmissions in each packet-number space.
   Validation starts with at most ten ECT(0) packets and restarts on a new path.
   Missing or inconsistent feedback disables marking without closing QUIC.
   Validated current-path CE feedback reaches NewReno once per recovery epoch;
   ambiguous old-path feedback cannot cut the new path's congestion window.
   Optional datagram methods preserve custom backends and ordinary UDP defaults.
   Unsupported ancillary sends fall back to an ordinary send of the same
   protected bytes, without encrypting twice or duplicating the datagram.

   QUIC v1/v2 key updates use their version-specific traffic-secret labels and
   retain the original header-protection key. Authenticated phase changes,
   actual sends and validated ACKs govern advancement. Local updates require
   handshake confirmation and confirmation of the current write keys. Previous
   receive keys expire after a fixed three-PTO interval exposed by NextWakeup.
   Cipher-specific confidentiality and integrity limits prevent further use of
   exhausted keys; failed UDP sends still spend completed encryption usage.
   Packet numbers continue across updates; TLS KeyUpdate is not used. If close
   protection is exhausted, draining stays silent until its fixed deadline.

   CaptureResumptionTicket returns an independent TLS credential and connection
   snapshot. ConfigureResumption binds its use to QUIC version, server name,
   offered application protocol, lifetime and application restoration context.
   A mismatch clears the offer and permits a fresh handshake. Resumed 1-RTT
   sessions use fresh authenticated transport limits, which may be lower.
   Raw TLS ticket properties cannot bypass this client-side binding. Without
   an explicit server name, the client declines resumption and uses a fresh
   handshake; a credential cannot be bound to an IP address alone.

   Remembered transport parameters carry the early-data policy, including the
   required non-reduction checks; entry 119 uses them for opt-in 0-RTT. Invalid
   QUIC ticket early_data values cause PROTOCOL_VIOLATION. Existing TLS record
   resumption, early-data behavior and intentional cryptographic provider
   linking are preserved.

   QUIC ticket snapshots convert lifetime seconds in Double precision, retaining
   the original receipt time, lifetime cap, binding checks and expiry boundary.

--------------------------------------------------------------------------------
HTTP/3: CLIENT CONNECTION ENGINE AND STATIC QPACK
================================================================================

94. NEW - HTTP/3 client framing, QPACK and a QUIC client adapter

   tHttp3ClientConn provides a bounded HTTP/3 client connection engine, with
   tHttp3QuicClient connecting it to the library's authenticated QUIC transport.
   Requests use independent bidirectional streams. Responses support interim
   headers, final headers, body data and trailers, with explicit application
   consumption controlling receive credit. Cancellation, GOAWAY and stream or
   connection errors retain their distinct meanings.

   QPACK uses its 99-entry static table and literal fields, including Huffman
   coding, while advertising zero dynamic-table capacity and zero blocked
   streams. The shared Huffman codec retains the existing HPACK entry points
   and behavior. Field arrays preserve HTTP octets and may be retained as
   shared read-only values, like body TBytes arrays.

   The QUIC client gains StopReceive for receive-side stream cancellation.
   The stream manager exposes read-only stream enumeration, queueable send
   capacity and temporary stream-admission queries. Cancelled receive streams
   return connection credit without extending their stream receive window.

   This is the low-level client engine and adapter. CONNECT tunnels are not
   supported. Entry 119 adds opt-in 0-RTT requests.

   tHttp3QuicClient takes stream work from the stream manager's queue (entry
   82), at most 128 streams per Pump. While queued work remains,
   StreamWorkPending is True and NextWakeup reports the current time. The
   HTTPS client's HTTP/3 transport waits on that wakeup. An exception raised
   by an observer callback during Pump reaches the caller; the stream stays
   queued, and the next Pump resumes its delivery.

--------------------------------------------------------------------------------
QUIC AND HTTP/3: ASYNCHRONOUS SERVER AND APPLICATION PROTOCOL PLUGINS
================================================================================

95. NEW - TsmAsyncQUICServer hosts QUIC applications; TsmHTTPSv3 serves HTTP/3

   TsmAsyncQUICServer listens on UDP and selects an application plugin using
   authenticated TLS ALPN. Its registry is independent of the existing TCP/TLS
   server registry. TsmHTTPSv3 is the first plugin, registering h3 and reusing
   the HTTP request, response, router and session-provider interfaces used by
   the HTTP/1.1 and HTTP/2 components. Both components are available on the
   StreamSec Mobile palette.

   The listener reuses the record-free TLS 1.3 and QUIC transport engines,
   including packet protection, loss recovery, pacing and stream flow control.
   Authenticated expiring Retry tokens are enabled by default. Connection and
   handshake limits, address-validation amplification limits, bounded unknown
   packet processing and stateless resets protect listener resources. The
   selected reactor must support datagrams. Each connection's callbacks are
   serialized, while independent connections can run concurrently.

   The listener's Filter screens peers and ALPN tokens with the same
   iPeerFilter as TsmAsyncTLSServer, together with OnPeerRefused (the TLS
   server's event type) and ReportPeerActivity. One filter instance can be
   assigned to both servers, so their rules, activity windows and temporary
   blocks are shared per address. Filter = nil, the default, admits every
   peer. An unknown Initial is screened before Retry or any per-connection
   allocation; a refusal drops it silently and spends none of the
   stateless-reply budget. Because an Initial's source can be forged,
   OnPeerRefused can fire per datagram: handlers must be cheap and should
   throttle their logging. One activity unit is counted per connection once
   its address is proven (a valid Retry token, or the first authenticated
   Handshake packet without Retry); Initials alone never count.

   Per-token rules work as on TCP: tokens a source may not use are removed
   from that connection's ALPN list before TLS starts, so RestrictToken('snip',
   ...) can limit Snip over QUIC to chosen networks while h3 stays open. With
   no permitted token the connection closes with no_application_protocol
   (0x178) using Initial keys, and the selected token is checked again before
   a session is created, resumed and 0-RTT handshakes included. A validated
   switch of the active path to a different IP is screened again (refusal:
   CONNECTION_REFUSED, 0x02); a candidate path whose validation fails leaves
   the old path in use, so a rewritten source address cannot kill a
   connection.

   The peer address an application sees - the transport's RemoteAddress,
   every HTTP/3 request's RemoteAddress and the OnConnectionClosed argument -
   is the address alone, as the TCP servers report it: dotted IPv4,
   unbracketed IPv6, ::ffff:a.b.c.d for a mapped address. The structured
   endpoints used for sending, Retry tokens, path validation, rebinding and
   stateless resets keep the port. RemoteAddress follows the current validated
   path; each HTTP/3 request takes it when its stream is first observed and
   keeps it. OnConnectionClosed reports the last validated address.

   HTTP/3 supports multiplexed requests, bounded complete request bodies,
   streamed file/response sources, static QPACK and the shared Huffman codec.
   Receive credit is returned independently of managed-array lifetime and
   retained-body memory limits. Per-connection and aggregate plugin budgets
   bound retained data. Cancellation, request errors and connection errors
   remain distinct. Shutdown sends GOAWAY and allows pending responses to drain
   within the configured deadline. The connection then closes as RFC 9114
   section 5.2 requires, with an application CONNECTION_CLOSE carrying
   H3_NO_ERROR (0x100). The plugin supplies that code through
   iQuicAppSessionDrainClose, so the listener stays protocol-neutral; without
   it, as for Snip over QUIC, the close carries the transport's NO_ERROR.

   HTTP/3 grants request streams in blocks of Limits.MaxRequests (default
   1000). When the client opens the last stream of a block, a block older than
   Limits.MinRequestBlockAgeMSec (default 60000, 0..86400000) is renewed by
   another block, with its start time and counter reset. A younger one gets
   GOAWAY and that connection drains as at shutdown: every request already
   allowed still completes, and the client reconnects through admission, Retry
   and the peer filter. Set the age to allow human client users but rule out
   bots: a person does not make 1000 requests in a minute, a scraper does.
   Zero renews regardless of age.

   Finished streams retire (entry 82) once their data, resets and
   acknowledgements are settled and no application, streaming or QPACK
   reference is left, so a long-lived connection keeps no record for the
   requests it has finished. Records stay within a fixed ceiling of 2048 per
   connection, enough to reserve a whole next block while a browser still has
   requests in flight; a client that keeps so many streams unfinished that the
   next block would not fit gets GOAWAY whatever its age. A record costs 628
   bytes on Win32 and 800 on Win64, so the ceiling bounds a connection at
   about 1.6 MB of records. Optional plugin companions carry this:
   iQuicAppTransportStreamBudget the stream credit and the drain of one
   connection, iQuicAppSessionRetirement the release of a finished stream and
   iQuicAppSessionDrainClose the close code.

   Limits.SendWindowBytes, the window W (default 65536, range 16384..3145728,
   set while the listener is inactive), caps the send storage one connection
   retains until the peer acknowledges it, so one HTTP/3 connection moves at
   most W bytes per round trip: 64 KiB at 50 ms is about 1.3 MB/s. It is small
   on purpose. A peer can grant flow-control credit in tiny steps and
   acknowledge selectively until the retained data is split into one range per
   byte, so the worst case per connection is about W plus W range records (32
   bytes each on Win32, 40 on Win64), times MaxConnections. The server's
   pending STREAM interval queue holds max(256, W div 256) entries, FINs
   included: packet-sized loss always fits, and a peer that fragments below
   that average breaks only its own connection (INTERNAL_ERROR, recorded in
   LastConnectionError). The window is bound into the early-data context, so a
   changed window refuses old 0-RTT, and a transport that refuses the
   preparation fails the connection closed. Raise the window only together
   with a lower MaxConnections and an explicit memory budget.

   Configure identity and trust through OnConfigureEngine before activation;
   assign TsmHTTPSv3.Server and its routes or OnRequest first. QUICServer.txt
   documents the listener, plugin contract, threading and shutdown rules;
   HTTP.txt describes HTTP/3 handler behavior and limits. CONNECT tunnels are
   not supported; optional QUIC 0-RTT, dynamic QPACK and server push are
   described in entries 119 through 121.
   Existing TLS provider linking and TLS-record behavior are preserved.

   Application deadline publication is idempotent: every value is stored, but
   only a newly armed or earlier nonzero deadline wakes the owner. Zero clears
   it. A consumed deadline can be rearmed with the same numeric value. The
   existing gate and pending-work event retain signals before or during a wait;
   callbacks and connection state remain serialized.

   Connection-owned sends, receive-credit updates, resets and close requests
   coalesce while the owner timer generation is unchanged. The first mutation
   wakes promptly; a new owner generation permits a follow-up even within the
   same locked turn, retaining progress after the owner consumed its first
   signal. Receive-driven scheduling changes use the same path. Final unlock
   clears only the local marker, without consuming or resetting the event.
   External worker requests and newly armed/earlier application deadlines keep
   their immediate publication path; no turn resets or consumes their signals.

   Each connection publishes its core and application schedule independently
   under a short metadata gate. The timer scans lifetime-pinned metadata,
   services ready/due entries in rotating order, and uses a nonblocking
   connection acquisition. Busy entries retain their work and absolute
   deadlines without due-spin. Final native unlock and deferral registration
   share the metadata gate, so release always hands pending work back to the
   timer without a lost wakeup. Core changes conservatively request refresh;
   application cancellation/rearming, handshake expiry and the existing 50 ms
   maintenance opportunities are preserved. Selection avoids the routing and
   connection-creation gate. Selected callbacks and source reads retain their
   existing serialized execution contract.

   WorkerThreadCount (default 2, inactive-only range 1..64) controls a separate
   bounded connection executor. The timer only selects and queues work; each
   connection has at most one queued/running turn. Worker completion publishes
   its next schedule, retaining work, absolute deadlines and unlock wakeups.
   Completion notifies the timer when work needs service before its bounded
   next review. Queue-capacity notification follows a failed full-queue post;
   ordinary dequeues and idle completions avoid redundant timer notifications.
   Metadata/queue gates preserve wakeups across completion and admission races.
   Counted worker permits retain each admitted turn without broadcasting to
   idle workers. Active workers claim in-memory credits without native waits;
   native wakes are reserved for registered idle workers so busy workers cannot
   steal a pending wake. Registration precedes parking under the queue gate.
   Notification rollback, wait-error retries and logical stop credits preserve
   queue draining, connection serialization, deadlines and safe worker joins.
   Active connections may retain the same reservation for immediately due work,
   for at most sixteen passes and 1 ms checked between passes. Each pass handles
   at most 16 input datagrams and then drives the connection once: stream
   callbacks, Writable and output follow the batch, not each datagram. The
   native connection lock is released between passes. Queued competitors,
   future deadlines and draining/closing connections yield to the timer; the
   final handoff retains pending work and wakeups.
   After successful ordinary in-flight sends, a pacing-only deadline that has
   become due may continue with fresh caller time within that same quantum.
   Future pacing deadlines yield; attempts without ordinary send progress and
   competing protocol/path deadlines retain the 1 ms core-service retry guard.
   Absolute deadlines and per-send transport permission checks remain
   unchanged. A connection's pacer holds 2 to 10 datagrams, about 1 ms of its
   pacing rate (CHANGES 89), so on a fast path one turn sends up to ten.
   Measured on a Wi-Fi LAN, that cut the sending server's CPU per byte by
   about a fifth. The datagrams of such a turn leave in one socket call
   (entry 55). If the socket does not take all of them, those it did not
   take count as never sent: their data is queued again, and congestion
   control, pacing and loss recovery do not see them. On the same LAN this
   cut the sending server's CPU per byte by a further 19 to 29% (system time
   by 36 to 44%) and raised throughput to an independent MsQuic client by
   27%. Zero-packet service invalidates previous
   progress and cannot authorize continuation from stale send evidence.
   Destination-route snapshots are reused until local CID history or initial-
   alias acceptance changes, avoiding repeated CID copies and routing-table
   locking. Replacement routes are published before new IDs are advertised;
   Retry aliases and historical CID association retain their existing behavior.
   Queue capacity is MaxConnections plus worker count. Known-connection UDP
   input is bounded to 32 retained datagrams/256 KiB per connection and 16 MiB
   aggregate, including active processing; excess input is dropped without
   granting credit and counted. IngressDropCount reports the drops of the
   current activation, and each connection's transport reports its own through
   the optional iQuicAppTransportIngress, which can be read while a callback of
   that connection runs.
   Source reads, trailer producers and callbacks execute on
   connection workers, serialized per connection. Final shutdown cleanup may
   use the owning caller after workers join. The configured grace deadline is
   unchanged; arbitrary blocking user operations still need to return for safe
   teardown and can occupy the bounded pool. Transport processing shares these
   workers and is not isolated from blocking application work.

   Future QUIC waits retain microseconds. On Windows 10 version 1803 and later,
   when available, a private high-resolution waitable timer is waited together
   with the work/shutdown event. Cancellation never resets that event, and the
   timer handle is released before the owning event. No busy polling, APCs or
   process-wide timer-resolution changes are used. Older Windows and other
   platforms keep a conservative cancellable event fallback. The existing due-
   slot retry, idle-scan cap and all absolute timeout budgets are preserved.

   Stream data, resets and stop notices reach the application from the stream
   manager's queue (entry 82), at most 128 streams per pass with another pass
   requested while work remains, instead of from a rotating visit over every
   retained stream. Notice that a peer stream has started still precedes its
   first data. With 700 idle streams open on one loopback connection, a
   one-byte request waited 26 ms at the median and is now answered in about
   0.1 ms. Against an independent MsQuic client on loopback, the 99th-percentile
   request latency falls from 51 ms to 0.26 ms and bulk throughput rises by
   about 22%.

   Releasing acknowledged ACK ranges (entry 82) then lowers server CPU per GiB
   by about 9% and raises bulk throughput by about 8% against the same client;
   an average ACK frame now carries about 3 ranges instead of 63.

   Driving the connection once per input batch instead of after every datagram
   then cuts refused ingress datagrams by about 80%, lowers server CPU per GiB
   by about 7% and raises bulk throughput by about 6% against the same client.

--------------------------------------------------------------------------------
HTTP/1.1 AND HTTP/2: AVAILABILITY-AWARE HTTP/3 ALTERNATIVE SERVICE
================================================================================

96. NEW - HTTP/1.1 and HTTP/2 components can advertise their live HTTP/3 peer

   TsmHTTPSv1dot1 and TsmHTTPSv2 expose opt-in AltSvc settings. Assign Source
   to TsmHTTPSv3, configure the authorized HTTPS Origin and enable the mapping.
   Responses for that origin advertise h3 on the actual bound UDP port, or on
   an explicitly configured PublicPort for a public/NAT mapping. MaxAge defaults
   to 60 seconds. Other origins and plaintext redirect paths are unaffected.

   Readiness is published after successful QUIC startup and withdrawn before
   draining, failed activation, endpoint closure and component removal. Requests
   sample retained endpoint state safely across listener restart and component
   destruction. An enabled mapping emits Alt-Svc: clear while unavailable;
   already cached advertisements remain subject to their freshness lifetime.
   Manually supplied Alt-Svc fields take precedence and remain unchanged.

   Origin checks use the actual HTTP/1.1 authority and HTTP/2 scheme/authority;
   malformed or ambiguous authorities do not advertise automatically. Enabling
   the mapping asserts that public routing, certificates and application content
   serve that origin; local readiness cannot establish Internet reachability.
   Existing HTTP components do not acquire a QUIC implementation dependency.
   Intentional TLS provider linking and TLS-record behavior are preserved.

--------------------------------------------------------------------------------
HTTPS CLIENT: HTTP/3 AND AUTOMATIC ALTERNATIVE-SERVICE DISCOVERY
================================================================================

97. NEW - High-level HTTPS clients can discover and use HTTP/3 alternatives

   TsmHTTPSClient and TsmAdvancedHTTPSClient accept opt-in hcpHttp3 alongside
   their existing TCP protocols. Authenticated Alt-Svc response fields populate
   a bounded origin-scoped cache. Eligible later requests use the same-host
   QUIC endpoint through the existing BeginRequest/Execute and iHttpExchange
   APIs, preserving the original URL, authority and certificate identity.
   HTTP/1.1 and HTTP/2 remain the default; TCP ALPN offers are unchanged.

   Streaming, concurrent exchanges, cancellation, response limits and existing
   redirect credential rules also apply to HTTP/3. Connection state, negotiated
   protocol and channel binding describe the selected backend. Completed unread
   exchanges retain safe response/body access after component destruction.
   Body-read failures cancel their exchange, and absolute operation deadlines
   also bound later HTTP/3 I/O. Changing the effective TLS engine resets this
   client's discovery context without clearing other shared-cache consumers.
   Explicit origin ports are checked and nondefault ports are included in the
   request authority, including on the existing TCP wires.

   Discovery handles expiry, response age, clear, failed-route suppression and
   generation-bound rejection. Automatic fallback occurs only before HTTP/3
   request submission; accepted requests are never automatically replayed after
   an ambiguous failure. Existing TLS configuration, engine ownership and
   intentional cryptographic provider linking are preserved. HTTPSClient.txt
   documents configuration, cache sharing and lifecycle requirements.

--------------------------------------------------------------------------------
HTTP/3 CLIENT: INCREMENTAL REQUEST BODIES
================================================================================

98. NEW - HTTP/3 client engines accept bounded incremental request bodies

   tHttp3ClientConn and tHttp3QuicClient add an open-body StartRequest overload,
   RequestBodyOpen, RequestBodyCapacity and TrySendBody. Applications can submit
   immutable TBytes chunks as send capacity becomes available and explicitly
   finish the request. Existing complete-body StartRequest calls are preserved.

   Admission is atomic for each chunk and its optional FIN. Queued payload and
   framing bytes and send-part metadata are bounded, and consumed parts are
   reclaimed as streaming continues. Fair send scheduling keeps other streams
   progressing. Declared Content-Length is checked across all accepted chunks.

   Response and upload completion are independent. Early responses remain
   available when the server stops the request body or the caller cancels the
   unfinished upload. Existing TLS authentication, cryptographic provider
   linking and request replay policy are preserved. HTTP.txt documents the
   engine API.
--------------------------------------------------------------------------------
HTTPS CLIENT: COMMON STREAMING REQUEST BODIES
================================================================================

99. NEW - HTTPS components accept bounded known-length streaming uploads

   TsmHTTPSClient and TsmAdvancedHTTPSClient add BeginUpload, returning an
   iHttpUploadExchange with RequestBodyOpen, RequestBodyCapacity, TrySendBody
   and WaitForBodyCapacity. The same API submits immutable TBytes chunks over
   HTTP/1.1, HTTP/2 and HTTP/3 without assembling a complete request body.
   Existing BeginRequest and Execute complete-body calls are preserved.

   Chunk and final-boundary admission is atomic, with bounded retained bytes
   and part metadata. Declared Content-Length is checked cumulatively, and
   producer waiting observes the operation deadline. Upload and response
   completion remain independent. Cancellation preserves an already complete
   response and aborts remaining transport work; a partial HTTP/1.1 exchange
   retires its connection before reuse. Graceful TLS peer closure terminates
   the HTTP wire promptly while preserving application alert callbacks.

   HTTP/2 gains bounded immutable send parts, fair output scheduling and empty
   final-frame handling. HTTP/3 automatic send admission reserves advertised
   receive credit and header/control space, and derives range limits from its
   bounded send window. Requests are not replayed or redirected by the upload
   API. Intentional TLS provider linking is preserved. HTTPSClient.txt documents
   the producer, buffer and lifetime contracts.

100. NEW - Unknown-length HTTPS uploads and chunked HTTP/1.1 requests

   TsmHTTPSClient and TsmAdvancedHTTPSClient add a three-argument BeginUpload
   overload returning the existing iHttpUploadExchange. It accepts immutable
   TBytes chunks without a declared Content-Length, using the same cumulative
   payload cap, bounded retained buffers and producer backpressure. The existing
   length-taking overload keeps its nonnegative length and exact-final-count
   checks; complete-body APIs are unchanged.

   Unknown-length HTTP/1.1 requests use Transfer-Encoding: chunked without
   Content-Length. HTTP/2 and HTTP/3 omit both fields and finish with the native
   stream boundary. The client generates no extensions or request trailers.
   Final admission closes the producer while transport work stays pending.
   Cancellation preserves an already complete response and retires unfinished
   HTTP/1.1 framing; multiplexed cancellation remains per stream. Uploads are
   not automatically replayed or redirected.

   TsmHTTPSv1dot1 decodes chunked requests into the complete Body stream used by
   existing shared handlers. It ignores valid extensions and validates then
   discards benign trailers, rejecting forbidden fields and ambiguous framing.
   Pipelined requests begin only after the complete chunk/trailer boundary.
   Content-Length requests and response framing retain their existing behavior.

   HeaderBytes separately bounds the request head and aggregate chunk metadata;
   BodyBytes counts decoded payload. Announced chunks reserve TotalBodyBytes
   before payload is retained, and reservations are released on dispatch or
   failure. Body-refusal events report undeclared length and decoded received
   bytes for chunked requests. Intentional TLS provider linking is preserved.
   HTTP.txt and HTTPSClient.txt describe the framing, limits and producer API.

--------------------------------------------------------------------------------
HTTP: RECEIVED REQUEST AND RESPONSE TRAILERS
================================================================================

101. NEW, BEHAVIOUR CHANGE - Keep received trailers separate from initial
     headers

   Shared HTTP/1.1, HTTP/2 and HTTP/3 handlers can query the optional
   iHttpRequestTrailers interface for a complete request-owned Trailers
   collection. Existing request and handler interfaces keep their contracts.
   HTTP clients expose tHttpResponse.Trailers after successful completion,
   preserving duplicates, empty values and order. Collections remain owned by
   their request or response and are read-only to consumers.

   HTTP/2 and HTTP/3 response trailers are no longer appended to Headers.
   Applications must read Trailers explicitly. Header convenience methods,
   redirects, authentication and Alt-Svc discovery use initial headers only.
   Pre-completion response trailer views stay empty; a complete validated
   collection is published atomically and survives cancellation or client
   destruction with its response. Failed or truncated messages expose no
   partial trailer list. Low-level HTTP/3 ResponseTrailers notifications now
   follow valid FIN and message checks, immediately before ResponseComplete.

   All three wires reject forbidden and malformed trailer fields and bound
   retained metadata including per-field overhead. HTTP/1.1 validates raw
   values before whitespace removal and requires exact CRLF. Received request
   trailers reach handlers only with a complete decoded body. Generated trailers
   and asynchronous server request streaming remain separate capabilities.
   HTTP.txt and HTTPSClient.txt describe access, lifetime and limits.

--------------------------------------------------------------------------------
HTTP: SHARED SERVER REQUEST-BODY STREAMING
================================================================================

102. NEW - Shared server request-body streaming

   NewHttpStreamingHandler adapts iHttpStreamingRequestHandler to the existing
   shared router for HTTP/1.1, HTTP/2 and HTTP/3. Admission supplies an
   immutable retained request head and a bounded iHttpServerExchange for
   application workers. Existing complete-body handler interfaces and lifetime
   rules are unchanged. The optional streaming session-provider companion
   preserves configured authorization/session preparation without a partial Body
   object.

   A fixed TBytes ring, independent cumulative body cap, finite absolute
   deadline and shared adapter job quota bound request delivery. Nonblocking
   var-buffer reads distinguish data, pending, validated EOF and failure;
   received trailers are published only after successful terminal validation.
   Workers submit a sealed prepared response with TryComplete or an early
   final answer with TryReject. Cancellation remains available during paced
   output; shutdown detaches workers and releases unread storage safely.

   HTTP/1.1 parks/resumes receive and accepts known/chunked bodies without
   assembling the payload. HTTP/2 and HTTP/3 return payload credit on reads
   with bounded receive admission. HTTP/3 accounts for observed stopped-stream
   grants until input termination and leaves critical-stream headroom for
   cooperative admitted requests. Early rejection preserves the response.
   Streaming routes reject early data and unsupported expectations before
   provider/worker admission, and support 100-continue after acceptance.
   HTTP.txt section 24 documents threading, ownership, limits and transport
   requirements. Intentional TLS provider linking is preserved.

--------------------------------------------------------------------------------
HTTP: GENERATED REQUEST AND RESPONSE TRAILERS
================================================================================

103. NEW - Generated trailers through the shared HTTPS APIs

   Shared HTTP/1.1, HTTP/2 and HTTP/3 handlers can query the additive
   iHttpResponseTrailers companion and set a copied, validated response trailer
   section. Existing response/handler interfaces are unchanged. Prepared
   streaming responses seal the fields with the response. HEAD and statuses
   forbidding a body suppress the section; source failures cannot produce a
   successful terminal section.

   New BeginUpload overloads declare trailer names before the initial head.
   Their existing iHttpUploadExchange supports the additive
   iHttpUploadTrailersExchange companion for final TrySendTrailers admission.
   Fields must be a subset of the declared names; invalid fields or final
   payload length raise without admission. Successful admission copies fields
   and closes the producer, with delivery remaining separate. A bounded final
   slot is independent of payload capacity. Old upload overloads retain their
   ordinary final-body behavior.

   Trailer-enabled HTTP/1.1 uploads use chunked framing even for known-length
   bodies, retaining local length checks. Nonempty server sections select
   chunked response framing and automatic name declarations; body-bearing
   responses to HTTP/1.0 requests become a local 500 before response output.
   HTTP/2 sends terminal HEADERS in actual HPACK wire order after queued DATA.
   HTTP/3 sends terminal HEADERS before FIN, using the existing static QPACK
   policy; empty generated field lists use ordinary FIN. HTTP/2 bounds and paces
   one encoded response trailer block. If cancellation/reset must abandon that
   pending stateful block, it retires the connection to preserve compression
   integrity; cancellation before commitment or after full handoff remains per
   stream. Cancellation preserves complete responses and retires unfinished
   HTTP/1.1 framing before reuse.

   Generated metadata preserves duplicate order, empty values, interior HTAB
   and raw high octets. Non-octet Unicode, forbidden names/controls and outer
   whitespace are rejected. Decoded metadata is bounded at 16 KiB including
   field overhead, encoded terminal storage at 32 KiB, with smaller peer limits
   honored. Initial headers and payload accounting remain separate.

   BEHAVIOUR CHANGE: HTTP/1.1 now suppresses payload and transfer/trailer
   framing for HEAD, 1xx, 204, 205 and 304 responses, including responses with
   no configured trailers. It omits Content-Length for the listed statuses;
   HEAD retains its representation-length behavior.

   BEHAVIOUR CHANGE: the common client accepts only one TE: trailers request
   field and rejects other or duplicate TE fields before submission. It supplies
   the required HTTP/1.1 Connection nomination and emits no Connection field
   for it on HTTP/2 or HTTP/3. HTTP.txt and HTTPSClient.txt document the new
   producer and response contracts. Intentional TLS provider linking remains.

--------------------------------------------------------------------------------
HTTP: DEFERRED RESPONSE TRAILERS
================================================================================

104. NEW - Generate response trailers after streamed body consumption

   Shared HTTP/1.1, HTTP/2 and HTTP/3 handlers can use the additive
   iHttpResponseDeferredTrailers companion to register copied trailer names
   and an iHttpResponseTrailerProducer. ProduceTrailers runs once after the
   selected response source range has been read successfully, allowing an
   application to finalize a streaming digest without buffering the body.
   Existing response interfaces and static SetTrailers remain supported.

   Eligible empty bodies finalize once. HEAD, body-forbidden statuses, source
   errors, truncation and cancellation before EOF suppress the callback.
   Callback failures and invalid final fields cannot produce a successful
   terminal response. Declared names, Connection nominations, field storage,
   peer limits, output pacing and compression ordering remain enforced.

   Configure the body before its producer: body replacement clears deferred
   generation. Callback results transfer an owned field collection for copied
   validation and release. Producer callbacks are synchronous and nonblocking;
   HTTP.txt section 2.3.1 describes ownership, threading and failure rules.
   Intentional TLS provider linking is preserved.

   BEHAVIOUR CHANGE: HTTP/1.1 and HTTP/2 normalize an application-selected
   informational final status to an empty 500, matching HTTP/3. Protocol-owned
   100-continue responses are unchanged. HTTP/2 suppresses body output and
   applies body-forbidden status framing even without configured static
   trailers.

--------------------------------------------------------------------------------
QUIC: UTILIZATION EPOCHS
================================================================================

105. REDACTED - Recovery utilization-epoch behavior
    consolidated into entry 83. This number is retained for reference.


--------------------------------------------------------------------------------
HTTP: ABSOLUTE INPUT DEADLINES
================================================================================

106. NEW, BEHAVIOUR CHANGE - Bound incomplete headers and buffered requests
     on all HTTP versions

   TsmHTTPSv1dot1, TsmHTTPSv2 and TsmHTTPSv3 now default to a 10000 ms absolute
   header budget and a separate 30000 ms buffered body/trailer budget through
   Limits.HeaderTimeoutMSec and Limits.RequestTimeoutMSec. Progress cannot
   extend a stage; zero explicitly disables it. HTTP/1.1 captures each new
   request's durations; HTTP/2 and HTTP/3 capture each connection's values.

   Silent startup, partial frame/header blocks and HTTP/3 reassembly holes are
   covered. HTTP/1.1 expiry closes, sending 408 when response framing permits.
   HTTP/2 and HTTP/3 body expiry cancels the affected request and releases held
   resources. Incomplete shared framing/compression or critical-stream input
   closes the connection. Unrelated multiplexed requests otherwise continue.

   Validated EOF ends buffered input timing before application dispatch, so
   response streams and downloads keep their existing lifetime. Accepted
   streaming handlers retain their exchange deadline after header admission.
   Finite deadlines require a working owner work/timer transport. HTTP.txt
   section 20.4 describes configuration and standalone-engine integration.
   Intentional TLS provider linking is preserved.

--------------------------------------------------------------------------------
FPC: POINTER CONVERSION COMPATIBILITY
================================================================================

107. FPC COMPATIBILITY - Provide the single-argument Ptr conversion

   The TLS record layer, internal TLS server and both SSH block-padding units
   now provide an implementation-local inline Ptr helper under FPC. Its
   NativeInt parameter widens narrower signed integers before the pointer
   conversion, while retaining native-width addresses used for buffer offsets.
   FPC otherwise resolves the two-argument segmented System.Ptr overload.
   This correction is required only for FPC compatibility; Delphi continues
   using its existing intrinsic. TLS provider linking is unchanged.

--------------------------------------------------------------------------------
FPC: OBJECT IDENTIFIER STRING CONVERSION
================================================================================

108. FPC COMPATIBILITY - Explicitly convert an object identifier before
     copying its text

   This source adjustment is required only for FPC compatibility.
   OIDToCipherClass now explicitly converts its ObjectIdentifier argument to
   ObjectIdentifierString before the keyed-IV prefix Copy call. FPC does not
   apply the record's implicit string conversion to this intrinsic. Delphi
   already accepted the expression; the dotted-OID comparison is unchanged.

--------------------------------------------------------------------------------
FPC: GC FIELD OWNERSHIP AND METADATA
================================================================================

109. FPC COMPATIBILITY - Match GC field interface calling conventions

   This adjustment is required only for FPC compatibility. The managed-field
   AddRef/Release mappings now use the same COM_CDECL selection as IUnknown.
   FPC on non-Windows otherwise rejects the stdcall mappings and dispatches
   ordinary owning reference-count methods for collector-managed fields.

110. FPC COMPATIBILITY - Emit the managed-field metadata FPC requires

   This adjustment is required only for FPC compatibility. The managed GC
   base class and ASN.1 read-only state record explicitly request field RTTI
   under FPC. The collector can then discover inherited/private fields and
   the nested coder reference for reachability, weak references and cleanup.
   Delphi retains its existing RTTI settings.

111. FPC COMPATIBILITY - Read dynamic-array lengths portably

   This adjustment is required only for FPC compatibility. The GC field walker
   uses System.DynArraySize when traversing or clearing dynamic arrays. FPC
   stores the highest index where Delphi stores the length; reading that
   header directly skipped the final element under FPC. The RTL helper keeps
   Delphi behavior and avoids assumptions about header width and byte order.

--------------------------------------------------------------------------------
FPC: ASN.1 INTERFACE CLASS ACCESS
================================================================================

112. FPC COMPATIBILITY - Unwrap ASN.1 interfaces before class access

   This adjustment is required only for FPC compatibility. CHOICE comparison
   and certificate-chain export obtain implementation objects through GetStruct
   before accessing their fields. FPC interpreted the direct interface-to-class
   casts as pointer casts, causing access violations during certificate-name
   comparison and chain export. The ASN.1 comparison and export rules are
   unchanged.

--------------------------------------------------------------------------------
FPC: PORTABLE DER LENGTH DECODING
================================================================================

113. FPC COMPATIBILITY - Decode long-form DER lengths portably

   This correction is required only for FPC compatibility on big-endian targets.
   The buffered DER reader accumulates length octets in their encoded order,
   rather than copying them into a native integer and assuming little-endian
   memory layout. On FPC MIPS, a valid two-octet length such as 317 was decoded
   as zero, causing certificate parsing to report signatureAlgorithm missing.
   Delphi behavior on little-endian targets, the limit of four length octets,
   truncated-input handling and offset/count updates are unchanged.

--------------------------------------------------------------------------------
FPC: BIT STRING AND NATIVE SET CONVERSION
================================================================================

114. FPC COMPATIBILITY - Match BIT STRING/set bit order

   This correction is required only for FPC compatibility on big-endian targets.
   BIT STRING/native-set conversion uses the most significant bit first on
   these targets, in both decoding and encoding. Delphi and little-endian FPC
   retain their existing per-octet bit reversal.

   The former reversal made a certificate's digitalSignature usage appear as
   encipherOnly on MIPS, and keyCertSign as keyEncipherment. Certificate
   capability discovery then disabled the signing schemes and TLSSetupServer
   refused the configuration. Certificate filters and TLS policy are unchanged.

   Unused trailing bits are masked before conversion without modifying shared
   byte arrays. Empty results and output clearing after oversized input are
   preserved, and zero-sized outputs do not require a memory copy.

--------------------------------------------------------------------------------
FPC: TLS HANDSHAKE NETWORK BYTE ORDER
================================================================================

115. FPC COMPATIBILITY - Encode TLS handshake lengths portably

   This correction is required only for FPC compatibility on big-endian targets.
   ClientHello length fields now use host-to-network conversion instead of
   unconditional byte reversal. Certificate-list and certificate-entry lengths
   use matching host/network conversion with the correct three-byte alignment,
   including certificate-chain import reused by TLS 1.3.

   The former conversions produced malformed ClientHello and certificate lengths
   on MIPS. Delphi and little-endian FPC retain their existing wire
   bytes. Inline conversion is an identity on big-endian FPC and uses native
   byte-swap routines on little-endian FPC, with optimized Delphi byte swaps
   and an inline portable fallback. TLS validation, certificate trust
   rules, algorithm policy and provider linking are unchanged.

--------------------------------------------------------------------------------
FPC: TLS TICKET EXPIRY PRECISION
================================================================================

116. FPC COMPATIBILITY - Compute TLS ticket expiry in Double precision

   This correction is required only for FPC compatibility. Ticket lifetime
   conversion now uses a typed Double seconds-per-day constant in shared TLS
   client ticket checks and the TLS server ticket store.
   FPC otherwise evaluated UInt32 LifetimeSecs / 86400.0 in Single precision
   before widening the result to TDateTime. A one-hour ticket could therefore
   remain eligible about 107.5 microseconds beyond its intended expiry.

   Receipt times, lifetime limits, binding checks, expiry comparisons and
   ticket ownership are unchanged. TLS provider linking is preserved.

--------------------------------------------------------------------------------
DELPHI XE3 WIN64: EMPTY TICKET IDENTITIES
================================================================================

117. FIXED - Handle empty ticket identities without a zero-length RTL comparison

   Correct a Delphi XE3 Win64 compatibility fault in the TLS server memory
   ticket store. Its RTL CompareMem can dereference nil for a zero-length
   comparison. After matching the identity hash and length, the store now
   accepts an empty identity directly and compares bytes only for nonempty keys.

   Empty identities retain their existing store-key behavior. Duplicate lookup
   order, cloning, atomic consumption, expiry, locking and TLS wire validation
   are unchanged. TLS provider linking is preserved.

--------------------------------------------------------------------------------
FPC: RTL UNIT NAMES IN HTTP AND ASYNC TLS
================================================================================

118. FPC COMPATIBILITY - Select compatible RTL unit names for FPC builds

   This adjustment is required only for FPC compatibility. Shared HTTP, async
   TLS, DNS and Snif/Snip units select the names supplied by the classic FPC
   RTL, correcting builds that stopped at explicit System.SysUtils or
   System.Classes imports. Related RTL imports use their corresponding FPC
   names; genuine dotted units such as System.Diagnostics retain their existing
   names.

   Delphi imports and behavior, global compatibility flags and intentional
   TLS provider linking are unchanged.

--------------------------------------------------------------------------------
QUIC: EXPLICIT BUFFERED 0-RTT AND SHARED HTTP EARLY-DATA POLICY
================================================================================

119. NEW, BEHAVIOUR CHANGE - Add opt-in QUIC 0-RTT with HTTP/2
     application-policy parity

   TsmHTTPSv3.EnableEarlyData and optional QUIC protocol/session companion
   interfaces enable bounded early-data acceptance using server-issued tickets,
   atomic single-use consumption and replay approval. Session/request callbacks
   still wait for authenticated handshake completion. Missing, changed or
   oversized protocol configuration refuses early data without disabling
   ordinary connections or resumption. EnableEarlyData defaults to False;
   the separate shared EarlyDataPolicy defaults to edpRefuse.

   tHttp3QuicClient can explicitly admit complete buffered early requests from
   an authenticated ticket, transport-parameter and HTTP/3 settings snapshot.
   Rejection clears provisional streams and protocol state under fresh limits
   and fails admitted requests with retry disabled. Requests and producers are
   never automatically replayed. Retry preserves retained packet work and
   packet numbers; rejected early flight cannot be acknowledged as new data.
   The common high-level HTTPS client retains authenticated request admission.

   Code constructing tQuicSentPacket must explicitly assign its new EarlyData
   field: True only for 0-RTT protection, False for ordinary packets. Do not
   presume that scalar fields in stack records are initialized automatically.

   HTTP/2 now preserves early provenance across fragmented frame headers and
   payloads. Internal stream lookups no longer taint later 1-RTT requests.
   HTTP/1.1, HTTP/2 and HTTP/3 refuse disallowed buffered early requests before
   session-provider or handler side effects. Requests crossing the early/1-RTT
   boundary always receive 425/no-store; streaming early requests remain refused
   before provider, factory or handler admission under every policy.

   Shared TLS early-data validation rejects nonempty indication extensions,
   repeated offers after HelloRetryRequest and acceptance without the first
   selected PSK and its exact cipher. Refusal clears active/accepted state.
   QUIC reuses the existing TLS 1.3 key schedule without emitting TLS records or
   EndOfEarlyData. Existing TLS provider linking is preserved.

--------------------------------------------------------------------------------
HTTP/3: DYNAMIC QPACK WITH BOUNDED BLOCKED STREAMS
================================================================================

120. NEW - Add opt-in dynamic QPACK compression and blocked-stream handling

   HTTP/3 clients and servers support dynamic tables, incremental encoder and
   decoder instructions, protected outstanding references, acknowledgements and
   cancellation. Blocked field sections resume in stream order after required
   inserts arrive, including informational headers and received trailers.
   Other streams can progress without publishing incomplete headers.

   TsmHTTPSv3.Limits adds QpackTableCapacity, QpackBlockedStreams and
   MaxQpackBlockedBytes. The common HTTPS client's Limits adds corresponding
   Http3-prefixed properties, captured for the next connection. Capacity and
   blocked-stream allowance default to zero; the blocked-byte budget defaults
   to 262144. Dynamic compression therefore requires explicit configuration.
   Initialize custom low-level limit records with their Init functions before
   assigning fields. HTTP.txt section 23.5 documents ranges and memory policy.

   Table memory, retained encoded input, instructions and outstanding references
   have finite bounds. Absolute header deadlines also cover blocked trailers;
   cancellation/reset/close releases blocked state. Critical compression output
   receives send credit before ordinary bodies, and deferred input cannot return
   receive credit twice. Credential/cookie fields are never inserted, and
   dynamic output is restricted to the connection's first scheme/authority.

   Resumption starts with empty tables. Rejection clears provisional compression
   state; fresh SETTINGS is required before dynamic early-client output. Server
   ticket contexts include the new limits. Authenticated-only high-level client
   admission and existing TLS provider linking are preserved.

--------------------------------------------------------------------------------
HTTP/3: OPTIONAL SERVER PUSH
================================================================================

121. NEW, DEPRECATED on arrival - Add bounded opt-in HTTP/3 server push

   It is provided for completeness of RFC 9114 only. Server push remains an
   optional part of HTTP/3, but no browser accepts it and widely used HTTP/3
   servers do not send it, so nothing should adopt it. Push stays off by
   default on both sides. To have a browser fetch related resources early,
   send Link preload headers on the ordinary response instead.

   Inline TsmHTTPSv3 handlers can query iHttpResponsePush on their ordinary
   shared response and use TryPush to prepare an independent child response.
   Promises are bodyless GET for the parent's exact HTTPS origin; no credentials
   or headers are inherited and no extra handler/provider is invoked. The
   application explicitly authorizes each resource for the client's privileges.
   The child supports existing owned sources and generated/deferred trailers.
   The capability expires when the inline handler returns; retained references
   remain safe after dispatch and connection destruction.

   Limits.MaxPushes defaults to zero, so push requires explicit server opt-in
   and a client ID grant. MaxActivePushes, MaxPushBufferedBytes and positive
   PushTimeoutMSec bound retained work. Push output shares existing response
   and send budgets. Pending stream credit expires; enabled push requires owner
   timer scheduling. Cancellation, STOP_SENDING, GOAWAY, source failure and
   transport loss retire the affected push without completing a failed response.

   Low-level clients can opt in with an iHttp3PushObserver companion and finite
   initialized limits. Promises, headers, body, trailers and terminal callbacks
   stay separate from ordinary exchanges. Reordered streams/promises and dynamic
   QPACK sections are bounded; duplicate IDs/fields and malformed framing are
   checked. ReleasePushBody returns body credit separately from TBytes lifetime.
   NextPushDeadline and the QUIC adapter's combined NextWakeup expose absolute
   push expiry. The high-level HTTPS client keeps refusing push and creates no
   implicit push cache, cookie updates or Alt-Svc discovery from pushed fields.

   Initialize custom low-level limits records with their Init functions before
   assigning fields. HTTP.txt section 23.6 documents limits and callback
   lifetime. Early connections do not restore push grants; early parent requests
   cannot initiate push. Existing TLS provider linking is preserved.


--------------------------------------------------------------------------------
QUIC: PACKET-DISPATCH ALLOCATION COST
================================================================================

122. REDACTED - Frame-array growth and transport-parameter caching
    consolidated into entry 82. This number is retained for reference.


--------------------------------------------------------------------------------
QUIC: PACKET SIZING AND READINESS
================================================================================

123. REDACTED - Packet sizing and metadata-only readiness
    consolidated into entry 88. This number is retained for reference.


--------------------------------------------------------------------------------
QUIC: OWNER TIMER WAKEUPS
================================================================================

124. REDACTED - Owner timer wakeup behavior and precise cancellable waits
    consolidated into entry 95. This number is retained for reference.


--------------------------------------------------------------------------------
SSH: SNTRUP761/X25519 POST-QUANTUM KEY EXCHANGE
================================================================================

125. NEW - SSH clients and servers can negotiate sntrup761x25519-sha512
     (RFC 9941) and its OpenSSH alias

   The hybrid Streamlined NTRU Prime and X25519 key exchange of RFC 9941 is
   available under its name sntrup761x25519-sha512 and under the identical
   OpenSSH name sntrup761x25519-sha512@openssh.com. Both names select one
   engine with a SHA-512 exchange hash. The client sends a 1158-byte sntrup761
   public key and a 32-byte X25519 value, the server a 1039-byte ciphertext
   and its own X25519 value; both ends refuse any other length and an all-zero
   X25519 shared secret. The shared secret is SHA-512 of the sntrup761 secret
   followed by the X25519 secret, used as a 64-byte SSH string and never as an
   mpint.

   Nothing is offered by default: select the names in the KEX option list's
   SelectedOptionNames. In registration order they follow the ML-KEM hybrids
   and precede pure ML-KEM. The application links StreamSec.DSI.Sntrup761 and
   StreamSec.DSI.ECC (entry 74); without them the names remain selectable and
   streamable but are left out of the offer.

   StreamSec.DSI.Sntrup761 is the provider: tDSISNTRUP and the key classes
   tSNTRUPKey, tSNTRUPPublicKey and tSNTRUPPrivateKey, behind the interfaces
   iDSISNTRUP, iSNTRUPKey, iSNTRUPPublicKey and iSNTRUPPrivateKey declared in
   StreamSec.DSI.PKTypes. Decapsulation uses implicit rejection: a ciphertext
   of the right size that is not valid yields an unrelated secret rather than
   an error, so the exchange fails at the host signature without telling the
   peer why. No ASN.1 identifier or certificate format is assigned to
   sntrup761 keys.

   VERIFIED on Win32 and Win64, natively and with ST4_NO_ASM: three OpenSSH
   KEM vectors and the RFC 9941 Appendix A combiner; both names in both roles
   against OpenSSH 10.3p1 and 10.2p1, with SFTP transfers and repeated key
   exchange; 28 malformed exchanges per target. The 14 runtime packages, XE3
   through Delphi 13, build for both targets. SSH.txt section 9 has the
   details.


--------------------------------------------------------------------------------
HTTP AND QUIC: THE LIBRARY'S OWN EXCEPTION CLASSES
================================================================================

126. NEW - StreamSec.Http.Errors: exception classes for the HTTP engines

   The HTTP/1.1, HTTP/2 and HTTP/3 engines, server request-body streaming,
   HTTP/3 uploads and the QUIC server raise the library's own classes when
   they refuse a call. The new unit StreamSec.Http.Errors declares the root
   eHttpLayerError and two classes below it:

     eHttpArgumentError  a value the routine refuses: a malformed or
                         forbidden field or trailer, a body that does not
                         match its Content-Length, an unknown request
                         stream, a limit outside its range;
     eHttpStateError     a call the object cannot take at the moment:
                         before Start, after close, while another call is
                         running, on a request body that is no longer open,
                         or with a send queue or request limit reached.

   A protocol error of the peer keeps its own class. eHttp3Error, for one,
   still closes the HTTP/3 connection with its error code; the two classes
   above never do. The argument checks inside the QUIC server raise
   eQuicError. Property setters raise the class of their component:
   eQuicAsyncServer for TsmHTTPSv3.Limits, ETLSAsyncServer for the AltSvc
   options of the HTTP/1.1 and HTTP/2 components, and eHTTPSClientError for
   the Http3 limits of the HTTPS client.

   Each message names the routine and the value it refused. A field value,
   path or authority appears as its length only, because it can carry
   credentials. StreamSec.Http.Errors is in the 14 runtime packages.

   VERIFIED: the harness checks of these refusals require the library
   classes; against the previous units 30 of the 31 affected battery rows
   fail and all pass with this change, on Win32, Win64 and Linux64. The 14
   runtime packages, XE3 through Delphi 13, build for Win32 and Win64; the
   pure HTTP/3 framing, trailer and body-queue units build and pass with
   FPC 3.3.1 on Linux x86-64 and big-endian MIPS.


--------------------------------------------------------------------------------
HTTP/2: MUST-LEVEL RULES OF RFC 9113 AND RFC 9110
================================================================================

A comparison of the HTTP/2 and HTTP/3 code against their RFCs found five rules
that HTTP/3 kept and HTTP/2 did not; entries 127 to 131 close them, and entry
132 closes a sixth found while checking those. Every release with HTTP/2, from
4.1.2.355 to 4.1.4.361, has all six. Entry 127 also closes the same gap in the
HTTP/1.1 response writer, where it was worse. The harness Http2MustTest checks
each rule: on 4.1.4.361's code 92 of its 163 checks fail and its 71 controls
pass, on Win32, Win64 and Linux64 alike; with these entries all 163 pass.


127. FIXED, BEHAVIOUR CHANGE - a response field the handler set that its wire
     cannot carry was sent as given: a CR or LF in a value split an HTTP/1.1
     response, and made an HTTP/2 response malformed

    StreamSec.Mobile.HTTPS, StreamSec.Http.Http2Conn, StreamSec.Http.Trailers.

    THE STEP THAT FAILED is where the response writers turn
    iHttpResponse.Headers into the head. tHttp11Session.SendResponse wrote each
    field as "Name: value" and a line end, so a CR LF inside a value ended the
    field there and the rest became another field, or the start of the body:
    response splitting. tHttp2Conn.SendResponse HPACK-encoded the field as
    given. RFC 9113 section 8.2.1: "A field value MUST NOT contain the zero
    value (ASCII NUL, 0x00), line feed (ASCII LF, 0x0a), or carriage return
    (ASCII CR, 0x0d) at any position." A conforming client refuses such a
    response, and a character above U+00FF was cut to its low octet. The same
    held for the HTTP/1.1 reason phrase given to SetStatus: a CR LF in it ended
    the status line. Trailers were already checked on both wires, and HTTP/3
    already refused such a response.

    NOW every field is checked before any part of the head is written: the
    name must be a token (RFC 9110 section 5.6.2), and the value may hold no
    control character other than HTAB, no DEL, and no SP or HTAB at either
    end; on HTTP/2 also no character above U+00FF, as that wire carries one
    octet per character. One field that fails turns the response into a 500:
    on HTTP/1.1 one whose body is 'Internal Server Error' (no body for a
    HEAD), on HTTP/2 a bare one with only the engine's content-length and
    date. Nothing the handler set goes out. HTTP/2 checks the fields it would
    send, HTTP/1.1 every field. An HTTP/1.1 reason phrase holding a control
    character other than HTAB, or DEL, is replaced by the standard phrase for
    the status. HTTP/2 now also drops an application TE field, which RFC 9113
    section 8.2.2 allows in a request only.

    WHY A BEHAVIOUR CHANGE. A response that went out before is now a 500.
    That includes an HTTP/1.1 value with a space or tab at either end, which
    a client used to read as harmless whitespace.

    WHO. Handlers that put request data, or anything else not their own, into
    a response field or a reason phrase.

    THE DISCRIMINATING TEST: a handler sets the field X-Test to 'a', CR, LF,
    'X-Injected: 1'. An affected release sends it as given: over HTTP/1.1 the
    client reads a second field, X-Injected, and over HTTP/2 the response is
    malformed under RFC 9113 section 8.2.1 (Node.js 24 drops the field, the
    HTTP/2 client of this library before entry 129 passed it on). This one
    answers 500 on both.

    HOW IT WAS TESTED. Http2MustTest section 127, 45 checks: a CR, LF, NUL,
    other control character or DEL in a value, SP or HTAB at either end, a
    name that is not a token, and on HTTP/2 a character above U+00FF, on
    each wire; the reason phrase; and as controls the fields that stay as
    they were - uppercase names, octets 0x80 to 0xFF, fields the wire drops
    anyway. 33 fail on 4.1.4.361's code. And Node.js 24 against TsmHTTPSv2
    and TsmHTTPSv1dot1: a CR or LF in a value now arrives as a 500 on both
    wires, where Node.js could not parse the HTTP/1.1 response.

    NOT CHANGED:
    - HTTP/3, which resets such a request.
    - On HTTP/1.1, a second Date or Connection the handler adds with
      Headers.Add still goes out next to the writer's own, and so does a
      second Content-Length when the writer frames the body by length (it
      drops every one when it frames chunked, or for a 204, 205 or 304), and
      a Transfer-Encoding on a response framed by Content-Length. Entry 133
      fixes it.


128. FIXED, BEHAVIOUR CHANGE - HTTP/2 sent a content-length with a 304 - 0
     for the 304 that the file helpers answer a conditional GET with - a
     second date when the handler set one, and a status outside 100..599 as
     given

    StreamSec.Http.Http2Conn, StreamSec.Mobile.HTTPS.

    THE STEP THAT FAILED is where tHttp2Conn.SendResponse adds its own fields.
    It sent content-length for every status but 1xx and 204, so a 304 carried
    the length of the body it does not send. HttpSendFile and HttpSendStream
    answer a conditional GET with a 304 whose body is empty, so every
    revalidation of a file served over HTTP/2 said content-length: 0. RFC
    9110 section 8.6: a server "MUST NOT send Content-Length in such a
    response unless its field value equals the decimal number of octets that
    would have been sent in the content of a 200 (OK) response to the same
    request." It also copied a date the handler set and then added its own
    (section 5.3: a sender "MUST NOT generate multiple field lines with the
    same name in a message" unless the field is a list), and sent any status
    the handler set. Section 15: "All valid status codes are within the
    range of 100 to 599, inclusive." The HTTP/1.1 writer already left
    Content-Length out of a 304 and replaced the handler's Date.

    NOW a 304 carries no content-length (204 none, 205 '0', HEAD the length
    of the body it describes), exactly one date goes out, the engine's, and a
    status outside 100..599 goes out as 500 with the handler's fields and
    body. The HTTP/1.1 writer does the same with such a status, and its status
    line then carries the standard reason phrase.

    WHY A BEHAVIOUR CHANGE. A handler's own Date no longer reaches an HTTP/2
    client, and a status outside 100..599 that went out before is now a 500,
    on HTTP/1.1 as well.

    WHO. HTTP/2 servers that serve files, or answer conditional requests.
    A cache that takes stored fields from a 304 could take the 0; RFC 9111
    section 4.3.4 tells it not to.

    THE DISCRIMINATING TEST: GET a file over HTTP/2, then repeat the request
    with If-None-Match set to the ETag. An affected release sends the 304
    with content-length: 0; this one sends none.

    HOW IT WAS TESTED. Http2MustTest section 128, 19 checks, 12 of which fail
    on 4.1.4.361's code; the controls are the 204, 205 and HEAD lengths, 599,
    and the 1xx remap that was already there. And Node.js 24's
    http2 client against TsmHTTPSv2: the 304 without content-length, one date,
    and status 600 as a 500 with its body.


129. FIXED, BEHAVIOUR CHANGE - the HTTP/2 client accepted a malformed
     response head: a second :status, a :status after another field or
     written as other than three digits, an uppercase field name, a CR, LF or
     NUL in a value

    StreamSec.Http.Http2Client.

    THE STEP THAT FAILED is where tHttp2ClientConn takes a decoded response
    head. It read the first :status with StrToIntDef and checked its range,
    refused another pseudo-header field or a connection-specific field, and
    checked content-length; the checks on field names and values ran on
    trailers only. So '0200' and '$C8' were read as 200, and a second
    :status, an uppercase name, or a value with a CR, LF or NUL was passed on
    to Response.Headers. RFC 9113 section 8.1.1:
    "Clients MUST NOT accept a malformed response."

    NOW every head, interim (1xx) or final, must hold exactly one :status, as
    its first field, written as three digits 100..599. Every other field
    needs a name with no uppercase letter, space, colon, control character,
    DEL or octet above 0x7E (the minimal check of RFC 9113 section 8.2.1),
    and a value with no control character other than HTAB, no DEL and no SP
    or HTAB at either end; octets 0x80 to 0xFF are accepted in a value. TE
    is malformed in a response (section 8.2.2). A malformed head, an empty
    one included, fails its exchange, not retryable, and resets the stream
    with PROTOCOL_ERROR; none of its fields reaches Response.Headers.
    The block is decoded first in every case, so the HPACK state stays in
    step and the connection and its other exchanges carry on.

    WHY A BEHAVIOUR CHANGE. An exchange that completed before with such a
    head now fails, and is not retried.

    WHO. Clients of servers that send such heads, and applications that
    relay response fields.

    THE DISCRIMINATING TEST: a server answers with :status '0200', or with a
    field whose value holds a CR LF. An affected release completes the
    exchange with that head; this one fails it with PROTOCOL_ERROR.

    HOW IT WAS TESTED. Http2MustTest section 129, 66 checks: each malformed
    case on a final head and on an interim 103, each followed by a response
    on another stream whose fields only an HPACK table still in step decodes
    right, and an empty head. 25 fail on 4.1.4.361's code; the controls are
    the follow-ups and the cases that code refused already, such as ':status
    20' or '600'.


130. FIXED, BEHAVIOUR CHANGE - the HTTP/2 server accepted a GOAWAY on a
     stream other than 0, and one shorter than 8 octets, and a GOAWAY cost
     the client nothing

    StreamSec.Http.Http2Conn.

    THE STEP THAT FAILED is tHttp2Conn.HandleGoAway, which was empty. RFC
    9113 section 6.8: "An endpoint MUST treat a GOAWAY frame with a stream
    identifier other than 0x00 as a connection error (Section 5.4.1) of type
    PROTOCOL_ERROR." Section 4.2: "An endpoint MUST send an error code of
    FRAME_SIZE_ERROR if a frame ... is too small to contain mandatory frame
    data"; a GOAWAY's mandatory data is 8 octets. The empty handler read no
    part of the frame, so nothing was read out of bounds.

    NOW those two are the connection errors the RFC names, and every other
    GOAWAY, with or without debug data, costs one token of
    MaxUnproductiveFrames, as PING and PRIORITY do; GOAWAY frames alone run
    the budget out and end the connection with ENHANCE_YOUR_CALM. What a
    client's GOAWAY means is still ignored (HTTP.txt section 6).

    WHY A BEHAVIOUR CHANGE. Those two frames now end the connection, and a
    client's valid GOAWAY now counts against MaxUnproductiveFrames when that
    budget is on.

    THE DISCRIMINATING TEST: send the server a GOAWAY on stream 1. An affected
    release carries on; this one answers GOAWAY(PROTOCOL_ERROR) and closes.

    HOW IT WAS TESTED. Http2MustTest section 130, 6 checks: the two errors,
    the token a GOAWAY costs, the budget run out by GOAWAY frames alone, a
    GOAWAY with debug data, and, as the control, a valid GOAWAY after which
    the open streams are still served. 5 fail on 4.1.4.361's code.


131. FIXED, BEHAVIOUR CHANGE - HTTP/2 ran over TLS 1.0 and 1.1 once the
     process-wide VersionMinorMin had been lowered

    StreamSec.Mobile.HTTPS, StreamSec.Mobile.HTTPSClient,
    StreamSec.Http.Http2Conn, StreamSec.Http.Http2Client,
    StreamSec.Http.Http2Frames.

    THE STEP THAT FAILED: nothing compared the TLS version with h2. ALPN
    selects h2 before the version is settled, and neither TsmHTTPSv2 nor
    TsmHTTPSClient looked at the version afterwards. RFC 9113 section 9.2:
    "Implementations of HTTP/2 MUST use TLS version 1.2 [TLS12] or higher for
    HTTP/2 over TLS." VersionMinorMin is TLS 1.2 by default, so only a program
    that lowered it is affected; but it is one setting for the whole process,
    so lowering it for one old HTTP/1.1 peer let h2 run below TLS 1.2 on every
    connection.

    NOW, below TLS 1.2:
    - TsmHTTPSv2 sends its connection preface, then GOAWAY with
      INADEQUATE_SECURITY, closes the connection and dispatches nothing.
    - TsmHTTPSClient sends its preface and SETTINGS, then the same GOAWAY, and
      closes the connection, as RFC 9113 section 5.4.1 requires after a
      connection error. Connect, or the request being made, raises
      eHTTPSClientError whose message ends with 'HTTP/2 requires TLS 1.2 or
      later (RFC 9113 s9.2)', after the name of the routine that raised it
      (entry 138). It does not fall back to HTTP/1.1 by itself: to reach such
      a server, leave hcpHttp2 out of Protocols.
    - A program that drives tHttp2Conn or tHttp2ClientConn itself calls the
      new Http2TlsBelowMinimum and RefuseConnection (HTTP.txt section 15.2).
    A transport that reports no TLS version is not refused. Separately, a
    request on an h2 connection the engine has ended now raises the engine's
    reason, where it raised 'the connection cannot take another request';
    after the engine's own GOAWAY for an error, entry 136 opens a new
    connection instead.

    WHY A BEHAVIOUR CHANGE. With VersionMinorMin lowered, an h2 connection
    below TLS 1.2 that worked before is now ended, and the client's Connect or
    request raises.

    THE DISCRIMINATING TEST: lower VersionMinorMin to TLS 1.1 and connect a
    client that offers only TLS 1.1 and h2. An affected release serves it over
    h2; this one sends GOAWAY(INADEQUATE_SECURITY) and closes.

    HOW IT WAS TESTED. Http2MustTest section 131, 23 checks, with transports
    and a TLS layer that report each version: the server's and the client's
    GOAWAY, the close on both sides, the client's raised text, also when the
    peer has already closed, and Protocols changeable afterwards; as controls
    TLS 1.2, TLS 1.3 and no TLS version. 14 fail on 4.1.4.361's code. No TLS
    1.0 or 1.1 handshake was part of the test, and the call that closes the
    client's connection in a real Connect has no check of its own.


132. FIXED - BeginGracefulClose on an HTTP/2 client connection lost the
     responses still in flight when the server was nghttp2-based, Node.js
     among them: the client's GOAWAY named one of its own streams

    StreamSec.Http.Http2Client.

    THE STEP THAT FAILED is the Last-Stream-ID in the GOAWAY that
    tHttp2ClientConn sends, from BeginGracefulClose or after a connection
    error. It was the client's next stream identifier, an odd number. RFC
    9113 section 6.8 makes it "the stream identifier of the last
    peer-initiated stream that was or might be processed", and "The last
    stream identifier can be set to 0 if no streams were processed." The
    client never accepts a stream the server starts, so the value is 0.
    Node.js 24 (nghttp2 1.70.0) answered the odd value with GOAWAY
    (PROTOCOL_ERROR) and reset the stream, so a response that had begun was
    cut off after its first DATA. TsmHTTPSClient does not call
    BeginGracefulClose; programs that use tHttp2ClientConn directly do.

    NOW both GOAWAYs carry Last-Stream-ID 0.

    THE DISCRIMINATING TEST: start a slow response from a Node.js http2
    server and call BeginGracefulClose once its head has arrived. An affected
    release receives GOAWAY(PROTOCOL_ERROR) and loses the rest of the body;
    with this one the response completes and the server then closes.

    HOW IT WAS TESTED. Http2MustTest section 132, 4 checks: Last-Stream-ID 0
    after the TLS 1.2 refusal, after a protocol error and from
    BeginGracefulClose; 3 fail on 4.1.4.361's code. And that Node.js 24 run,
    before and after.


--------------------------------------------------------------------------------
HTTP/1.1: THE RESPONSE WRITER'S OWN FIELDS
================================================================================

Found while checking entry 127, which closed another gap in the same writer
and listed this one under NOT CHANGED.


133. FIXED, BEHAVIOUR CHANGE - the HTTP/1.1 server sent a second
     Content-Length, Date or Connection when the handler had added one with
     Headers.Add, and a handler's Transfer-Encoding next to its own
     Content-Length, which made the client read the body as chunks

    StreamSec.Mobile.HTTPS.

    THE STEP THAT FAILED is where tHttp11Session.SendResponse adds its own
    fields to the handler's. It set Content-Length, Date and Connection with
    SetHeader, which replaces the first field of that name and leaves the
    rest, so a second copy the handler had added with Headers.Add went out
    beside the writer's: two Date lines, or two Content-Lengths with
    different values. RFC 9110 section 5.3: a sender "MUST NOT generate
    multiple field lines with the same name" unless the field is a list, and
    Date and Content-Length are not; two Content-Lengths that differ leave an
    intermediary two framings to choose from. And it dropped a
    Transfer-Encoding or Trailer the handler set only when it framed the
    body chunked or sent none, so on an ordinary response framed by
    Content-Length a Transfer-Encoding: chunked went out beside it. RFC 9112
    section 6.2: "A sender MUST NOT send a Content-Length header field in any
    message that contains a Transfer-Encoding header field." The client
    follows the Transfer-Encoding (section 6.3) and reads the body as chunks:
    it fails, or on a kept-alive connection takes the next response from the
    middle of this one. 4.1.2.355 to 4.1.4.361 sent every such field, with
    every status.

    NOW the writer drops every copy of Content-Length, Date, Connection,
    Transfer-Encoding and Trailer the handler set, by SetHeader or
    Headers.Add, and writes its own: Date and Connection always;
    Content-Length when it frames the body by length, 0 on a 205 and none on
    a 204 or 304; Transfer-Encoding: chunked and its own Trailer declaration
    when it frames the body chunked, which it does for trailers. Each goes
    out once. HTTP/2 (DroppedResponseField) and HTTP/3 already dropped every
    copy of Content-Length, Date, Connection and Transfer-Encoding. A value
    the handler gave one of these fields is still checked as entry 127
    describes, and one that cannot be written still makes the response a 500.

    WHY A BEHAVIOUR CHANGE. Fields the handler set that went out before no
    longer do: a second Date, Content-Length or Connection, and a
    Transfer-Encoding or Trailer on a response framed by Content-Length. And
    where the handler set one of the writer's fields itself, the writer's own
    now follows the handler's fields instead of taking that field's place in
    the head.

    WHO. Handlers that copy another response's fields into their own - a
    gateway passing on a backend's Date, Content-Length or Transfer-Encoding
    - or that add Date or Connection with Headers.Add.

    THE DISCRIMINATING TEST: a handler answers 200 with a body and adds
    Transfer-Encoding: chunked with Headers.Add. An affected release sends it
    beside Content-Length, and the client reports a malformed chunked body;
    this one sends Content-Length alone, and the body arrives. Likewise two
    Date fields added with Headers.Add arrive as two Date lines from an
    affected release, as one from this one.

    HOW IT WAS TESTED. Http2MustTest section 133, 18 checks, which read the
    wire back as a client does (RFC 9112 section 6.3): two Dates on a 200 and
    on a 304, two Content-Lengths on a 200 and on a HEAD, two Connections,
    Transfer-Encoding chunked or gzip and a Trailer on a 200 with a body, and
    Transfer-Encoding: chunked on two pipelined responses. 9 fail on the code
    before this entry (main 0b711e67). The 9 controls - one copy of each
    field, the writer's own chunked framing and Trailer with SetTrailers,
    Transfer-Encoding on HEAD and on 204, Content-Length: 0 on 205,
    pipelining itself, and HTTP/2 dropping the same fields - pass before and
    after, on Win32, Win64 and Linux64.


--------------------------------------------------------------------------------
TLS 1.2 AND EARLIER: INTEROPERABILITY WITH OPENSSL
================================================================================

Found while testing HTTP/2 against Node.js 24 and OpenSSL 3.5. Entry 134
breaks a TLS 1.2 handshake with any OpenSSL server that has an RSA
certificate and orders signature algorithms by its own preference. Entries
135 and 137 concern TLS 1.0 and 1.1, which TLS.txt tells a program to reach by
lowering VersionMinorMin: 135 is why that never worked against another
implementation, and 137 is why a lowered VersionMinorMax did not do what it
says. Two battery harnesses check them with messages written by Node.js and
OpenSSL, on Win32, Win64 and Linux64, and a live run against Node.js 24.21
(OpenSSL 3.5.8) and openssl s_server 3.5.7 checks them on the wire: 20 of its
25 checks fail on the code before these entries (main 0b711e67) and its 5
controls pass; with them all 25 pass.


134. FIXED - the TLS 1.2 client answered a ServerKeyExchange signed with
     rsa_pss_rsae_sha256, _sha384 or _sha512 with handshake_failure, although
     its own ClientHello offers those schemes

    StreamSec.Mobile.Tls.

    THE STEP THAT FAILED is the check of an RSA-signed ServerKeyExchange in
    TLS 1.2 (TLS_DecodeServerKeyExchange). It took only rsa_pkcs1_*
    signatures. Since 4.1.0.348 the client lists rsa_pss_rsae_sha256/384/512
    (0x0804-0x0806) in every ClientHello, for TLS 1.3, and RFC 8446 section
    4.2.3 says: "Implementations that advertise support for RSASSA-PSS (which
    is mandatory in TLS 1.3) MUST be prepared to accept a signature using
    that scheme even when TLS 1.2 is negotiated." OpenSSL picks
    rsa_pss_rsae_sha256 for its TLS 1.2 ServerKeyExchange whenever it orders
    signature algorithms by its own preference: openssl s_server -serverpref,
    nginx with ssl_prefer_server_ciphers on, Apache with SSLHonorCipherOrder
    on, and a Node.js TLS server. Measured with openssl s_server 3.5.7
    -tls1_2: with -serverpref it signed with rsa_pss_rsae_sha256 and the
    client sent handshake_failure; without it, it took the client's first
    choice, rsa_pkcs1_sha256, and the handshake completed. Affected: a TLS
    1.2 handshake - a server that does not speak TLS 1.3, or a connection
    with OfferTLS13 off - with an RSA certificate and an ECDHE or DHE suite,
    in every release from 4.1.0.348 to 4.1.4.361.

    NOW the client accepts rsa_pss_rsae_sha256/384/512 there. It verifies
    them as RSASSA-PSS with MGF1 over the signed hash and a salt as long as
    the hash, as RFC 8446 section 4.2.3 defines them. It refuses a salt of
    any other length, a PSS signature under another hash's code point, and
    rsa_pss_pss_* (0x0809-0x080B), which it never offers and which needs a
    key with the RSASSA-PSS OID. The RFC 9155 check of the hash is
    unchanged.

    THE DISCRIMINATING TEST: run openssl s_server -tls1_2 -serverpref with
    an RSA certificate and connect TsmHTTPSClient or TsmTLSClient to it. An
    affected release sends handshake_failure after the ServerKeyExchange;
    this one completes the handshake.

    HOW IT WAS TESTED. TlsPssSkeTest, 28 checks, on Win32, Win64 and Linux64.
    It gives the decoder 15 ServerKeyExchange messages. Five were signed by
    a Node.js 24 TLS 1.2 server (OpenSSL 3.5): rsa_pss_rsae_sha256, _sha384,
    _sha512 and rsa_pkcs1_sha256 over ECDHE, and rsa_pss_rsae_sha256 over
    DHE. The other ten are changed copies. Each message must get OpenSSL's
    verdict, and each accepted one must report the hash it was signed with.
    On 0b711e67, 4 of its 20 checks fail: the four PSS messages are refused.
    Live: our client against Node.js TLS 1.2 servers that sign with each of
    the three schemes, sign by their own preference, or use DHE, and against
    openssl s_server -serverpref, with TLS 1.3 offered and not: 11 of 14
    handshakes fail before, none after. The rsa_pkcs1_sha256 controls and
    s_server without -serverpref pass both times.


135. FIXED - TLS 1.0 and 1.1 did not work with any other implementation
     after a program lowered VersionMinorMin: every record said TLS 1.2,
     and a client that offered TLS 1.3 did not list the lower versions

    StreamSec.Mobile.TlsLayer.

    THE STEPS THAT FAILED, two:
    - The record layer wrote 0x0303 into the header of every record, whatever
      version had been negotiated (since 4.0.1.346; before that it wrote the
      negotiated version). OpenSSL refuses a record of any other version once
      the version is settled (ERR_SSL_WRONG_VERSION_NUMBER, then
      protocol_version). On a TLS 1.1 connection that first happens to the
      client's ClientKeyExchange flight, and to the server's ChangeCipherSpec
      and Finished. This library ignores the record version it receives, so
      its own client and server worked with each other and with nothing else.
    - With TLS 1.3 offered, which is the default, supported_versions listed
      only 0x0304 and 0x0303 (since 4.1.0.348). RFC 8446 section 4.2.1: a
      server that sees the extension "MUST use only the "supported_versions"
      extension to determine client preferences." So a server that knows the
      extension and speaks only TLS 1.1 or 1.0 refused the ClientHello
      (OpenSSL: unsupported protocol), however low VersionMinorMin was.

    NOW, below TLS 1.3, every record carries the version the hellos
    selected, from the ServerHello on. The client takes that version as soon
    as it accepts the ServerHello. Before the ServerHello a record carries 3
    and VersionMinorMax; RFC 5246 appendix E.1 allows any "{03,XX}" on a
    ClientHello. Every TLS 1.3 record stays 0x0303, as RFC 8446 section 5.1
    requires. supported_versions lists 0x0304, then every version from
    VersionMinorMax down to VersionMinorMin. With the default settings both
    are what they were: 0x0303 records, and the list [0x0304, 0x0303]. TLS
    1.0 and 1.1 have no AEAD suite, so reaching such a peer also takes the
    CBC suites and their SHA-1 MAC (BulkCipherAES128 or BulkCipherAES256,
    and HashAlgorithmSHA1). HTTP/2 still refuses anything below TLS 1.2
    (entry 131); this entry is what lets that refusal happen on a real
    connection.

    THE DISCRIMINATING TEST: set VersionMinorMin := cTLS11vmm, allow AES-CBC
    and SHA-1, and connect to openssl s_server -tls1_1. An affected release
    gets protocol_version on its ClientHello with TLS 1.3 offered, or after
    its ClientKeyExchange without it; this one completes on TLS 1.1.

    HOW IT WAS TESTED. TlsLegacyVersionTest, 42 checks, which also covers
    entry 137, on Win32, Win64 and Linux64:
    - our ClientHello under five settings;
    - our client and our server in memory on TLS 1.1, where every record
      after the ClientHello must carry 0x0302 both ways;
    - two ClientHellos a Node.js 24 TLS client sent, fed to our server, which
      must select and frame as OpenSSL's TLS 1.1 server does;
    - the client's ceiling.
    On 0b711e67, 17 of the 36 checks that run fail; 6 more are skipped
    because the step before them failed. Live: our client against Node.js
    servers that speak only TLS 1.1 or only TLS 1.0, with TLS 1.3 offered and
    not; a Node.js TLS 1.1 client against our server; and CHANGES 131's
    refusal of h2 on TLS 1.1, by our client and by our server. All 7 fail
    before and pass after; the controls (TLS 1.3 to the same server, a client
    limited to 1.1 against a 1.2-only server) pass both times.


137. FIXED, BEHAVIOUR CHANGE - a lowered VersionMinorMax did not cap the
     server, did not cap the client, and made every ClientHello carry
     TLS_FALLBACK_SCSV

    StreamSec.Mobile.TlsLayer, StreamSec.Mobile.Tls, StreamSec.Mobile.TlsConst.

    THE STEPS THAT FAILED, four:
    - The server selected the client's version whenever it was TLS 1.0 to
      1.2, and never compared it with VersionMinorMax. RFC 5246 section
      7.4.1.3: server_version holds "the lower of that suggested by the
      client in the client hello and the highest supported by the server."
      So a server limited to TLS 1.1 negotiated TLS 1.2 with every TLS 1.2
      client, in every release.
    - The client checked the server's selection against VersionMinorMin only.
      RFC 5246 appendix E.1: "If the version chosen by the server is not
      supported by the client (or not acceptable), the client MUST send a
      "protocol_version" alert message and close the connection."
    - The client put TLS_FALLBACK_SCSV in every ClientHello while
      VersionMinorMax was below TLS 1.2. RFC 7507 section 4: "If a particular
      protocol version is implemented but completely disabled by client
      settings, it is not considered supported", and "If a client sets
      ClientHello.client_version to its highest supported protocol version,
      it MUST NOT include TLS_FALLBACK_SCSV in ClientHello.cipher_suites."
      VersionMinorMax is a setting, for the whole process. So every server
      that speaks a higher version, TsmAsyncTLSServer and OpenSSL among
      them, answered inappropriate_fallback, which is the server's duty under
      RFC 7507. Together with the connection's FallbackSCSV the ClientHello
      carried the SCSV twice.
    - With TLS 1.3 offered and VersionMinorMax lowered, legacy_version was
      VersionMinorMax. RFC 8446 section 4.1.2 says it "MUST be set to
      0x0303".

    NOW:
    - The server selects the lower of the client's version and
      VersionMinorMax.
    - The client answers a ServerHello above VersionMinorMax with
      protocol_version.
    - A lowered VersionMinorMax adds no SCSV. FallbackSCSV, set on the one
      connection that is a fallback retry, still adds it.
    - legacy_version is 0x0303 whenever TLS 1.3 is offered.
    TLS 1.3 is not capped by VersionMinorMax. A server that offers TLS 1.3
    with a lowered VersionMinorMax - TsmAsyncTLSServer offers it on every
    connection - speaks TLS 1.3 and the versions up to the ceiling. When it
    negotiates one of those it puts the RFC 8446 section 4.1.3 DOWNGRD
    sentinel in its random, so a client that offered TLS 1.2 refuses a TLS
    1.1 handshake with it (OpenSSL: inappropriate fallback). That is the
    outcome the RFC asks for.

    WHY A BEHAVIOUR CHANGE:
    - A server with VersionMinorMax lowered served TLS 1.2 clients on TLS 1.2.
      Now it serves them on the lower version, or, if it offers TLS 1.3, a
      TLS 1.2 client refuses it.
    - A client with VersionMinorMax lowered no longer announces a fallback,
      and refuses a server that selects above the ceiling.
    - A program that lowered VersionMinorMax to make a fallback retry sends no
      SCSV now; it sets FallbackSCSV on that connection instead.

    THE DISCRIMINATING TEST: set VersionMinorMin := VersionMinorMax :=
    cTLS11vmm, allow AES-CBC and SHA-1, and connect to a server that also
    speaks TLS 1.2 or 1.3, such as openssl s_server. An affected release
    sends TLS_FALLBACK_SCSV and gets inappropriate_fallback; this one
    completes on TLS 1.1.

    HOW IT WAS TESTED. The ClientHello and ceiling checks of
    TlsLegacyVersionTest (entry 135):
    - legacy_version and the SCSV under four settings, and FallbackSCSV as
      the control;
    - our client and our server both limited to TLS 1.1, the server also
      offering TLS 1.3 as TsmAsyncTLSServer does; this failed with
      inappropriate_fallback;
    - a client that allows TLS 1.1-1.2 against a server limited to 1.1, which
      negotiated 1.2;
    - Node.js's TLS 1.1-1.2 ClientHello against our server limited to 1.1,
      where the server must select 0x0302 as OpenSSL's does, and end its
      random in DOWNGRD 00 when it also offers TLS 1.3 (it ended it in
      DOWNGRD 01, for the TLS 1.2 it selected);
    - a ServerHello raised to 0x0303 for a client limited to 1.1, which must
      be refused with protocol_version.
    TlsNetworkOrderTest's fallback ClientHello, which lowered VersionMinorMax
    and expected the encoder to add the SCSV itself, now builds the retry the
    way the handshake does for FallbackSCSV; its expected octets are
    unchanged.
    Live:
    - Our client limited to TLS 1.1 against a Node.js server that speaks TLS
      1.1 to 1.3: inappropriate_fallback before, TLS 1.1 after.
    - A Node.js TLS 1.1-1.2 client against our server limited to 1.1: TLS 1.2
      before; after, the server selects 1.1 and the client refuses it for the
      DOWNGRD sentinel.


--------------------------------------------------------------------------------
HTTP/2: THE CLIENT CLOSES ITS CONNECTION AFTER A CONNECTION ERROR
================================================================================

Found in the review of entries 127 to 132. Entry 131 closed the client's
connection after its refusal in the handshake; after a connection error at
run time it stayed open, which RFC 9113 section 5.4.1 forbids. Http2MustTest
section 136 checks it.


136. FIXED, BEHAVIOUR CHANGE - the HTTP/2 client kept its connection open
     after ending it with GOAWAY for a protocol error in the server's frames

    StreamSec.Mobile.HTTPSClient, StreamSec.Mobile.TLSClient,
    StreamSec.Http.Http2Client.

    THE STEP THAT FAILED is TsmHTTPSClient's handling of a connection error
    that tHttp2ClientConn finds in the server's frames once the connection is
    up. RFC 9113 section 5.4.1: "After sending the GOAWAY frame for an error
    condition, the endpoint MUST close the TCP connection." The engine sent
    the GOAWAY and failed every exchange; the component did nothing more. Its
    reader thread kept reading, the wire stayed h2, and the connection stayed
    open until the server closed it or the application called Disconnect. A
    request made meanwhile found the connection, could not open a stream on
    it, and raised eHTTPSClientError with the engine's reason. Entry 131
    closed the connection only after the refusal made in the handshake.

    NOW the reader thread, as soon as the engine has sent such a GOAWAY,
    sends TLS close_notify and then a TCP FIN, so the server reads the end of
    the connection behind the GOAWAY. Wire reads hcwNone, and the next
    request, BeginUpload or Connect opens a new connection. The exchanges on
    the old one fail as before, not retryable. A GOAWAY from the server is
    unchanged: the client does not close on it. A program that drives
    tHttp2ClientConn itself can tell from the new ErrorGoAwaySent when it
    must close its transport (HTTP.txt section 15.2), and a TsmCustomTLSClient
    descendant with a reader thread can end the connection from that thread
    with the new protected CloseSending, after which Send raises.

    WHY A BEHAVIOUR CHANGE. A request made after such an error opens a new
    connection where it raised eHTTPSClientError, and Wire then reads hcwNone
    where it read hcwHttp2.

    THE DISCRIMINATING TEST: let an h2 server answer a request with a PING on
    stream 1. An affected release sends GOAWAY(PROTOCOL_ERROR) and keeps the
    connection open; this one sends close_notify and closes it at once.

    HOW IT WAS TESTED. Http2MustTest section 136, 10 checks, with the client
    component's own reader thread on a cleartext socket pair: three
    connection errors - a PING where the server's SETTINGS must come, a PING
    on stream 1, a DATA header announcing 16385 octets - each with its
    GOAWAY, the server reading EOF within 2 s of it, and the next Connect
    opening a new connection; as control, a PING the client answers with the
    connection left open. 6 fail on 0b711e67's code (entries 127-132), none
    of them among the 4 controls, on Win32, Win64 and Linux64 alike. Over
    TLS 1.3 against a Python 3.13 (OpenSSL 3.0) h2 server that answers a
    request with a PING on stream 1: before, the connection was still open
    5 s after the GOAWAY and the next request raised 'HTTPS: PING on a
    stream'; after, close_notify and the FIN followed the GOAWAY at once and
    the next request got its 200 over a new connection. That TLS run is not
    part of the battery.


--------------------------------------------------------------------------------
HTTP AND QUIC: EXCEPTION MESSAGES NAME THE ROUTINE
================================================================================

138. BEHAVIOUR CHANGE - the exception messages of the HTTP, HTTP/2, HTTP/3,
     QUIC and HTTPS units are resourcestrings that name the routine

    StreamSec.Http.Client, StreamSec.Http.Hpack, StreamSec.Http.Huffman,
    StreamSec.Http.Qpack, StreamSec.Http.Http2Client,
    StreamSec.Http.Http3Client, StreamSec.Http.Http3Server,
    StreamSec.Http.Http3QuicClient,
    StreamSec.Http.Rest, StreamSec.Http.RestServer, the StreamSec.Quic units,
    StreamSec.Mobile.HTTPS, StreamSec.Mobile.HTTPSClient,
    StreamSec.Mobile.HTTPS3ClientTransport, StreamSec.Mobile.AsyncQUICServer.

    WHAT CHANGED. 327 raises in these units passed their message as a string
    literal. Every one of those messages is now a resourcestring, so it can
    be translated with the rest of the library. A message that stays in this
    process now starts with the routine that refused the call, in place of an
    "HTTPS:", "HTTP:", "HPACK:" or "REST route" prefix, and gives the refused
    number where there is one, for example

      TsmCustomHTTPSClient.BeginUploadInternal: invalid upload field name
      tHttpsExchange.TrySendBody: a 20000-octet upload chunk exceeds 16384
      octets

    No exception class changes; a field value, path or authority is still
    reported by its length only.

    WHAT DID NOT CHANGE. An HTTP/3 or QPACK error that closes the connection
    is sent to the peer as the reason phrase of its CONNECTION_CLOSE frame.
    Those 142 messages keep their text exactly, so a peer reads what it read
    before, and no routine name or local value reaches the wire.

    WHY A BEHAVIOUR CHANGE. eHttpError, eHTTPSClientError, EHpackError and
    ETLSAsyncServer were in 4.1.4.361 with the old text. Code that compares
    E.Message with that text, or looks for its "HTTPS:" prefix, no longer
    matches; test the exception class instead.

    HOW IT WAS TESTED. The battery's HTTP and QUIC rows on Win32, Win64 and
    Linux64; the 14 runtime packages, XE3 through Delphi 13, for Win32 and
    Win64; the pure HTTP/3, QPACK, trailer and body-queue units with FPC
    3.3.1 on Linux x86-64 and big-endian MIPS; and the HTTP/3 early-data,
    HTTPS upload, HTTPS/3 client and generated-trailer interoperability runs.
    The two harnesses that compared the old text now test the class and a
    substring.


--------------------------------------------------------------------------------
SNIF CLASS REMOTING OVER QUIC
================================================================================

139. NEW - TsnipQUICServer, TsnipQUICClient and TsnipAdvancedQUICClient: snip
     (Snif class remoting) over QUIC

    StreamSec.Snip.QUICServer, StreamSec.Snip.QUICClient,
    StreamSec.Snip.QUICOctetConnection; registered on the StreamSec Snif
    palette page.

    WHAT IS NEW. The QUIC counterparts of TsnipTLSServer, TsnipTLSClient and
    TsnipAdvancedTLSClient, with the same properties and the same remoted
    classes, users and roles. TsnipQUICServer is an application protocol for
    TsmAsyncQUICServer, as TsnipTLSServer is for TsmAsyncTLSServer: assign its
    Server property, or register AppProtocol with Protocols.AddProtocol. It
    owns its ClassServer and serves each connection on a thread of its own.
    TsnipQUICClient owns its TLS engine; TsnipAdvancedQUICClient uses the one
    assigned to TLSServer, or GlobalServer. Start connects, opens the snip
    channel and logs the Snif user in.

    One snip connection is the first bidirectional stream the client opens
    (stream 0), carrying the same snip framing as over TLS; the server refuses
    any further stream with application error 1. KAPA login is bound to the
    RFC 9266 tls-exporter value of the QUIC connection's TLS 1.3 handshake, as
    it is over TLS, and fails without one. The ALPN token is 'snip', the same
    as over TLS (cSnipAlpnToken, now declared in
    StreamSec.Snip.TLSOctetConnection). RemoteAddress is the peer's address
    alone, without the port, as over TLS.

    A snip connection is quiet between calls, and QUIC closes a connection
    that is quiet for its idle timeout. The client therefore sends a PING at
    least every third of the negotiated idle timeout, and more often if
    RecoveryHeartbeatInterval is shorter. A client of another make must do the
    same. ConnectTimeout (default 15 s) closes a connection that completes the
    QUIC handshake but sends no snip connect frame.

    Two additions to the QUIC units support this: tQuicClient.Ping, and
    iQuicAppProtocolPriority on the protocol registry, which TsnipQUICServer
    uses for AlpnPriority; AddProtocol adds at priority 0, after higher
    priorities and before lower ones, so a registry with no priorities set
    keeps its order. A snip connect or accept failure now names the transport
    it ran on; the TLS messages are unchanged. AsyncTLSServer.txt describes
    the setup.

    HOW IT WAS TESTED. Test\snipquic, 37 checks on Win32 and Win64, over
    loopback on ports the system assigns: a remoted call; KAPA login with the
    exporter value equal at both ends, and a wrong binding refused; a server
    callback inside an outstanding client call; 1 MiB each way across a 64 KiB
    initial stream window; a quiet connection surviving twice the idle
    timeout; ConnectTimeout; Stop draining within DrainTimeout. Builds with a
    wrong binding, withheld flow-control credit and no PING each fail their
    check. StrSecIV370 builds for Win32 and Win64; SnipAdvancedTest passes
    32 of 32 on both. Not run on the other platforms the client lists, and
    not yet a battery row (the harness needs a fixture directory argument).


--------------------------------------------------------------------------------
FPC COMPATIBILITY: LINUX READINESS REACTORS AND 64-BIT SHARED VALUES
================================================================================

140. NEW - FPC compatibility for the Linux epoll reactor and listener

   Required only for FPC compatibility. The Linux readiness reactor and its
   listener now select native FPC/Linux declarations instead of Delphi's
   Posix units. Their libc calls use libc's thread-local error value, including
   errors reported during setup and cleanup. Target-specific socket constants
   and epoll event layouts are retained on Linux64 and big-endian MIPS32.

   Socket one-shot rearming, descriptor generations, queued work, partial
   writes and interruptible shutdown retain the existing contracts. Delphi's
   backend selection and provider linking are unchanged.


141. NEW - FPC compatibility for Int64 counters, memory budgets and deadlines

   Required only for FPC compatibility. On 32-bit FPC targets TInterlocked
   does not offer the Int64 overloads used by datagram statistics, HTTPS client
   statistics, TLS deadlines and HTTP memory budgets. These operations now use
   a common RTL-only adapter backed by FPC's full-width Atomic intrinsics;
   Delphi retains its TInterlocked implementation.
   Segmented UDP sends and ECN send paths use the same adapter for sent and
   dropped datagram counts, including partial batch results. Unsupported
   ECN markings retain their existing no-send, no-drop behavior.

   Counter reads are atomic as well as writes. Adds retain their signed
   64-bit range and return the new value; exchange and compare-exchange return
   the old value. Memory-budget compare-exchange loops and deadline wakeup
   ordering are preserved. No shared value is narrowed to fit a 32-bit API.

   FPC stDES support for legacy encrypted files remains a separate backlog
   item. Its existing FPC exclusions and intentional TLS provider linking are
   unchanged.

--------------------------------------------------------------------------------
HTTPS CLIENT: DISCARDING AN UNWANTED RESPONSE BODY
================================================================================

142. NEW - iHttpExchange.DiscardBody: drop the body of a response you do not
     want, and give its receive-window credit back

    StreamSec.Mobile.HTTPSClient (TsmHTTPSClient, TsmAdvancedHTTPSClient).

    WHY. The HTTP/2 client gives the server receive-window credit back as the
    application reads a response body, and only then, as it did in 4.1.4.361.
    The unread part of a completed response therefore keeps its share of the
    connection's 4 MiB window for as long as the connection lives. An
    application that looks at a response's status and never reads its body -
    an error page, say - shrinks that window with every such response, and
    once the unread bodies add up to it, every later response on that
    connection stalls until Disconnect. Cancel does not help: it is
    documented to keep a completed response readable, body included, and it
    does. In this version the same holds for the new HTTP/3 wire, and the
    client also keeps a completed exchange while part of its body is unread,
    so that reading it later still returns the credit; with hcpHttp3 it does
    not move to HTTP/3 while it holds one.

    WHAT IS NEW. DiscardBody drops the part of the body that has not been
    read and returns its credit, on all three wires. On a completed response
    status, headers and trailers stay readable, Read then reports the end of
    the body (0) and ReadAll an empty one, and the client lets go of the
    exchange. On a response that is not complete it first cancels, as Cancel
    does, and drops what had arrived, so Read reports cHttpReadFailed. It does
    not end an upload still being written beside a completed response; Cancel
    does. It may be called from any thread, and more than once.
    HTTPSClient.txt (REQUESTS, STREAMING AND LIFETIME) shows where it goes.

    WHAT DID NOT CHANGE. Cancel, Read and ReadAll behave as before, and a
    body read to its end needs no DiscardBody.

    THE INTERFACE CHANGED, SO ITS GUID DID. iHttpExchange is now
    {E50DC9E7-9705-49BA-BFCB-5F9881985B85}. Code that names the interface -
    a declaration, Supports(X, iHttpExchange, Y), an as-cast - recompiles
    unchanged and uses the new GUID. Code that wrote the old GUID out as a
    literal must use the new one, and a class of your own that implements
    iHttpExchange must add the method.

    HOW IT WAS TESTED. Test\httpsclient\HttpsDiscardBodyTest, 42 checks. It
    feeds the client's real HTTP/1.1 response parser by hand and tells from
    each exchange's destruction whether the client still holds it: a
    completed unread exchange stays until Disconnect; DiscardBody drops the
    body and lets the exchange go, keeping its trailers readable, also after
    part of it was read and after the client was freed; on an unfinished or
    pending response it cancels, drops the buffered octets and frees the
    HTTP/1.1 wire for the next response. With an empty DiscardBody 16 of the
    42 fail. The credit goes
    back through the call Read makes after it has copied octets (ReleaseBody);
    no check watches the WINDOW_UPDATE on the wire. StrSecIV370 builds for
    Win32 and Win64 without warnings, and the runtime packages from XE3 to 13
    build; the HTTP, HTTPS and QUIC rows of the self-test battery pass.


--------------------------------------------------------------------------------
UDP: ECN ON macOS AND iOS
================================================================================

143. NEW - the datagram sockets of stSocket mark and read ECN on macOS and iOS

    stSocket.Posix.

    WHY. A UDP socket from NewDatagramSocket could set and read the ECN field
    of the IP header (RFC 3168) on Windows, Linux and Android only. On macOS
    and iOS, SetEcnReception answered cDatagramUnsupported, SendToEcn refused
    ECT(0) and ECT(1) and sent nothing, and ReceiveFromEcn reported deUnknown.
    A QUIC connection there therefore sent Not-ECT and never validated ECN
    (RFC 9000 section 13.4); traffic and congestion control were unaffected
    otherwise. macOS and iOS do support ECN on ordinary, unprivileged UDP
    sockets.

    WHAT IS NEW. On macOS and iOS the three calls now do what they do on
    Linux: SetEcnReception turns on IP_RECVTOS or IPV6_RECVTCLASS, SendToEcn
    marks one datagram with ECT(0) or ECT(1) and keeps the socket's DSCP and
    its default marking as they were, and ReceiveFromEcn reports the
    datagram's codepoint, CE included. The control data follows XNU's own
    layout, which is not Linux's: a 32-bit length and 4-octet alignment, IP_TOS
    and IPV6_TCLASS sent as an int (Darwin silently ignores a one-octet IP_TOS
    and the datagram would leave unmarked), and its own MSG_CTRUNC. Missing or
    truncated control data still gives deUnknown, never an invented Not-ECT.
    tQuicClient uses this as it does on Linux, and so does
    TsmAsyncQUICServer since CHANGES 146.

    WHAT DID NOT CHANGE. Windows, Linux and Android behave as before: the
    Linux code path now names its constants, with the same values. FPC builds
    target Linux only and are unchanged.

    HOW IT WAS TESTED. On a Mac mini M1 with macOS 26.5.2, EcnSocketTest gives
    180 of 610 before this change and 610 of 610 with it, on real loopback
    UDP for IPv4 and IPv6; EcnDscpWireTest, now also on macOS, has 11 checks
    pass and 13 fail before and all 23 pass with it, for each family, with an
    independent receiver
    that reads the TOS byte itself: the DSCP is kept and the socket default is
    not changed. Across the LAN, from Windows to the Mac, 300 of 300 datagrams
    arrived with the ECT(0), ECT(1) or Not-ECT they were sent with, read both
    by this library and by an independent receiver; from the Mac, tQuicClient
    validated ECN against an MsQuic 2.6.3 server; against an OpenSSL 3.5.7
    server ECN validation failed and the connection went on unmarked, as RFC
    9000 section 13.4.2 provides, and the transfer completed. The QUIC suites
    built for macOS give the same results as before this change; two of them,
    QuicServerTransportTest and QuicCloseFailureTest, fail on macOS before and
    after it because they read a loopback datagram before macOS has delivered
    it, and pass when they wait for it. On Windows and on Linux (Delphi and
    FPC 3.3.1) the ECN and UDP harnesses pass unchanged. For iOS it compiles and
    links (iPhoneOS 26.0 SDK, whose headers carry the same values); it has not
    run on a device.


--------------------------------------------------------------------------------
FPC COMPATIBILITY: RSA MASK GENERATION AND TLS RECORD BYTE ORDER
================================================================================

144. FPC COMPATIBILITY - Generate fixed-width network-order MGF1 counters

   StreamSec.DSI.IFC. FPC can evaluate the UInt32 counter subtraction as
   Int64 and select the 64-bit ByteSwap overload. Truncating that result to
   UInt32 made successive mask blocks use counter zero. Valid external
   RSA-PSS signatures were refused, and generated PSS/OAEP encodings did not
   interoperate. Internal round trips could conceal the shared defect.

   Counters now use an explicitly typed UInt32 host-to-network conversion.
   The two EMSR3 recovered-message bit-length writes use the same fixed-width
   rule. These changes are required for FPC compatibility on little-endian
   and big-endian targets; Delphi retains its existing valid encodings.

   Hash selection, salt and padding rules, the OAEP hash-selection correction
   and its existing legacy-ciphertext compatibility policy are unchanged.
   TLS provider linking is preserved.


145. FPC COMPATIBILITY - Read and write TLS record lengths in network order

   StreamSec.Mobile.TlsLayer, StreamSec.Mobile.TlsEncryption, stTlsUtils.
   An unconditional swap changed a valid 1561-byte ClientHello record into
   an apparent 6406-byte record on big-endian FPC. The server waited for
   bytes that were not part of that record until its handshake deadline.

   Record length readers, writers and encryption-layer checks now use
   exact-width host/network conversion. This includes TLS 1.3 AEAD record
   headers and existing MAC/AAD/explicit-IV sequence serialization, which
   retains all 64 bits. TLS 1.3's bytewise nonce construction is unchanged.
   The initial legacy-header peek is confined to a new record, so buffered
   body fragments are not reinterpreted as a fresh header.

   Host lengths are checked before allocation or narrowing. Shared malformed
   CBC bounds paths preserve authentication failure and safe MAC processing;
   failed authentication or padding does not advance the sequence. Valid
   Delphi wire bytes, cipher selection, record limits, entropy policy and
   production deadlines are preserved. Existing FPC DES exclusions and all
   other intentional TLS provider linking remain unchanged.


--------------------------------------------------------------------------------
QUIC SERVER: ECN
================================================================================

146. NEW, BEHAVIOUR CHANGE - TsmAsyncQUICServer marks, validates and reports
     ECN; the async reactor's datagram endpoints read and set the ECN field

    StreamSec.Mobile.AsyncQUICServer, StreamSec.Mobile.AsyncTLSReactor (and
    its IOCP, epoll and kqueue backends), StreamSec.Quic.Ecn,
    StreamSec.Quic.Server, stSocket.

    WHY. With ECN (Explicit Congestion Notification, RFC 9000 section 13.4) a
    QUIC endpoint marks its packets ECN-capable, and a router under load can
    then mark a packet "congestion experienced" instead of dropping it. The
    endpoint that receives the packets "MUST provide feedback about ECN
    markings it receives, if these are accessible" (section 13.4.1).
    tQuicClient did both. TsmAsyncQUICServer did neither, on any platform: its
    connections sent every datagram unmarked (Not-ECT) and their ACK frames
    carried no ECN counts, although the system could read them. A client that
    marks - tQuicClient, MsQuic and others - therefore failed its validation
    against this server and stopped marking for the connection (section
    13.4.2.1). Nothing else was affected: traffic and loss-based congestion
    control worked as usual. The QUIC connection code already asked for ECN;
    what could not provide it was the socket the listener lends its
    connections, and the reactor's datagram endpoint below it, which could
    neither read nor set the ECN field.

    WHAT IS NEW.
    - TsmAsyncQUICServer. On activation the listener has its socket read the
      ECN field of every datagram it receives. Each connection reports those
      markings in its ACK frames, and marks what it sends ECT(0) as
      tQuicClient does: ten test packets, then every packet once the client's
      reported counts confirm them, and Not-ECT for the rest of the path if
      they do not. This is the server's new default and there is no property.
      Where the system cannot read the field, the connections report nothing;
      where it cannot set it, they send Not-ECT; either way they run as
      before, and activation does not fail. Retry, Version Negotiation and
      stateless reset replies stay Not-ECT.
    - Marked packets keep the server's send batches (several datagrams of one
      size in one system call). A batch has one marking, that of its first
      packet; the packet where the marking changes - where the ten test
      packets end - goes on its own. A batch is counted against the ten test
      packets and the tracking limit before any of it is recorded, so it never
      marks more than those allow. A batch the system refuses to mark is sent
      again unmarked in the same pass, nothing lost, and the connection stops
      marking.
    - tReactorDatagramEndpoint (CHANGES 56) gains SetEcnReception and the
      read-only EcnReception, SendToEcn, SendSegmentsToEcn, and the virtual
      HandleDatagramEcn, which the backends now call for every datagram, with
      its marking, or deUnknown when reception is off. Its default calls
      HandleDatagram, so an endpoint that overrides only HandleDatagram works
      as before. SendToEcn and SendSegmentsToEcn refuse CE and unknown with
      cDatagramUnsupported, sending and counting nothing. tAsyncReactor gains
      the virtual SetDatagramEcnReception, SendDatagramEcn and
      SendDatagramSegmentsEcn; a backend that does not override them refuses
      reception and marks the same way, sends a marked batch one datagram at
      a time, and still sends Not-ECT. The IOCP backend receives with
      overlapped WSARecvMsg while reception is on, and sends a marked batch as
      one WSASendMsg carrying both the UDP segmentation offload and the
      marking; where the system refuses the two together, that batch goes one
      marked datagram at a time. epoll and kqueue read with recvmsg and its
      ancillary data, and send a marked batch one datagram at a time, as they
      send an unmarked one.
    - stSocket. tAbstractDatagramSocket.SendSegmentsToEcn, virtual: what
      SendSegmentsTo sends, every datagram marked; the default sends one
      marked datagram at a time, and deNotEct is SendSegmentsTo. The
      handle-level SendDatagramSegmentsEcn does the same for a socket handle,
      with the single WSASendMsg above on Windows. On Windows the handle-level
      SendDatagramEcn and ReceiveDatagramEcn look WSASendMsg and WSARecvMsg up
      once per process, not once per datagram. New: DatagramReceiveMessage and
      DatagramEcnFromControl, for a completion backend that posts its own
      WSARecvMsg.
    - tQuicEcnController, for tQuicClient and the server. An ACK frame that
      newly acknowledges a few packets costs about the same with thousands of
      marked packets in flight as with a few, also at the tracking limit. It
      used to compare every marked packet with every range of every ACK frame:
      with 4,000 in flight, two sends and one such ACK frame took 16 to 36
      microseconds on Windows, depending on the compiler, and a validated
      server, which marks every packet, would have paid that for each ACK
      frame it receives. Its results are unchanged. New: Marking(aSpace,
      aPending), the marking for a packet that will be recorded after aPending
      others of the same batch; it leaves the controller as it is.

    WHAT DID NOT CHANGE. tQuicClient's ECN behaviour, and the marking strategy:
    ECT(0) only, ten test packets, no revalidation after a failure. The
    server's congestion control, its ingress bounds, unmarked send batches, and
    everything on the reactor's TCP path.

    HOW IT WAS TESTED. QuicServerEcnTest runs TsmAsyncQUICServer and
    tQuicClient through a relay of two sockets that read and forward each
    datagram's ECN field, over IPv4 and IPv6 loopback. Before this change, the
    server sent all of its 237 datagrams Not-ECT and the client ended with ECN
    failed (36 of 46 checks). With it, 236 of 237 arrive ECT(0) - the remaining
    one is the Retry - and the client validates; when the relay clears the
    field, the server marks two datagrams, stops, and the transfer still
    completes (46 of 46: Delphi 13 and XE3, Win32 and Win64; Delphi 13 Linux64
    and macOS on an M1). Six deliberately broken builds (the marking dropped by
    the endpoint, by the socket for single datagrams or for batches, by the
    input queue or by the IOCP completion, and reception never turned on) all
    fail it. QuicSendBatchEcnTest runs one server connection against
    tQuicClient over loopback: once ECN is validated, ten packets go to the
    socket as one marked batch and the client receives all ten ECT(0); a batch
    the socket refuses to mark leaves unmarked in the same pass, with the same
    bytes; with three of the ten test packets spent, a burst of ten marks
    exactly seven. Before the batching change the ten went out one call each
    (30 of 46 checks of its first version); now 58 of 58 on the same compilers
    and platforms. Seven broken builds of the batching (a batch only when
    unmarked, sent unmarked, recorded unmarked, no pending count in the send
    loop, in the testing budget or in the tracking limit, no fallback) all fail
    it. ReactorEcnTest checks the endpoint on each backend, a marked batch
    included (68 of 68 on IOCP, Win32 and Win64; 59 of 59 on epoll and kqueue);
    two more broken builds, the marking left out of the segmented send and the
    IOCP batch sent unmarked, fail it. QuicEcnLedgerTest compares the
    controller with a copy of the previous one over 216,000 random calls -
    every result the same - and its cost check gives 0.87 to 1.08 times the
    time of two sends and an ACK frame with 4,000 marked packets in flight as
    with 40, and 1.02 to 1.21 times at the tracking limit (12,288), against 31
    to 76 times at 4,000 for the previous one (Delphi 13 and XE3, Win32 and
    Win64; Delphi 13 Linux64 and macOS; FPC 3.3.1 Linux64). QuicSendBatchTest,
    DatagramSegmentTest, QuicEcnTest, EcnSocketTest and UdpTest pass. Across a
    Wi-Fi LAN, from this server on Windows to tQuicClient on another Windows
    machine and on a Mac, the client validated ECN and received all 7,218
    packets of an 8 MiB response marked ECT(0); against the previous build it
    ended with ECN failed and none. In ten interleaved rounds of the LAN
    benchmark against the previous build, sending to MsQuic and to tQuicClient,
    throughput and the server's CPU time per GiB did not change measurably
    (-1.4% and -1.2%, +0.7% and -8.4%; p > 0.3). The runtime packages build for
    Win32 and Win64 with the same hints as before.


--------------------------------------------------------------------------------
TLS 1.3 CLIENT AUTHENTICATION: THE CertificateVerify SCHEME, AND THE CLIENT'S
CERTIFICATE IN A SNIF METHOD
================================================================================

Mutual TLS with plain ML-DSA certificates, the library on both ends, for a
listener that authenticates its clients by certificate and runs full
handshakes only. Both entries come from that work; SnifPeerCertTest checks
them, with every certificate and key generated in the run.


147. NEW - a Snif method served over TLS can read the client's certificate

    StreamSec.Snip.TLSOctetConnection, StreamSec.Snip.TLSServer.

    A remoted method never sees the connection its call arrived on, and the
    snip-over-TLS server connection published only RemoteAddress, so a Snif
    service behind a TsmAsyncTLSServer that required client certificates
    could not tell WHICH certificate the handshake had accepted - although
    the transport underneath has always known (iTLSConnectionInfo,
    AsyncTLSServer.txt section 8.2), and HTTP handlers reach it through
    Request.Connection.TransportInfo.

    NOW, inside a Snif call:

      lCert := TsnipTLSServer.CurrentPeerCertificate;   // iCertificate or nil
      lTLS  := TsnipTLSServer.CurrentTransportInfo;     // iTLSConnectionInfo

    Both read TsnifClassServer.CurrentContext, which belongs to the calling
    thread for one call, and answer nil outside a call and on a connection
    that is not snip over TLS. The same is reachable as the new interface
    IsnipTLSTransportInfo, by Supports on CurrentContext.Connection (as
    IsnifChannelBinding is), and as the TransportInfo and PeerCertificate
    properties of TsnipServerTLSOctetConnection. The connection takes the
    transport's iTLSConnectionInfo once, before the snip accept exchange, and
    keeps it for its own life; the certificate is read from that interface's
    locked snapshot each time.

    WHAT IT REPORTS. A certificate the handshake has already accepted - the
    server engine's trust configuration and the TLS 1.3 client-certificate
    checks - so what is left for the method is authorization. It is nil
    when the client sent none, after the TLS session has closed, and on a
    resumed TLS 1.3 session, where the server asks for no certificate and
    the ticket does not carry one: a listener that authorizes on the client
    certificate sets Options.SessionResumption := False. A certificate with
    no extendedKeyUsage extension is accepted as a client certificate (RFC
    5280: no extension, no restriction); TLS.txt section 4.5 had said
    clientAuth was required and now says what the check does, unchanged.
    The comments on iTLSConnectionInfo.IsResumed and iHttpConnectionInfo.
    IsResumed, which said a resumed session keeps the original certificate,
    now say it has none.

    HOW IT WAS TESTED. SnifPeerCertTest section 1, on Win32, Win64 and
    Linux64: a TsmAsyncTLSServer + TsnipTLSServer requiring a client
    certificate with resumption off, and TsnipTLSClient. With an ML-DSA-65
    leaf carrying serverAuth and clientAuth, a clientAuth-only leaf and a
    leaf with no extendedKeyUsage, the method's SHA-256 of
    CurrentPeerCertificate and of IsnipTLSTransportInfo's certificate equal
    the client's own, and CurrentTransportInfo reports a full TLS 1.3
    handshake with a certificate; no certificate (certificate_required), a
    serverAuth-only leaf (unsupported_certificate) and a leaf from an
    untrusted CA (unknown_ca) are refused and no call reaches the server.


148. FIXED, BEHAVIOUR CHANGE - TLS 1.3 accepted a CertificateVerify whose
    EdDSA or ML-DSA SignatureScheme did not match the certificate's key

    StreamSec.Mobile.TlsLayer (TTLS_HandshakeProtocol.VerifyTLS13CertVerify),
    which both roles and the QUIC handshake use.

    THE STEP THAT FAILED is the check of the SignatureScheme in a peer's
    CertificateVerify. The EdDSA and ML-DSA schemes each name one key type
    and one parameter set - 0x0807 ed25519, 0x0808 ed448, 0x0904 ml-dsa-44,
    0x0905 ml-dsa-65, 0x0906 ml-dsa-87. draft-ietf-tls-mldsa-06 section
    3.2: "The corresponding end-entity certificate MUST use the
    corresponding AlgorithmIdentifier from Table 1 in its
    SubjectPublicKeyInfo." The check accepted any of
    them that the local Options enabled and then verified the signature
    with whatever key the certificate held. So a server took a client
    CertificateVerify labelled 0x0904 or 0x0906 from an ML-DSA-65
    certificate, and a client took the same from a server, and 0x0807 from
    an ML-DSA-65 server; the handshake completed. A server refused 0x0807
    already, because a server engine holding no EdDSA certificate turns
    EdDSA off in its Options.

    WHAT IT WAS NOT. The signature was still verified, with the
    certificate's own key, over the right transcript: no peer could
    authenticate with a key it does not hold, and no forged signature was
    accepted. What was accepted is a signature under the wrong label, from
    a peer that does not follow the specification. The library's own
    senders choose the scheme from the key and were never affected, and
    classical schemes (RSA, ECDSA) are not touched by this change.

    NOW such a CertificateVerify is refused with illegal_parameter (47)
    before its signature is checked, by the server and by the client. (The
    draft names no alert for this. RFC 8446 section 6.2, illegal_parameter:
    "A field in the handshake was incorrect or inconsistent with other
    fields.")

    WHY A BEHAVIOUR CHANGE. A peer that labels its EdDSA or ML-DSA signature
    with another scheme, which completed a handshake before, is now refused.

    THE DISCRIMINATING TEST: present an ML-DSA-65 certificate and send its
    CertificateVerify with scheme 0x0904. An affected release completes the
    handshake; this one ends it with illegal_parameter.

    HOW IT WAS TESTED. SnifPeerCertTest sections 2 and 3, on Win32, Win64
    and Linux64, with a hand-built TLS 1.3 peer (ML-KEM-768,
    TLS_AES_128_GCM_SHA256) that signs CertificateVerify with an ML-DSA-65
    key and labels it 0x0904, 0x0906 or 0x0807, against our server and our
    client; 0x0905 is the control. Without the change 10 of the harness's 48
    checks fail - the server's 0x0904 and 0x0906, the client's 0x0904,
    0x0906 and 0x0807 - and none of the controls; with it all 48 pass.


149. FIXED - QUIC CRYPTO and stream receive reassembly cost grew with the
    square of the buffered bytes, and receive reassembly reused the raised
    send-window range budget

    StreamSec.Quic.Crypto (tQuicCryptoBuffer), StreamSec.Quic.Streams
    (tQuicStreamManager) and StreamSec.Quic.Connection (the 1-RTT CRYPTO
    buffer). These units are in no released build; this is a pre-release
    fix, not a security update.

    THE STEP THAT FAILED is reassembling out-of-order CRYPTO or STREAM bytes
    from a peer that never sends the opening byte, so the buffered run is
    never drained. Each insert rebuilt the whole pending range: it allocated
    a buffer the size of the merged range and copied the old range in, so
    appending one byte at a time to an N-byte run cost about N each time and
    about N*N/2 in all - estimated at tens of milliseconds of copying per
    datagram on one connection. The stream receive path had the same shape
    and, under HTTP/3, used a per-stream range budget that the send-window
    preparation had raised to 65536 (and to 262144 on the clients), so a peer
    could also hold tens of thousands of one-byte ranges, each insert
    rebuilding the whole range array.

    WHAT IT WAS NOT. No peer could read, alter or forge buffered data, and
    the byte budgets were always honoured; what was unbounded was processing
    time, not memory or confidentiality or integrity. The 62-bit offset
    limit, the conflict check on overlapping bytes and the delivery order are
    unchanged.

    NOW each insert costs in proportion to the bytes it adds. A contiguous
    append or prepend grows the stored piece in place with geometric capacity
    (held within twice the live bytes); only an insert that bridges or spans
    stored pieces builds a piece afresh. Receive reassembly has its own range
    budget, set once and never raised by the send-window preparation, and the
    total receive pieces are capped per connection so their metadata stays
    within about the buffer pool however many streams a peer opens. The 1-RTT
    CRYPTO level, where a peer never legitimately sends large CRYPTO, buffers
    at most a few KiB (RFC 9000 section 7.5 requires 4096) rather than a
    megabyte held for the life of the connection.

    THE DISCRIMINATING TEST: buffer a large run by appending one byte at a
    time while never sending the opening byte. An affected build copies about
    the square of the run; this one copies about twice the run.

    HOW IT WAS TESTED. QuicCryptoReassemblyTest (Win32 and Win64) builds an
    8192-byte CRYPTO run by one-byte appends and prepends and checks that the
    cumulative bytes moved stay under 32 times the run - about 33 million
    before the change, about 27 thousand after. QuicReceiveReassemblyTest
    (Win32 and Win64) does the same for stream receive, checks the receive
    range cap holds at 256 with the send budget raised to 262144, and checks
    the per-connection piece cap bounds the total. QuicStateTest,
    QuicTransportTest, QuicStreamServiceTest and QuicConnectionTlsTest pass
    unchanged.


150. FIXED - the QUIC listener's stateless-reply rate limit also gated
    admission, so a reply-less flood of unknown connection IDs could block new
    connections

    StreamSec.Mobile.AsyncQUICServer (tQuicServerState.Receive and Stateless).
    This unit is in no released build; this is a pre-release fix, not a
    security update.

    THE STEP THAT FAILED is admitting a new connection. Every datagram whose
    connection ID matched no entry first had to pass AllowStateless - a budget
    of 64 per second for the whole listener - before the Initial admission
    branch was even reached, even for datagrams that drew no reply. An off-path
    source spraying short-header datagrams with random IDs (needing no reply)
    spent the budget, and then first Initials and token-bearing Initials, which
    also carry unknown IDs, were dropped. A Retry handshake cost two slots, so
    admission could top out near 32 new connections a second even with no
    attacker.

    WHAT IT WAS NOT. The budget was never a bound on memory or on admitted
    connections - those are MaxConnections and MaxHandshakes - but governs only
    the stateless replies the server chooses to send. Nothing was read, altered
    or forged. QUICServer.txt describes the limit as governing unknown-packet
    replies, not admission.

    NOW the budget is spent inside Stateless, just before a reply is actually
    sent, and never on a datagram that draws no reply. Admission is bounded by
    MaxConnections and MaxHandshakes alone, so a reply-less flood of unknown IDs
    leaves new connections answerable.

    THE DISCRIMINATING TEST: send many short-header datagrams with unknown IDs,
    which draw no reply, then ask for version negotiation. An affected build has
    spent the whole budget on the flood and stays silent; this one still
    answers.

    HOW IT WAS TESTED. QuicAdmissionFloodTest (Win32) activates a listener on
    loopback, confirms version negotiation is answered, sends 200 reply-less
    short-header datagrams with unknown IDs, and confirms version negotiation is
    still answered. Without the change the second probe goes unanswered.


151. FIXED - Linux and Android QUIC sockets honoured a forged ICMP
    "fragmentation needed", clamping sends to a chosen address for about ten
    minutes

    stSocket.Posix (SetDatagramDontFragment). The datagram socket is in no
    released build; this is a pre-release fix, not a security update.

    THE STEP THAT FAILED is setting the don't-fragment policy a QUIC socket
    needs. On Linux and Android the code set IP_MTU_DISCOVER (and
    IPV6_MTU_DISCOVER) to IP_PMTUDISC_DO, which both sets the don't-fragment bit
    and honours the kernel's cached path MTU. An off-path source could send one
    spoofed ICMP "fragmentation needed" quoting the server's address to any
    victim address; Linux accepts it on an unconnected socket and caches a path
    MTU of 552 bytes for about ten minutes, after which every 1200-byte send to
    that address failed and the server retried in vain. The address may be a NAT
    address shared by many users.

    WHAT IT WAS NOT. Nothing in the protected flow was read, altered or forged;
    the effect was lost sends to one address. Windows is untraced; Darwin uses a
    separate don't-fragment option and is unaffected.

    NOW the option is set to IP_PMTUDISC_PROBE, which keeps the don't-fragment
    bit but ignores the cached path MTU, so a forged ICMP cannot clamp our sends
    below the QUIC 1200-byte minimum (RFC 9000 14.2.1 requires ignoring an ICMP
    PMTU below 1200). MsQuic and quinn do the same.

    THE DISCRIMINATING TEST: set don't-fragment on a datagram socket and read
    IP_MTU_DISCOVER back. An affected build reads IP_PMTUDISC_DO (2); this one
    reads IP_PMTUDISC_PROBE (3).

    HOW IT WAS TESTED. QuicDontFragmentTest (Linux64) opens IPv4 and IPv6
    datagram handles, sets don't-fragment, and reads IP_MTU_DISCOVER and
    IPV6_MTU_DISCOVER back with getsockopt; both read 3. Without the change both
    read 2.


152. FIXED - a snip peer could declare a frame of any size and make the
    receiver buffer without bound, and an over-size length wrapped an Integer
    and desynced the framing

    StreamSec.Snip.BaseOctetConnection (GetHasData, new MaxFrameSize),
    StreamSec.Snip.TLSOctetConnection (AddIn) and
    StreamSec.Snip.QUICOctetConnection (AddStreamData). Snip over SSH
    (TsnipSSHOctetConnection) does not override GetHasData, so the same
    MaxFrameSize check now bounds its declared length, which was unchecked and
    could wrap the Integer the same way; its own buffering is pull-driven and
    was already bounded. Snip over TLS and SSH shipped in 4.1.4.360 and
    4.1.4.361, so those twins are in a released build; this is an ordinary fix,
    not a security update (SECURITY.txt section 3). Snip over QUIC is
    unreleased.

    THE STEP THAT FAILED is reading a message's declared length from its header.
    GetHasData refused only a zero length, so a peer that completed the TLS or
    QUIC handshake (client certificates are off by default) could declare a
    frame of any size and keep sending, and the receiver buffered every octet:
    the TLS buffer grew with no ceiling, and the QUIC path returned flow-control
    credit the instant bytes were buffered, re-opening the window. The connect
    timeout bounds only the time before the connect frame, and the read timeout
    defaults to no bound after it, so process memory ran out (on Win32 the
    address space first), multiplied across MaxConnections. A declared length of
    2^31 or more also wrapped the Integer message length negative and desynced
    the framing.

    WHAT IT WAS NOT. Nothing in a message was read, altered or forged; the
    effect was memory and, for the Integer wrap, a lost frame boundary. A peer
    still has to complete the handshake to send any frame at all.

    NOW an inbound header declaring more than MaxFrameSize octets (default 16
    MiB, and never more than an Integer holds) is refused and the connection
    dropped before the length is stored. The TLS buffer holds at most one whole
    frame plus a reader's headroom; past that the connection is dropped rather
    than the plaintext retained. On QUIC, flow-control credit is withheld once
    that ceiling is reached, so the stream window stops advancing and the peer
    is pushed back. MaxFrameSize is a property; raise it where an application's
    legitimate messages are larger.

    WHY NOT A LARGER DEFAULT. A frame genuinely larger than 16 MiB is rare in a
    request/response protocol; an application that needs one sets MaxFrameSize,
    and every other deployment gets the bound for free.

    THE DISCRIMINATING TEST: feed a header declaring a 4 GiB length, or declare
    a legal frame and keep sending past the ceiling. An affected build stores a
    negative length or buffers without limit; this one refuses the frame and
    drops the connection.

    HOW IT WAS TESTED. SnipFrameLimitTest (Win32 and Win64) drives the octet
    framing in memory: a 4 GiB length, a 2^31 length and a length one octet over
    MaxFrameSize are each refused; an ordinary frame and one at exactly
    MaxFrameSize are delivered; buffering one octet past the ceiling is refused.
    The SSH octet connection, sharing the base check, refuses a 4 GiB and an
    over-MaxFrameSize length too. Without the change these refusals do not
    happen.


153. FIXED - every ACK frame scanned the whole recovery ledger, so a flood of
    identical ACK frames made the cost grow with the ledger times the frame
    count

    StreamSec.Quic.Recovery (AckReceived) and StreamSec.Quic.Transport (the
    frame loop that dispatches ACKs). These units are in no released build; this
    is a pre-release fix, not a security update.

    THE STEP THAT FAILED is processing a decoded ACK frame. AckReceived
    allocated two arrays the size of the whole sent ledger and tested every
    unacknowledged entry against the ACK before it could tell the ACK made no
    progress, and it ran once per ACK frame in a packet. A peer that
    acknowledges only one packet holds the ledger near its cap, then sends many
    identical ACK frames in each packet; the cost was the ledger size times the
    number of ACK frames.

    WHAT IT WAS NOT. The acknowledgements were always applied correctly; the
    cost was processing time. The ledger was already bounded.

    NOW at most one ACK per packet reaches recovery - a later ACK frame in the
    same packet acknowledges nothing a peer will not re-send - and a repeat of
    the previous ACK for a space is dropped before the ledger is scanned, so a
    flood of identical ACK frames costs a range comparison each, not a ledger
    pass. The ledger-sized scan and its two allocations happen only for an ACK
    that is not a repeat.

    THE DISCRIMINATING TEST: hold the ledger near its cap and feed many
    identical ACK frames. An affected build scans the ledger once per frame;
    this one scans it once.

    HOW IT WAS TESTED. QuicAckFloodTest (Win32 and Win64) sends 2000 packets,
    holds them pending, then feeds 500 identical ACKs for a packet number never
    sent and reads the cumulative scan work: it stays at one ledger pass (2000),
    not 500 of them (1,000,000 before the change), and a distinct ACK still
    makes progress. QuicConnectionTlsTest's real handshakes pass unchanged.


154. FIXED - the QPACK dynamic table shifted its whole slot array on every
    insertion once the table ran near its maximum, so inserting under churn cost
    the square of the table size

    StreamSec.Http.Qpack (tQpackTable.Insert). The dynamic table is used only
    when dynamic QPACK is switched on (opt-in), on the server and on a client
    whose capacity is above zero. This unit is in no released build; this is a
    pre-release fix, not a security update.

    THE STEP THAT FAILED is reclaiming the slots of evicted entries after an
    insertion. The compaction that shifts the live entries down over the evicted
    prefix was keyed partly on the slot array reaching a size, not only on the
    evicted prefix growing large. Once the table held near its maximum entries
    that size test was true after every compaction, so a peer that keeps the
    table full - 32-byte insertions and one-byte Duplicate instructions - forced
    a full-array shift on every insertion, contradicting the amortized bound the
    code's own comment claimed.

    WHAT IT WAS NOT. The table's contents and indices were always correct; the
    cost was processing time, and only with dynamic QPACK switched on.

    NOW compaction happens only when the evicted prefix has grown past half the
    slot array, so each compaction moves at most the live entries and leaves at
    least that many insertions before the next, for a constant amortized shift
    per insertion while still bounding the slot array to twice the live entries.

    THE DISCRIMINATING TEST: set a dynamic capacity and insert far more entries
    than it holds, keeping it full. An affected build shifts the slot array on
    nearly every insertion; this one shifts amortized.

    HOW IT WAS TESTED. QpackInsertChurnTest (Win32 and Win64) sets an 8192-byte
    capacity and feeds 5000 minimal insertions, then reads the cumulative slot
    shift work: it stays near the insertion count (about 4600), not near the
    insertions times the live entries (about 1.2 million before the change).


155. FIXED - the server's per-packet route lookup scanned every connection's
    whole connection-ID history, which a peer could grow by rotating its
    connection IDs

    StreamSec.Quic.Routes.inc (tQuicRouteSnapshot.Update), reached from
    StreamSec.Mobile.AsyncQUICServer (tQuicServerState.Receive). These units
    are in no released build; this is a pre-release fix, not a security update.

    THE STEP THAT FAILED is choosing the connection a received packet belongs
    to. The server matches the packet's destination connection ID against each
    connection's published route set, and that set was built from the local
    connection-ID registry, which is append-only: a retired ID stayed in the
    routes for the life of the connection. A peer that kept issuing itself new
    connection IDs and retiring the old ones grew its route set toward the
    registry's history cap, so the per-packet scan - already linear in the
    number of connections - grew linear in each peer's rotation history too.

    WHAT IT WAS NOT. Routing was always correct: a retired ID is already
    refused by the core, so a packet that matched one was rejected, never
    misdelivered. Only the length of the scan was at fault.

    NOW a retired connection ID is left out of the published route set, so a
    connection's routes are bounded by its active connection-ID limit, not by
    how many IDs it has rotated through. The snapshot takes the registry's
    active count alongside its history count as the cache key, so a retirement
    that leaves the history length unchanged still rebuilds the set in place.

    THE DISCRIMINATING TEST: publish routes, retire an advertised ID, then
    republish. An affected build keeps the retired ID and the set length tracks
    the whole history; this one drops it and the set length equals the
    registry's active count.

    HOW IT WAS TESTED. QuicRouteSnapshotTest (XE3 and 13, Win32 and Win64, run
    by Test\quicserver\Run-QuicWork.ps1) drives the route snapshot through
    issuance, retirement and replenishment under a concurrent reader: after a
    retirement the published set drops the retired ID and its length equals the
    registry's active count, and across sixty-three rotations the reader sees
    only the active IDs. The check floor rose from 100 to 196.

156. FIXED - the HTTP/3 server re-scanned every request stream's input
    deadlines twice for each parsed frame piece, and once more per stream while
    resuming blocked QPACK streams, so the deadline work grew with the piece
    and stream counts

    StreamSec.Http.Http3Server (tHttp3ServerConn.ProcessInputDeadlines, reached
    from ReadFrames and ResumeQpack). This unit is in no released build; this is
    a pre-release fix, not a security update.

    THE STEP THAT FAILED is checking input-stage deadlines while parsing
    received bytes. ProcessInputDeadlines walks every request stream on the
    connection; ReadFrames called it before and after each parsed frame piece,
    and ResumeQpack called it once per stream in a loop over all streams. A peer
    that delivered a request in many small pieces, or kept many streams open,
    made that scan run again and again inside the handling of one input, so the
    cost was the number of pieces, or streams, times the number of streams.

    WHAT IT WAS NOT. The deadlines were always enforced correctly; the cost was
    the repeated scanning.

    NOW the full scan runs at most once per millisecond tick. Deadlines are
    millisecond-granular and a freshly armed one is always set in the future, so
    repeating the scan within one tick cannot change which have expired; a
    second or later call in the same tick returns at once. The next tick scans
    again, so an expired deadline is still enforced.

    THE DISCRIMINATING TEST: open many request streams and feed one of them a
    byte at a time, then read the cumulative scan work. An affected build scans
    on every piece, so the work grows with the byte and stream counts; this one
    does one pass per tick.

    HOW IT WAS TESTED. Http3DeadlineScanTest (Win32 and Win64) opens 32 request
    streams and drips 256 single bytes into another, then reads the cumulative
    deadline scan work: it stays within one pass over the streams per tick (0
    extra passes when the burst fits a tick), not the 36864 an unfixed build
    runs. A second connection with a one-millisecond SETTINGS deadline, pumped
    after a pause, still closes, so the per-tick throttle does not suppress
    enforcement.

157. REDACTED - QUIC peer address without the port
    consolidated into entries 95 and 139. This number is retained for reference.

158. REDACTED - TsmAsyncQUICServer peer and ALPN-token filter
    consolidated into entry 95. This number is retained for reference.

159. NEW + FIXED - the snip components publish MaxFrameSize, so the frame-body
    limit of entry 152 can be raised for the connections they create

    StreamSec.Snip.TLSServer, StreamSec.Snip.QUICServer,
    StreamSec.Snip.TLSClient (TsnipCustomTLSClient and its descendants),
    StreamSec.Snip.QUICClient
    (TsnipCustomQUICClient and its descendants), StreamSec.Snip.SSHClient,
    StreamSec.Snip.SSHServer; TsnipClient and TsnipServer forward it to their
    own SSH components. StreamSec.Snip.BaseOctetConnection shares the check.

    THE STEP THAT FAILED is receiving a legitimate message larger than 16 MiB
    through a connection a component created. Entry 152 bounded one inbound
    frame body, but only the octet connection exposed the setting; the
    components copied padding and timeouts into the framers they made and left
    MaxFrameSize at its default. A message is one frame, so an application that
    sends, say, a 38 MB file as one snif argument had no way to accept it.

    NOW the published value (default 16 MiB, at least 1, refused at assignment
    otherwise) is copied into every new framer before its first read; a live
    framer keeps its own limit. It bounds one frame body and, over TLS and QUIC,
    the buffered plaintext. A peer can make this end buffer about one frame per
    connection, so choose it for the largest legitimate message and the number
    of concurrent connections.

    HOW IT WAS TESTED. SnipFrameLimitTest drives all six components and both
    wrappers through their real framer factories and session constructors:
    defaults, a custom boundary above 16 MiB accepted, one octet more refused,
    0 and negative refused at assignment, forwarding, live framers unchanged.
    98 passed on Win32 and Win64; a variant without the copies fails 28.

160. REDACTED - HTTP/3 server send window
    consolidated into entry 95. This number is retained for reference.

161. REDACTED - HTTP/3 request blocks and stream retirement
    consolidated into entries 82 and 95. This number is retained for reference.

162. REDACTED - HTTP/3 close code after a drain
    consolidated into entry 95. This number is retained for reference.


--------------------------------------------------------------------------------
THE EMBEDDED CCADB ROOT SET
================================================================================


163. BEHAVIOUR CHANGE - the embedded root set no longer contains the three
    emSign roots that the Mozilla root program no longer lists for websites

    StreamSec.Mobile.CCADBRoots, surfaced by TsmCCADBTrustAnchors
    (StreamSec.Mobile.CCADB).

    The unit embeds the Mozilla root program's CCADB export, filtered to the
    websites trust bit. On 2026-10-25 that export listed 118 roots, where the
    set embedded since 2026-08-11 has 121, and it added none. The three it no
    longer lists are removed:

      CN=emSign ECC Root CA - G3,O=eMudhra Technologies Limited,OU=emSign PKI,
        C=IN
      CN=emSign Root CA - C1,O=eMudhra Inc,OU=emSign PKI,C=US
      CN=emSign ECC Root CA - C3,O=eMudhra Inc,OU=emSign PKI,C=US

    An application that trusts through TsmCCADBTrustAnchors therefore no
    longer accepts a peer whose certificate chain ends at one of these roots;
    every other root is unchanged. Established and Verified both read
    2026-10-25 and RootCount reads 118. On that day each of the 118 was checked
    again to be self-signed, to carry basicConstraints CA:TRUE and to be
    unexpired. An application that still has to reach such a peer can add the
    root as a trust anchor of its own.