Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

Release notes 4.1.2.355

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

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

--------------------------------------------------------------------------------
2026-08-11  AN ASYNC TLS SERVER, AN HTTP STACK, MAIL, PDF SIGNING, AND THREE
            TLS HANDSHAKE FIXES
================================================================================

Everything below is the state of the library as it now stands, relative to
release 4.1.1.354.

Most of it is new surface rather than changed surface. Four subsystems arrive
whole: an asynchronous implicit-TLS server that serves many connections on a
small pool of I/O threads, an HTTP layer (server and client, HTTP/1.1 and
HTTP/2) that runs on it, a complete mail layer (Internet messages, S/MIME, and
SMTP, POP3 and IMAP at both ends over one maildir and one account store), and
PDF signing (PAdES signatures, an RFC 3161 timestamp client, and a verifier
that reads what the signature really covers). Alongside them: TLS and HTTPS
client components, a filesystem confinement primitive with the
SFTP server moved onto it, snip carried over TLS, and ACME renewal that needs
no ACME code.

A new demo puts most of that together in one deployment - see entry 50. If you
would rather read working code than a list, start there.

Existing code is affected in nine places. Read entries 14, 15, 16, 27, 29,
30 and 63 before upgrading: three defects in the TLS handshake are fixed - one
let a valid connection fail, the other two let invalid peer input through - a
TLS 1.3 server no longer reports an ALPN protocol to a client that offered
none, SFTP path handling is stricter on Windows, and the SSH and SFTP wire
types are spelled differently (a no-op on Windows). Entry 38 changes which AES
implementation actually runs: hardware AES-NI reaches TLS at last, and
machines without it get a constant-time software AES that is slower than the
cache-timing-leaky tables it replaces. Entry 38 also moves the x86 and x64
table assembler out of stAES into a unit of its own, stAESBG, so an
application that links only stAES gets the portable Pascal. Entry 61 replaces
the third-party Winsock declarations with the library's own: existing code
compiles against the same names and layouts, a uses clause that names one of
the replaced units is warned rather than broken, and a service-name lookup
that returned a meaningless port on Win64 is corrected.


--------------------------------------------------------------------------------
 THE MAIL SUBSYSTEM
--------------------------------------------------------------------------------

1. NEW - TsmEmail: Internet messages, parsed and composed

   StreamSec.Mail.Message reads and writes .eml files and streams - RFC 5322
   for the message, RFC 2045-2047 for MIME - as a component and the two
   classes beneath it:

       TsmEmail        the component: a message, its headers, its part tree
       tMimeEntity     one MIME entity: headers plus a body or child parts
       tMailHeaders    an ordered, duplicate-tolerant header block

   Loading and saving take a file, a stream or a tBytes; Root is the message
   entity and Headers its header block. The published properties - Subject,
   From, Sender, ReplyTo, Recipients (the To header; to is a reserved word),
   Cc, Bcc, MessageId - present the DECODED, human-readable view, and setting
   one applies RFC 2047 encoding when the text needs it. NewMessage,
   SetTextBody, AddAttachment and GenerateMessageId build a message from
   nothing; FindTextEntity, BodyText, FromAddress, SenderAddress and
   GetEnvelopeAddresses read one back.

   A PARSED MESSAGE THAT IS SAVED UNMODIFIED IS BYTE-IDENTICAL, and that is
   the property everything else here rests on. Every entity retains the exact
   octets it was parsed from and re-emits them until something in that entity
   changes; a header edit invalidates the entity that carries it and the
   entities that contain it, and leaves every untouched sibling part exactly
   as it arrived.

   It is not a detail of the implementation. A DETACHED SIGNATURE IS COMPUTED
   OVER OCTETS, so a mail model that re-encodes a part on output cannot verify
   one: the bytes that were signed are gone by the time the signature is
   checked. That is why entry 2 can both produce and verify multipart/signed,
   and it is the reason this component exists rather than an adapter to an
   existing one.

   Header values are refused, not sanitised. SetField raises on CR or LF in a
   name or a value - a header assembled from text that came in over the
   network is the header-injection family, and there is no safe way to guess
   what was meant. The text path (SetTextField, and every published property)
   accepts any string and emits encoded words, so control characters travel
   inside a word rather than breaking the block.

   Parsing is deliberately tolerant and composing deliberately strict: bare-LF
   line ends, a line without a colon and an unknown transfer encoding are all
   accepted on the way in, while output is CRLF, folded below 78 columns, and
   encoded where it must be. Four bounds cap what a hostile message can make
   the parser allocate - cMailMaxHeaderBlock (1 MiB per entity),
   cMailMaxFieldCount (1000), cMailMaxNestingDepth (16) and cMailMaxPartCount
   (1000) - each raising eMailMessageError rather than growing.

   The codecs are exported, because they are useful on their own and because
   they can then be tested on their own: MailQPEncode / MailQPDecode,
   MailBase64Encode / MailBase64Decode, MailEncodeHeaderText /
   MailDecodeHeaderText, MailCharsetEncode / MailCharsetDecode,
   MailParseAddressList, MailComposeAddress, MailTryParseDate, MailFormatDate
   and MailGenerateBoundary. MailMessageSelfTest round-trips all of them.

   Character sets: us-ascii, utf-8, iso-8859-1 and windows-1252 are decoded
   exactly and anything else falls back to Latin-1, so an unknown charset
   displays wrongly rather than losing octets. Encoding accepts utf-8,
   us-ascii and iso-8859-1 and raises on anything else rather than writing a
   label it did not honour.


2. NEW - TstSMIMEBroker: S/MIME on top of the CMS broker

   StreamSec.Mail.SMIMEBroker descends from the CMS broker in
   StreamSec.DSI.PkixCms and adds Encode and Decode overloads that take
   TsmEmail messages where the inherited ones take streams:

       function Encode(aActions: tContentTypeArray; aSrc, aDest: TsmEmail;
                       aDataType: tPKCS7DataType = pData): Boolean;
       function Decode(aSrc, aDest: TsmEmail;
                       aActionDescriptions: TStrings): Boolean;
       function Decode(aSrc, aDest: TsmEmail;
                       var aActions: tContentTypeArray): Boolean;

   Wire SignedData, EnvelopedData and KeysAndCerts exactly as for
   TstMPCMSBroker; the cryptography is those components' and is unchanged. The
   layering convention is theirs too - aActions is INNERMOST FIRST, so
   MakeContentTypeArray([pSignedData,pEnvelopedData]) is sign-then-encrypt,
   and Decode reports what it peeled in the same order.

   BOTH S/MIME SHAPES ARE PRODUCED AND BOTH ARE VERIFIED. SignedFormat selects
   multipart/signed with a detached application/pkcs7-signature part (the
   default, and what an agent without S/MIME support can still read) or opaque
   application/pkcs7-mime signing. It applies to the OUTERMOST layer only: a
   clear signature buried inside an encryption layer clarifies nothing to
   anyone, so an inner signing layer is always opaque.

   WHAT IS PROTECTED IS THE CONTENT ENTITY - the Content-* headers and the
   body - not the whole message with its addresses and trace headers. That is
   what interoperating mail clients sign and encrypt. Messages that wrap a
   complete message are still decoded: a recovered entity that turns out to
   carry From, To or Subject replaces the destination, so mail produced by the
   older Indy-based demo broker reads back correctly.

   The signer is resolved from the From address across every signature
   algorithm the CMS layer supports - RSA, ECDSA, Ed25519, Ed448 and ML-DSA -
   rather than RSA alone, and OnAddSigner still overrides the lookup entirely.
   Recipients are the From and Sender addresses plus To, Cc and Bcc, so the
   sender can read the copy in the sent folder and a Bcc recipient can open
   what was sent. Note what that implies: a RecipientInfo names the
   certificate it was wrapped to, so every recipient can see that another one
   exists.

   Detection is available without decoding - CheckIsSMIME and
   CheckIsMultipartSigned answer for a message, CheckIsSMIMEEntity and
   CheckIsMultipartSignedEntity for one entity - and both the pkcs7-mime and
   x-pkcs7-mime spellings are recognised, as is the .p7m attachment form used
   by agents that lose the content type in transit.

   Everything stays in memory. Ciphertext and recovered plaintext travel in
   secure memory streams and are wiped; nothing is written to a temporary
   file.


3. NEW - TsmSMTPClient: message submission over TLS

   StreamSec.Mail.SMTPClient submits mail (RFC 5321, RFC 6409) on the TLS
   client base of entry 11, in the same two tiers: TsmSMTPClient creates and
   owns its TLS configuration, TsmAdvancedSMTPClient takes an external one.

       Client.Host := 'smtp.example.com';
       Client.Port := 465;                       { implicit TLS, the default }
       Client.UserName := 'alice';
       Client.SetPassword(lPassword);
       Client.Open;
       Client.SendMail(lMessage);                { a TsmEmail }
       Client.Close;

   Open brings the session all the way to ready-to-submit: connect, greeting,
   EHLO, and - with ImplicitTLS False - STARTTLS followed by a SECOND EHLO,
   because a capability list learned in cleartext was learned from whoever
   was on the wire. Authentication runs when UserName is set.

   Port 587 with STARTTLS is supported because one large deployment offers
   nothing else, not because it is preferable; RFC 8314 asks for implicit TLS
   and that is the default. SendMail also takes an explicit envelope
   (a reverse path, a recipient list and the message octets) for callers that
   own that decision themselves.

   AUTHENTICATION REFUSES TO RUN WITHOUT TLS, whatever RequireTLS says. PLAIN
   and LOGIN are the password under a trivial encoding, so there is no
   configuration in which sending them over a cleartext connection is the
   caller's business. The credential is held as an iSecretKey and wiped;
   SetPassword is the convenience for a caller holding a string.

   The Bcc header is REMOVED from the octets that go on the wire while its
   addresses stay in the envelope - which is what makes a blind copy blind -
   and the caller's message object is not modified. Dot-stuffing and CRLF
   normalisation are applied to the message as it is sent, so a body line
   consisting of a single dot cannot end the transfer.

   A negative reply raises eSMTPClientError carrying ReplyCode and the
   server's text, after a best-effort RSET that leaves the session usable for
   another attempt - a refused recipient does not cost the connection.
   Extensions, SupportsExtension, ExtensionParams and ServerMaxSize report
   what the server advertised; a message larger than an advertised SIZE limit
   is refused before MAIL FROM rather than after DATA, and BODY=8BITMIME is
   used when the server offers it and the message needs it.

   It is a submission client, not an MTA: no MX resolution, no relaying, no
   queue and no retry.

   THE DEMO for all three of the above is the Mail folder under Demos,
   present for every supported Delphi version. It imports an identity and a
   root, composes a message with an attachment, signs and encrypts it, writes
   and re-reads the .eml - reporting each layer it peeled and who signed - and
   submits it over TLS. The certificate wiring on its data
   module is the same arrangement the CMS demo uses, with the one difference
   S/MIME requires: the clear-text-name indexes are keyed on the e-mail
   attribute, because that is what the broker's '/E=<address>' lookups match.

   IT RUNS OUT OF THE BOX. A demo CA and two identities - alice@example.com and
   bob@example.net, the addresses the demo starts with - ship alongside it, PFX
   password 'abc'. They are test certificates: issued to nobody, trusted by
   nothing, and of no use outside the demo. MailDemoCertGen.dpr, in the same
   folder, mints a fresh set when they expire; readme.txt covers both. Read that
   generator if you need to know what an S/MIME certificate has to carry - the
   emailAddress attribute the lookup matches, keyUsage for signing AND for being
   an encryption recipient, and emailProtection in extendedKeyUsage.


4. NEW - TsmSMTPServer: mail arriving, not just mail sent

   StreamSec.Mail.SMTPServer is a receiving MTA as one component. It serves
   three ways in, and they run together:

       Server      a TsmAsyncTLSServer  -> implicit TLS (SMTPS, RFC 8314),
                                           conventionally port 465
       Inbound     its own listener     -> cleartext + STARTTLS, port 25,
                                           the mail exchanger role
       Submission  its own listener     -> cleartext + STARTTLS, port 587,
                                           RFC 6409 message submission

   One implementation of the policy serves all three, which is what stops the
   relay gate from being right on one port and wrong on another.

   DENY BY DEFAULT. A recipient is accepted when it is in a local domain, when
   the session authenticated, when the peer presented a client certificate and
   RelayForClientCertificate is set, or when the peer is in RelayNetworks.
   OnCheckRelay then gets the last word on every recipient. With none of those
   configured the server accepts nothing and relays nothing.

   The inbound and submission roles differ in exactly one thing and it is the
   thing that matters: an inbound exchanger accepts mail for the domains this
   host serves FROM ANYBODY and relays nothing, while submission relays for
   authenticated senders. Both are per listener, so neither can inherit the
   other's rules.

   Mail for a local domain goes to the maildir (entry 5). Anything else goes to
   an on-disk queue with retry, bounces (RFC 3464) and a delivery agent -
   either a smarthost you configure or MX delivery (entry 10).

   ASSIGN Store WHEN ANYTHING ELSE SERVES THE SAME MAILBOXES. Given a
   TsmMailStore the server writes into THAT object; given only MailboxRoot it
   opens the tree itself, which is correct for a host that does nothing but
   receive and wrong the moment POP3 or IMAP is added beside it. Two components
   over one directory each hold their own in-process lock, and a lock only
   guards an index rewrite against holders of the same lock. With Store
   assigned, MailboxRoot and Mailboxes are not consulted - the store already
   knows both.

   DATA ends on CRLF and nothing else, so <LF>.<LF> and <CR>.<CR> cannot
   terminate a message (the CVE-2023-51764 family) whatever BareNewlinePolicy
   does with the octets. AUTH PLAIN and LOGIN are refused on a cleartext
   channel unconditionally, not as a setting.

   Accepting is durable: by the time the sending client has its 250, the
   message is on disk and will survive the process.


5. NEW - TsmMailStore: one maildir, shared by everything that touches it

   StreamSec.Mail.Maildir is the mailbox tree as a single component, so the
   SMTP server that writes it and the POP3 and IMAP servers that read it are
   pointed at THE SAME OBJECT rather than three configured with the same
   directory - one component in each server's Store property. Three objects
   over one tree means three mailbox lists that can disagree and three
   in-process locks that guard nothing against each other.

   Maildir++ layout: write into tmp, flush, rename into new - one atomic rename
   is the commit, so a crash can leave a stray file in tmp but never a
   half-written message in new. Flags travel in the file name; folders are
   '.Name' directories; a UID index gives IMAP its UIDVALIDITY and UIDNEXT.

   With Users assigned, the accepted addresses ARE the accounts: an account is
   a mailbox is a maildir. Without it, fill in Mailboxes by hand.

   No peer-supplied octet reaches a path in the default configuration. A
   mailbox directory comes from configuration or from the application's own
   resolver; the peer's address is a lookup key, and the file name is
   generated.


6. NEW - TsmMailUsers: the accounts, with Argon2id verifiers

   StreamSec.Mail.Users holds one verifier per address and answers one
   question: does this credential match. Passwords are never stored, and a
   sign-in attempt for an address that does not exist still performs a
   derivation, so the answer takes the same time either way and the store
   cannot be used to enumerate accounts.

   It is the store the SMTP, POP3 and IMAP servers all consult, so an account
   removed is an account that can no longer collect mail, submit mail, or open
   a mailbox - one place, one answer.


7. NEW - SPF, DKIM and DMARC on received mail, and DKIM on sent mail

   StreamSec.Mail.Spf, .Dkim, .Dmarc and .MessageAuth evaluate what arrives and
   sign what leaves, over a DNS client (StreamSec.Mail.Dns) that speaks to the
   resolver over TCP and can be substituted through iDnsResolver.

   SPF (RFC 7208) evaluates the sending host against the domain's record, with
   the lookup budgets the RFC sets - they are protocol, not tuning, and
   exceeding one is a permerror rather than a slower answer.

   DKIM (RFC 6376) verifies the signatures on an incoming message and signs
   outgoing mail with rsa-sha256 or ed25519-sha256. The signing key is a key
   COMPONENT on TsmSMTPServer.DkimKey - a TstRSAKey or a TstEdDSAKey, wired in
   the Object Inspector, with the design-time drop-down narrowed to components
   that could actually sign a DKIM signature.

   AND IT PUBLISHES ITS OWN PUBLIC KEY. DkimDnsName gives the owner name a
   verifier will query, <selector>._domainkey.<domain>, and DkimDnsRecord gives
   the TXT record to publish there, generated from the key the server will
   actually sign with. That is the step this normally leaves to an operator with
   a hex dump, and it is easy to get wrong: RSA publishes a base64
   SubjectPublicKeyInfo while Ed25519 publishes the bare 32 octets (RFC 8463),
   and a verifier handed the wrong one sees a key it cannot parse. Building the
   record from the assigned key means the published record and the signature
   cannot disagree. DkimRecordName and DkimPublicKeyRecord in
   StreamSec.Mail.Dkim do the same without a server component.

   DMARC (RFC 7489) is the part that makes the other two mean something: it is
   ALIGNMENT that matters, not a pass. A DKIM signature by any domain proves
   only that that domain signed it, so an unaligned pass is not evidence about
   the From address at all. One aligned pass is enough; none is a failure
   whatever else succeeded.

   The results are attached to the session, so OnCheckRelay and the delivery
   policy can act on them, and are written into an Authentication-Results
   header for whatever reads the message later.


8. NEW - TsmPOP3Server and TsmPOP3Client

   StreamSec.Mail.POP3Server serves RFC 1939 on port 110 with STLS and on 995
   with implicit TLS, out of the maildir in entry 5. The maildrop is opened
   exclusively for the length of the session, as RFC 1939 requires, and it is
   released on every exit path - QUIT, either timeout, a dropped socket, an
   exception inside a command - so a client that vanishes does not lock its own
   mailbox out until the lock goes stale.

   Deletions become real only in UPDATE state. An autologout does not enter it,
   so a timed-out session deletes nothing.

   Every password mechanism is refused on a cleartext channel unconditionally,
   and CAPA advertises nothing the server would then refuse.

   StreamSec.Mail.POP3Client is the other end, in the usual two tiers -
   TsmPOP3Client owns its TLS engine, TsmAdvancedPOP3Client is given one - with
   STAT, LIST, UIDL, RETR, TOP, DELE and RSET, and retrieval straight into a
   TsmEmail.


9. NEW - TsmIMAPServer and TsmIMAPClient

   StreamSec.Mail.IMAPServer serves IMAP4rev1 (RFC 3501) with IDLE (RFC 2177)
   and UIDPLUS (RFC 4315), on port 143 with STARTTLS and on 993 with implicit
   TLS, out of the same maildir. Mailboxes can be created, renamed, deleted and
   subscribed to; RENAME moves a folder's children with it, and subscriptions
   are stored where an existing maildir keeps them.

   Unlike POP3 the mailbox is not opened exclusively, because IMAP expects
   concurrent sessions on one mailbox.

   FETCH answers FLAGS, UID, INTERNALDATE, RFC822.SIZE, the body and header
   items, and ENVELOPE, BODY and BODYSTRUCTURE - the last three computed from
   the message with the same MIME parser TsmEmail uses, so a client is told
   about the structure that is actually there. BODY.PEEK does not set \Seen.

   THE LITERAL IS READ AS DATA. An IMAP command can announce its own length
   mid-command, and those octets may spell a complete second command; they are
   counted, never scanned for a delimiter, so a client cannot make the server
   execute what it sent as data. Non-synchronising literals are refused rather
   than read as ordinary ones.

   StreamSec.Mail.IMAPClient is the other end, in the same two tiers.
   EVERYTHING IT ADDRESSES IS ADDRESSED BY UID: a message sequence number is
   renumbered by any expunge, including one another client caused between two
   of this client's own commands, so an API built on them would be a race.


10. NEW - MX delivery, with MTA-STS

   StreamSec.Mail.SMTPMx delivers to the recipient domain's own mail exchanger
   instead of, or behind, a smarthost: MX records in preference order, RFC
   5321's implicit MX when a domain publishes none, and RFC 7505's null MX
   treated as the permanent refusal it is.

   THE TLS PROBLEM IT EXISTS TO GET RIGHT. Between MTAs there is no shared
   configuration and no password, so opportunistic STARTTLS protects against a
   passive observer and nothing else - an active attacker strips STARTTLS from
   the EHLO response and the sender delivers in the clear. Verifying the
   certificate does not fix that and is worse than useless: the MX name came
   from unsigned DNS, so whoever forged the MX answer also chose the name that
   would be checked, while an attacker who simply strips STARTTLS is never
   asked for a certificate at all.

   MTA-STS (RFC 8461) closes it, because the policy arrives over a channel the
   DNS attacker does not control. StreamSec.Mail.MTASTS discovers it - a TXT
   record carries an id, the policy itself is fetched over HTTPS from
   mta-sts.<domain>, and it is the certificate for THAT host that makes the
   policy authentic. Redirects are not followed, because a redirect moves the
   name being checked.

   A FAILED LOOKUP NEVER TURNS ENFORCEMENT OFF. Suppressing the TXT record,
   blocking the fetch and serving a broken policy are all things an attacker
   can do, and none of them removes a policy already cached. A domain turns
   enforcement off by publishing one that says so.

   What the domain publishes RAISES the sender's own TLS policy and can never
   lower it, and under enforce an MX the policy does not name is not used at
   all - a forged MX answer is exactly how a host that is not the domain's
   would be reached.

   WHAT IS NOT OFFERED, and will not be: looking for some other relay that
   happens to support TLS when the recipient's does not. That means finding a
   host willing to relay for a domain it does not serve, and it is strictly
   worse than the cleartext hop it replaces - the message is encrypted to a
   stranger who then delivers it over the same unprotected last hop, having
   taken a plaintext copy on the way.

--------------------------------------------------------------------------------
 TLS AND HTTPS CLIENTS
--------------------------------------------------------------------------------

11. NEW - TsmTLSClient: the TLS half of a client, with no protocol opinion

   StreamSec.Mobile.TLSClient carries the connection, the handshake, the
   record layer, the timeouts and a byte- or line-oriented API. A protocol
   client descends from TsmCustomTLSClient and supplies only its commands -
   which is what the SMTP client of entry 3 and the HTTPS client of entry 12
   are.

       procedure Connect;  procedure StartTLS;  procedure Disconnect;
       procedure Send(const aData: TBytes); overload;
       procedure SendLine(const aLine: string);
       function  Receive(aTimeout: Cardinal = 0): TBytes;
       function  ReadLine(out aLine: string; aTimeout: Cardinal = 0): Boolean;

   Two tiers, as elsewhere in the client families: TsmTLSClient CREATES AND
   OWNS its TsmSimpleTLSInternalServer, so a client dropped on a form works
   with nothing else wired up, and TsmAdvancedTLSClient takes an external one
   so several clients can share a set of trust anchors and an identity.
   Assigning a foreign engine to the owning tier RAISES rather than being
   quietly ignored, because silently discarding it would surface much later as
   an unexplained certificate failure.

   ImplicitTLS (True by default) connects and handshakes in one step. Setting
   it False returns a cleartext connection for a descendant to upgrade with
   StartTLS, and StartTLS DISCARDS everything buffered before the handshake -
   data a server pipelined into the cleartext phase would otherwise be read
   back as though it had arrived inside the TLS session, which is the STARTTLS
   command-injection family.

   RequireTLS (True by default) gates the public surface: Send, SendLine,
   Receive and ReadLine RAISE while the connection is cleartext. A descendant
   implementing an in-band upgrade opens a window for the bare minimum its
   protocol needs to reach StartTLS - the greeting, the capability query, the
   upgrade command - and nothing else passes. Only an explicit RequireTLS :=
   False, a visible act by the consumer, permits application traffic over
   cleartext, and a descendant is free to be stricter: the HTTPS and SMTP
   clients both are.

   ALPNProtocols is offered in the order given and NegotiatedProtocol reports
   what was actually agreed - read the latter, never the offer list, because a
   server that sends no ALPN leaves the offer intact and its first entry is
   then something nobody consented to.


12. NEW - TsmHTTPSClient: HTTP/1.1 and HTTP/2 over the TLS client

   TsmHTTPSClient and TsmAdvancedHTTPSClient (StreamSec.Mobile.HTTPSClient)
   are the same two tiers over an HTTP client that speaks either wire, chosen
   by ALPN. Requests raise unless the connection is secure - unconditionally,
   whatever RequireTLS says, and https URLs only.

   Redirects are followed for safe methods by default (hrpSafeMethods); a POST
   gets its 3xx handed back, because a signed protocol binds the request URL
   and re-issuing it elsewhere is not a redirect but a different request.
   hrpNever hands every redirect back.

   StreamSec.Http.Client remains what it was - a plain class, no component,
   one exchange per connection - and is what the ACME client runs on.


13. FIXED - a client could stall waiting for a server that had already spoken

   TsmCustomTLSClient read the socket once per call and treated a read that
   yielded no application data as a timeout. That is wrong whenever the SERVER
   SPEAKS FIRST: the peer's first application record routinely arrives behind
   a batch of post-handshake records - TLS 1.3 session tickets above all - and
   the batch can occupy a socket read of its own. ReadLine then reported
   nothing while the greeting sat unread in the buffer, and the caller could
   only read that as a dead connection.

   Reads that decode to protocol records alone are now progress rather than an
   outcome: the wait continues within the caller's deadline until plaintext
   arrives, the peer closes, or the timeout expires.

   HTTPS never met this, which is why it survived the component's own tests -
   an HTTP client transmits first, so by the time it reads, application data
   is in front of the tickets. It is SMTP, IMAP and POP3 that are exposed, and
   it would have affected any protocol client written on this base.


--------------------------------------------------------------------------------
 TLS HANDSHAKE FIXES
--------------------------------------------------------------------------------

14. FIXED (BEHAVIOUR CHANGE) - a stapled OCSP response no longer breaks a
    TLS 1.3 handshake

   An outbound TLS 1.3 handshake to a server that STAPLES an OCSP response
   (e.g. DigiCert / PayPal) could fail with a fatal certificate_unknown alert
   even when the certificate chain was completely valid. The documented
   RevocationPolicy = rpSoftFail contract ("an inconclusive revocation result
   is treated as good, the handshake proceeds") was not honoured for such a
   peer - only rpIgnore let the connection complete. This reached every
   outbound TLS consumer (the mail relay, ACME, and the HTTPS/REST clients).

   Three independent PKIX-parsing defects were the root cause. With no Ocsp
   component wired (the default), revocation falls to the automatic CRL fetch,
   and DigiCert's CRLs tripped both:

     1. CRLReason was short. The tCRLReason ENUMERATED stopped at
        removeFromCRL(8), so its derived ASN.1 range was 0..8. A revoked-entry
        reason of privilegeWithdrawn(9) or aACompromise(10) (RFC 5280
        sec.5.3.1 - DigiCert uses 9) failed to decode with "Value is too large
        for transform". The two missing codes were appended to the enum
        (existing ordinals 0..8 unchanged).

     2. AddCRL assumed an IssuingDistributionPoint. A full-scope CRL that
        carries no IDP extension (e.g. DigiCert's root CRL) made AddCRL
        dereference a nil UniqueItems[IssuingDistributionPoint] and
        access-violate. AddCRL now reads the IDP through the same nil guard
        FindCRL already uses, treating an absent IDP as the full scope.

     3. AddCRL also assumed the CRL's issuer was already held. When no
        certificate in the store issued the CRL, FindCRLCACert leaves its var
        parameter nil and reports crcCANotTrusted - a status AddCRL ACCEPTS,
        going on to scan the CRLs it already holds for a superseding one. That
        scan passed the nil certificate to IsAllegedCRLIssuer, which
        dereferenced it. Adding a CRL whose CA is not (or not yet) in the store
        therefore access-violated, whenever at least one CRL was already held.
        IsAllegedCRLIssuer now answers False for a nil certificate, and the
        scan is skipped when there is no CA to compare against.

   Any of these faults raised inside the chain import, which ImportChainFromTLS
   swallowed as Status=[crcSyntax] - a fatal result that ignored the
   revocation policy. Two defence-in-depth changes ensure a revocation-lookup
   failure can never again turn a soft-fail handshake fatal:
   TsmX509TrustedCertificates.CheckRevocation now resolves the whole OCSP+CRL
   determination inside a try/except and maps ANY exception to the active
   policy (rpSoftFail/rpIgnore proceed, rpHardFail fails closed; a genuine
   crcRevoked stays fatal), and TstAbstractOcsp.ValidateStapledResponse
   degrades a malformed/unverifiable staple to csError instead of raising.

   No source change is needed on your part; a soft-fail engine that was
   working around this with rpIgnore can drop that and return to the
   rpSoftFail default.


15. FIXED (BEHAVIOUR CHANGE) - TLS 1.2 rejects an unsupported ECDHE curve and
    a malformed or small-order peer point

   The TLS 1.2 ECDHE key exchange did not fully validate what the peer sent
   before using it. Four classes of input got through:

     1. A point that does not lie on the negotiated curve, or is otherwise
        malformed, decoded to nil rather than raising. The nil then reached
        the scalar multiplication and access-violated; the handshake driver's
        exception handler reported that as a generic handshake failure.

     2. A compressed point ($02/$03) or the point at infinity ($00) was
        accepted where RFC 8422 sec.5.4.1 requires the uncompressed format
        ($04).

     3. A small-order X25519 or X448 point was not detected at all. Such a
        point drives the shared secret to all zero for every private scalar,
        which RFC 8422 sec.5.11 requires the receiver to abort on. Only a
        zero u-coordinate was caught, and only as a side effect of decoding.

     4. The named curve the server selects is a 16-bit identifier, but its two
        bytes were recombined wrongly and the result was held in eight bits.
        Identifiers of 256 or more folded onto smaller ones - the registered
        ffdhe6144 group, for one, landed on secp192r1 - so a ServerKeyExchange
        naming a curve the library does not implement could be taken for one it
        does. Every curve the library does implement is identified below 256
        and was unaffected.

   All four are now rejected cleanly. The three point checks apply on both ends
   of the connection and in both directions of the exchange: the server
   validates the client's point in the ClientKeyExchange, and the client
   validates the server's point in the ServerKeyExchange and again before
   deriving the premaster secret. Only the server names a curve, so that check
   is the client's. A rejected curve or point ends the handshake with an alert
   instead of an access violation, and no key material is derived from it. The
   TLS 1.3 layer enforces the same rules as part of the key_share validation
   of entry 16.

   Nothing changes for a well-formed peer. Code that relied on reading an
   access violation out of a failed ECDHE handshake sees an ordinary alert
   instead.


16. FIXED (BEHAVIOUR CHANGE) - TLS 1.3 validates every key_share it receives,
    per RFC 10024 and RFC 9846

   RFC 10024 (August 2026) places the ECDHE+ML-KEM hybrid key agreement on
   the Standards Track. It is the document behind the X25519MLKEM768,
   SecP256r1MLKEM768 and SecP384r1MLKEM1024 groups the library offers;
   codepoints, share layout and shared-secret order are exactly what the
   library sends, so nothing changes on the wire between conforming peers.
   What the RFC also does is state, as requirements, what an implementation
   must refuse in the key_share a PEER sends - and together with RFC 9846
   those requirements are enforced wherever the TLS 1.3 handshake takes
   key-exchange material from the peer: client and server, classical,
   pure-ML-KEM and hybrid groups alike.

   Four checks stand between a received key_share and any use of it:

     1. Exact length. A group has exactly one legal share length in each
        direction - an ML-KEM encapsulation key one way and a ciphertext the
        other, plus the fixed-size EC point for the hybrids - and a share of
        any other length is refused before anything is decoded from it.

     2. EC point form. A Weierstrass point (P-256/384/521, standalone or the
        EC half of a hybrid) must be in uncompressed form ($04) and must lie
        on the named curve; compressed points and the point at infinity are
        refused.

     3. All-zero shared secret. An X25519 or X448 exchange whose output is
        all zero bytes aborts the handshake (RFC 9846 sec.7.4.2): a
        small-order peer point forces that outcome whatever the private key
        is, leaving nothing secret about the "shared secret".

     4. ML-KEM encapsulation-key validity. A key is checked as FIPS 203
        sec.7.2 requires before the server encapsulates against it.

   The alert sent distinguishes the two failure families, as RFC 10024
   directs: input that fails validation draws illegal_parameter - no
   conforming peer produces it - while an ML-KEM operation that fails on
   input that VALIDATED draws internal_error.

   For diagnosing a failed handshake, StreamSec.Mobile.TlsConst adds nine
   reason codes to the qualified alert values AlertMsg decodes: on the
   server, client_key_share_format, client_ec_point_invalid,
   client_kem_key_invalid, client_zero_shared_secret and kem_encaps_failed;
   on the client, server_key_share_format, server_ec_point_invalid,
   server_zero_shared_secret and kem_decaps_failed. As with the existing
   codes, the qualifier is local diagnostic detail: the alert on the wire
   carries only the standard TLS code.

   Nothing changes for a well-formed peer.


--------------------------------------------------------------------------------
 THE ASYNC IMPLICIT-TLS SERVER
--------------------------------------------------------------------------------

17. NEW - TsmAsyncTLSServer

   An implicit-TLS server that serves many connections on a small pool of I/O
   threads, with the TLS engines sharded so a handshake on one connection does
   not serialise against another. It routes each accepted connection to an
   application-protocol plugin by ALPN, and it serves no protocol itself.

   AsyncTLSServer.txt documents it; the entries below cover what an
   application configures. The Windows backend is IOCP; POSIX backends
   (epoll, kqueue, poll) exist for Linux and macOS.


18. NEW - the HTTP server plugins: TsmHTTPSv1dot1 and TsmHTTPSv2

   Two plugins over one request-handling core (StreamSec.Http.Server), so a
   handler is written once and served on either wire. Assign one Router to
   both and register each with the server's Protocols; ALPN decides which
   answers. HTTP/2 brings its own HPACK codec (RFC 7541), frame layer and
   connection engine, and multiplexes streams over the single connection.

   Handlers come in three forms - an interface, a per-path event, or an
   exact-path file - plus a component-level OnRequest as the fallback.
   THttpLimits publishes every bound the wire imposes (header sizes, body
   sizes, concurrent and lifetime stream counts, continuation frames,
   unproductive-frame budget) with defaults that reproduce the previous
   hard-coded behaviour.

   HTTP.txt documents the core, both wires and every cap in one table.


19. NEW - byte ranges on the HTTP response

   Two additions to StreamSec.Http.Server. SendFileRange is on iHttpResponse,
   so it is reachable wherever SendFile is - a handler is given the interface,
   and calls it the same way:

       function iHttpResponse.SendFileRange(
                  const aPhysicalFile, aRangeHeader: string): Integer;

       function ParseByteRange(const aRangeHeader: string;
                                     aTotalSize: Int64;
                                 out aOffset, aLength: Int64): tRangeVerdict;

   In a handler that is one line, the header coming off the request:

       aResponse.SendFileRange(lPath,aRequest.Headers.Value('Range'));

   SendFileRange is SendFile with the request's Range header honoured, and it
   answers the status it set:

       no range        200, the whole file
       a range         206, Content-Range: bytes o-e/total
       unsatisfiable   416, an EMPTY body, Content-Range: bytes */total

   Accept-Ranges: bytes accompanies all three, because it describes the
   resource rather than the outcome. A file that is not there is 404, as with
   SendFile, rather than an exception into the session.

   IT READS ONLY THE OCTETS THE RANGE ASKS FOR, which is the reason to prefer
   it. SendFile reads a whole file into the response body, so serving a 200 MB
   download allocates 200 MB before the transport has copied it anywhere;
   SendFileRange reads the requested window, so a client resuming a download in
   chunks costs the size of a chunk.

   THREE RANGE FORMS, and the middle one is where hand-written parsers go
   wrong:

       bytes=0-499     the first 500 octets
       bytes=500-      from 500 to the end
       bytes=-500      the LAST 500 octets - a suffix LENGTH, not a start

   Overshooting is not an error: bytes=0-99999 against a ten-octet file is
   those ten octets. 416 is reserved for a well-formed range that begins past
   the end, which is the only case RFC 9110 permits it for.

   A MULTI-RANGE REQUEST GETS THE WHOLE REPRESENTATION, deliberately. A server
   may decline to honour a Range header, and 200 with everything is always a
   correct answer; replying 206 with only the FIRST of several requested ranges
   is not, because the client asked for all of them and nothing in the response
   would tell it otherwise.

   The 416 body is empty for the same kind of reason: a 416 carrying the whole
   file contradicts its own status line, and it is what turns a client's retry
   into repeated full downloads.

   WHAT THIS IS NOT is whole-file streaming. A response body is still assembled
   in memory and written to the transport in one go, and SendFile still reads
   whatever you give it. That shape is deliberate, not an omission: the
   first send on a connection goes straight out, a second while it is in flight
   is queued, and the send-queue ceiling closes the connection when it is
   exceeded - so writing a large body in chunks would drop the connection
   rather than pace it. Ranges are what bound the cost today.


20. NEW - TsmAsyncTLSServer.PlainTextRedirectPort

   A server that answers only TLS still has to say something to the browser
   that typed the bare host name. Set PlainTextRedirectPort (0, off, by
   default) and the component binds that port too - conventionally 80 - purely
   to answer ONE request per connection with a redirect and close.

   It is not an HTTP server and will not become one: nothing is routed, no
   body is read, no keep-alive is honoured. A request over 8 KiB or slower
   than five seconds is dropped without a reply, and at most 64 exchanges run
   at once. Redirects are handled on short-lived threads of their own and
   never touch an I/O thread, so a slow peer on the cleartext port cannot
   occupy capacity belonging to TLS connections. The listener binds after the
   TLS port and is torn down before it.

   The exchange goes to whichever application-protocol plugin implements
   iAppPlainTextRedirect - one method, because there is one exchange. The
   HTTP/1.1 plugin implements it and surfaces OnPlainTextRedirect, where
   aLocation arrives holding 'https://' + Host + target and aStatusCode 301,
   so a handler that does nothing still redirects correctly.

   IT TAKES TWO SETTINGS, NOT ONE. A cleartext connection negotiated nothing,
   so it is resolved through FallbackPolicy exactly like a TLS client that
   offered no ALPN - and that defaults to fbpRefuse. Setting only the port
   leaves every cleartext connection refused and the port looking dead. Pair
   it with fbpUseFallback plus IsFallback on the answering plugin, or with
   fbpFirstRegistered.

   AND ANSWER ONLY FOR NAMES YOU SERVE. The default answer echoes the peer's
   own Host header into a Location header, which is an open redirect in every
   respect except that it cannot leave the https scheme - a safe default and a
   poor policy. Setting aLocation to '' refuses with no response at all, which
   is the right answer for a Host the deployment does not serve.

   AsyncTLSServer.txt section 4 and HTTP.txt section 20.


21. NEW - TsmAsyncTLSServer.OnTLSIncomingAlert / OnTLSOutgoingAlert

   The TLS alerts of every engine shard, on one handler:

       property OnTLSIncomingAlert: TTLSAlertEvent;
       property OnTLSOutgoingAlert: TTLSAlertEvent;

   Same signature as the events of the same name on a single
   TsmSimpleTLSInternalServer, and the Sender is the ENGINE that raised the
   alert rather than the component - so a handler can tell the shards apart,
   and one written for a single server works here unmodified. The component
   routes every shard to itself, so one handler answers for all of them; an
   engine whose alert event was assigned from OnConfigureEngine keeps it.

   ASSIGN AT LEAST ONE OF THEM IN A SERVER, and read this even if you do not
   want the reporting. An engine with no alert handler RAISES - EIncomingTLSAlert
   or EOutgoingTLSAlert - for every alert except close_notify. That is the right
   default for a client, where an alert means the one connection you cared about
   has failed. On a server it is not: an ordinary handshake_failure or
   protocol_version from a probing client is a routine event, and turning it into
   an exception on a reactor thread is not what you want. Assigning either
   property routes every shard through this component, which is silent when
   nothing is assigned.

   The two channels a public server usually wants are a fatal log and a warning
   log, split on the Fatal parameter; that is what the alert level means and it
   is the only thing you need to read to make the split.

   AsyncTLSServer.txt sections 4 and 8.


22. NEW - provisioning the whole engine bank, stated once

   Three operations on TsmAsyncTLSServer itself, each covering every shard:

       procedure ImportFromPFX(aFileName: TFileName; aPassword: iSecretKey);
       procedure LoadRootCertsFromFile(aFileName: TFileName);
       procedure ValidatePublicKeyPairs;

   CALL THEM BEFORE Active := True, from wherever the port and the routes are
   set. The engine bank does not exist yet, so they are RECORDED there and
   applied - in call order - the moment it has been built, which is the first
   moment there is anywhere to put the material:

       Server.LoadRootCertsFromFile(cAnchors);
       Server.ImportFromPFX(cIdentity,tDualSecretKey.CreateForPFX(cPassword));
       Server.Active := True;

   THEY RAISE IF CALLED ONCE THE BANK EXISTS, rather than quietly doing the
   work. By then every shard has had TLSSetupServer run over the store they
   would change, so the material would land in the store while the serving
   cache knew nothing about it - a call that appears to succeed and changes
   nothing a handshake can see.

   A RUNNING server is updated with AddCertificate or AddCRL, which mutate every
   shard's trust stores under the engine lock and are read live by handshakes,
   and with ReplaceTLSServerCertificate, which additionally rebuilds each
   shard's SERVING cache. Note the difference: the served leaf chain is built
   once per shard at TLSSetupServer time and is not re-derived afterwards, so
   adding an intermediate with AddCertificate changes what the shard TRUSTS
   without changing what it SENDS. Replacing the leaf is what does both.

   DO NOT CALL THEM FROM OnConfigureEngine. That handler runs once per shard,
   and each of these is itself a fan-out over the whole bank, so a call there
   repeats the entire fan-out once per shard. It is also too late, which is
   what the exception will tell you.

   ImportFromPFX PARSES AND DECRYPTS THE FILE ONCE for the whole bank, which is
   the reason it is worth having. A PKCS#12 file is opened with a
   password-derived key, and the iteration count is the writer's choice: the
   compatibility encoding this library writes by default uses 2000, while PBES2
   - what ExportToPFX produces unless told otherwise - uses 131072. One import
   costs roughly 50 ms in the first case and 750 ms in the second, so a bank of
   eight shards that each read the file spends about 0.4 s or about 6 s before
   it can bind. One parse puts the second case back under a second.

   ANCHORS BEFORE IDENTITY, in that order. Importing a leaf pairs it with its
   issuer, and the issuer is looked for in the stores as they stand at that
   moment, so anchors loaded afterwards are too late and the chain is left
   incomplete. Where the automatic AIA caIssuers chase is enabled, the same
   miss turns into a network fetch on the thread that set Active.

   NONE OF THEM REPORTS A COUNT. A per-shard number would have to be either one
   shard's answer or a sum over the bank, and neither says anything usable: the
   shards are required to hold the same material, so N times one number is
   noise and one shard's number is a fact about that shard. What matters is
   whether it worked, and that is what the exception is for - including the
   case where the shards turn out to disagree, which raises rather than
   reporting a partial success.

   SETTINGS DO NOT MOVE. They stay on the engine the handler is given, one
   assignment per shard. What belongs on the component is what costs an
   unbounded amount of time and what has an ordering requirement - which is
   these three and not a property assignment.

   AsyncTLSServer.txt sections 6 and 9.


--------------------------------------------------------------------------------
 ALPN
--------------------------------------------------------------------------------

23. NEW - ALPN preference is settable at design time

   TsmHTTPSv1dot1, TsmHTTPSv2 and TsnipTLSServer publish AlpnPriority (default
   0). HIGHER IS PREFERRED, and the SERVER's order decides which protocol a
   client that offers several ends up speaking (RFC 7301 section 3.2).

   Registering from code already states that order - adjacent AddProtocol calls
   read top to bottom - but a component registers itself from Loaded, which is
   DFM declaration order: invisible, changed by accident, and wrong in a way
   nothing reports, since every ordering is a valid negotiation. Set this and
   load order stops mattering. Typical use is h2 = 10 against http/1.1 = 0.

   The registry is kept in descending priority order, so fbpFirstRegistered
   serves the HIGHEST-PRIORITY registration, not the earliest one. With every
   component left at 0, equal priorities keep insertion order and the two
   readings coincide. Engine-seeded tokens such as 'acme-tls/1' are merged
   ahead of all of them and cannot be demoted.


24. NEW - the TLS content layer reports what was actually agreed

   TCustomTLS_ContentLayer gains:

       property SelectedProtocol: OctetString;          { already present }
       property ServedProtocol: OctetString;
       property AlpnFallbackPolicy: TAlpnFallbackPolicy;

   SelectedProtocol is the protocol ALPN genuinely agreed on, or empty.
   ServedProtocol applies AlpnFallbackPolicy when nothing was agreed, and
   DEFAULTS to afpFirstOffered - serve the first protocol we offered - which is
   what reading the application-protocol list's first entry has always produced.
   Existing code is therefore unaffected. Set afpStrict when the caller wants to
   own the no-ALPN decision itself.

   Prefer ServedProtocol over indexing the application-protocol list: the two
   agree whenever a protocol was agreed, and differ in exactly the case that
   matters.


25. The protocol registry: instances, teardown, and thread safety

   iAppProtocolRegistry.RemoveProtocol takes the iAppProtocol to remove and
   returns whether it was registered:

       function RemoveProtocol(const aProtocol: iAppProtocol): Boolean;

   Removal is deliberately not by ALPN token. Nothing forbids two registrations
   sharing a token, and a token lookup takes the FIRST match - a plugin asking
   to leave could evict a different plugin's registration and leave its own
   behind, to dangle once it was freed. Call it with the protocol instance:

       srv.Protocols.RemoveProtocol(myPlugin.AppProtocol);

   Registering an instance that is already registered RE-SEATS it at its new
   priority, so binding a component through the Server property AND calling
   AddProtocol for it is harmless. Unregistering also clears the instance from
   FallbackProtocol.

   Freeing a plugin, clearing its Server property, or removing the server from
   its owner all leave the registry clean:

     * a server that is being DESTROYED only has the reference dropped - its
       registry is already gone;
     * a server that is still ALIVE when the plugin is detached from it
       (RemoveComponent, reparenting) is unregistered as well;
     * TsnipTLSServer unregisters BEFORE draining its serving threads, so a
       handshake is never routed to a plugin that is shutting down.

   A registration the component cannot reach - one made by calling AddProtocol
   with a second server, or an adapter the application stored itself - still
   outlives the component, because a plugin tracks one Server. Such a
   registration is inert rather than dangerous: the adapter is detached when
   the component is freed, so it keeps advertising its token but declines to
   create sessions, and the connection is closed instead of reaching freed
   memory. Unregister such registrations yourself before freeing the plugin.

   The registry is read from I/O threads on every handshake and written from
   the application thread whenever a plugin binds or unbinds. Every entry point
   is serialised, and AdvertisedProtocols returns a single consistent snapshot.
   Count and Protocols[] are safe individually but are not atomic as a pair;
   Protocols[] answers nil for an out-of-range index rather than raising, so a
   walk that races a removal thins out instead of failing. Note for implementors
   of iAppProtocol: Token is read while the registry lock is held, so it must
   not call back into the registry.

   Setting FallbackPolicy on TsmAsyncTLSServer writes through to the registry,
   so the two faces of it cannot disagree and reading it back tells the truth.


26. Two properties raise rather than silently doing nothing

   TsmHTTPSv1dot1.AlpnPriority, TsmHTTPSv2.AlpnPriority and
   TsnipTLSServer.AlpnPriority raise ETLSAsyncServer if assigned while the
   server is Active. The preference list is read per connection during
   handshakes, so the assignment could not take effect; storing it would
   leave the property reporting one order while the wire showed another.
   Deactivate, set it, reactivate.

   TsnipTLSServer.AlpnToken raises ETLSAsyncServer once the plugin has been
   associated with a server (or once AppProtocol has been called). The protocol
   adapter reads the token live, so from that moment it is a live registry key
   and renaming it would re-route traffic silently. Set it before assigning
   Server.

   Both remain freely settable at design time and while a form is streaming, and
   re-assigning the value a property already holds is always allowed.


27. BEHAVIOUR CHANGE - a TLS 1.3 server no longer reports an ALPN protocol
    to a client that offered none

   The TLS layer's application-protocol list means the OFFER before ALPN
   settles and the AGREEMENT after. The TLS 1.3 server left the offered list
   in place when the peer sent no ALPN, so afterwards nothing distinguished
   the two and such a client read back as having chosen whatever the server
   advertises FIRST; TLS 1.2 cleared it. Both paths now leave the same state:
   an empty list means "nothing negotiated" and a single-entry list means
   "this was agreed", whichever version was used.

   The consequence that matters: certificate selection is driven by that
   value, so a client that negotiated nothing was answered with the
   certificate chosen for the server's first advertised protocol. With a
   tls-alpn-01 challenge installed, that is the ACME CHALLENGE certificate
   rather than the real one.

   ON THE NEW ASYNC SERVER, FallbackPolicy owns the no-ALPN decision: the
   registry resolves a plugin only for a protocol that was genuinely agreed,
   and a client that offers none falls to FallbackPolicy. The DEFAULT -
   fbpRefuse - closes such connections after the handshake.

   WHAT TO DO. If your server should serve clients that send no ALPN - which
   is the ordinary case for a web server, since a plain HTTPS client need not
   offer one - set FallbackPolicy explicitly:

       srv.FallbackPolicy := fbpFirstRegistered;   { serve the top plugin }
     or
       srv.Protocols.FallbackProtocol := myPlugin.AppProtocol;
       srv.FallbackPolicy := fbpUseFallback;

   A client that negotiates a protocol you registered is served regardless of
   FallbackPolicy.


--------------------------------------------------------------------------------
 FILESYSTEM CONFINEMENT, AND THE SFTP SERVER ON IT
--------------------------------------------------------------------------------

28. NEW - stFileJail, one filesystem confinement primitive

   Any component that turns a name from the network into a file needs the same
   two questions answered together: may this resolve BENEATH the root, and may a
   file of this KIND be touched at all. They are not separable, because on
   Windows they share failure modes - 'logo.png::$DATA' and 'secrets.ini.' both
   defeat an extension allow-list through the PATH rules rather than the
   extension rules.

   Four units, in every runtime package from StrSecIV170 (XE3) to StrSecIV370:

     stFileJail           iFileJail, tFileJailPolicy, the verdict enum, and the
                          platform-neutral half of the algorithm.
     stFileJail.Windows   Win32 verification backend.
     stFileJail.Posix     POSIX backend (Linux, macOS, iOS, Android).
     stMimeTypes          Extension to media-type registry.

   Nothing here is a component and there is no design-time registration.

   THE SHAPE THAT MATTERS. On success the jail returns the OPEN OBJECT, not a
   path. A confinement primitive whose output is a string cannot be free of
   check-then-open races on any platform: the name is correct when it is
   produced and can stop being correct before it is used. OpenVerified returns a
   descriptor and OpenStream wraps that same descriptor rather than re-opening
   by name. Resolve and ResolveUrl remain, but they are lexical only and emit
   the canonical VIRTUAL path - they deliberately cannot hand back anything
   openable, because the convenient method must not also be the unsafe one.

   The root is opened and PINNED at mint time through the same mechanism every
   later object goes through, and the path the operating system reports for it
   is what containment is measured against. A lexical canonicaliser resolves
   "." and ".." but symbolic links on no platform, so a document root that is
   itself a link - /tmp and /var on macOS, and many administrator-convenience
   roots - would otherwise make an honest implementation refuse everything.

   tJailShareMode on the policy states what OTHER processes may do to an object
   while the jail holds it open. jsmShareAll (the default) permits readers,
   writers and deleters; jsmDenyWrite permits other readers only, which combined
   with a write open gives single-writer / multi-reader; jsmDenyAll permits
   nobody. WINDOWS SHARE MODES ARE MANDATORY - the kernel refuses a conflicting
   open. POSIX has no equivalent: flock and fcntl locks are ADVISORY, so a
   process that never asks is never stopped. The POSIX backend therefore IGNORES
   this setting rather than honouring it with a lock that guarantees nothing, on
   the grounds that a guarantee which is not one is worse than a documented gap.
   Code that depends on a deny mode depends on Windows behaviour. The jail's own
   verification opens always share fully regardless: the pinned root is held for
   the jail's entire lifetime, and a brief interrogating open must never be able
   to make an unrelated operation fail.

   stMimeTypes has ONE table read for two purposes that must not be confused.
   HasExtension is a PERMIT predicate: true only for an extension explicitly
   present, never inferring and never falling back. MediaTypeOf is a LABEL and
   takes its fallback from the caller. A label lookup wants a fallback - an
   unrecognised extension is still a file. A permit lookup must never have one,
   because a table that answers application/octet-stream for .pfx has just
   permitted a private key. There is deliberately no single method that answers
   both. The seeded table is small on purpose; a deployment's real table is
   configuration, in the syntax an ini file already uses:

     Map.AddMapping('jpeg,jpg,jpe','image/jpeg');

   See FileJail.txt, in particular section 10, which states what the primitive
   does NOT close: hard links, bind mounts within one filesystem, a lying
   network server, and case-insensitive volumes reached from a case-sensitive
   build.


29. BEHAVIOUR CHANGE - SFTP server: a trailing dot or space is now refused on
    Windows

   TstSFTPServerSubSystem now confines paths through stFileJail rather than
   through its own copy of the rules. The rule set asked for is faithful to what
   the private implementation refused, with ONE deliberate difference: a path
   segment ending in a dot or a space is refused.

   WHY. Win32 strips trailing dots and spaces at open time. A name validated
   with one and opened without it is a name nobody approved, and it is the
   mechanism by which an extension veto can be bypassed simply by appending a
   dot. A client that depended on the old behaviour was depending on a defect.

   WHAT TO DO. Nothing, unless you knowingly serve files whose names end in a
   dot or a space - in which case those names become unreachable over SFTP and
   should be renamed.

   Device names and 8.3-style short names are NOT refused, matching the previous
   behaviour, because an existing client may legitimately hold such a name.

   Two smaller consequences of the same change:

     * A root directory that cannot be opened is now detected when the
       connection is configured, and every path mapping then refuses. Previously
       the subsystem accepted the root and failed per-operation instead. The
       outcome is the same; the cause is now visible at the right moment.

     * On Windows the physical paths the subsystem composes are in the
       extended-length form the operating system itself reports. This is what
       disables Win32 name normalisation and keeps the validated name and the
       opened name identical. It is visible only if your application logs or
       compares those strings.

   Two defects in the private implementation disappear with it: it hard-coded
   the Windows path separator, so it could not have served a POSIX build, and it
   compared case-insensitively on every platform, so on POSIX it would have
   accepted "FOO" for a root named "foo".

   SFTP interop was re-run against the change: the self-test, the third-party
   client matrix (OpenSSH sftp, PuTTY psftp, curl/libssh2), and our client
   against a real OpenSSH sftp-server all pass.

   FILE DATA IS NO LONGER SUBJECT TO A CHECK-THEN-OPEN RACE. A decision about a
   NAME expires the moment it is made: between the check and the open, anything
   able to write the tree can substitute a link for a directory, so the name
   that was approved and the object that is opened become two different things.
   SSH_FXP_OPEN of an existing file now takes its stream from the jail, so the
   descriptor that was verified is the descriptor every subsequent read and
   write uses. The subsystem already held one stream for the life of an SFTP
   handle; what changed is where that stream is opened.

   Still name-based, and a smaller exposure: creation - which cannot be verified
   by opening, there being nothing there yet - and the one-shot requests (stat,
   remove, rename, mkdir, rmdir, directory enumeration). Losing a race on those
   leaks metadata or misdirects a delete; it does not disclose file contents.
   Closing them needs the POSIX *at family and has no Windows equivalent.

   The subsystem asks the jail for jsmDenyWrite, which reproduces the
   single-writer / multi-reader behaviour it had before: a read open denied
   writers, so a read and a write of one file could never overlap.


30. BEHAVIOUR CHANGE - the SSH/SFTP wire types are now UInt32 and Int32, not
    LongWord and LongInt

   LongWord and LongInt are 32-bit on every Windows target, but 64-BIT on
   64-bit POSIX, where Delphi widens them to match C's `long`. Every SSH and
   SFTP wire value is a uint32, so the 18 wire-facing units now say UInt32 and
   Int32 explicitly - 474 and 11 sites respectively.

   ON WINDOWS THIS CHANGES NOTHING. The two types are the same width there, so
   the rename is semantically a no-op and all fourteen runtime packages build
   green with identical behaviour. It only changes meaning where the previous
   code was already wrong.

   It also removes eight `{$IFDEF POSIX} LongWord = UInt32` blocks that had been
   added to individual SSH units. Those pinned the type for whichever sections
   happened to `use` the declaring unit and silently left the rest on the
   platform-dependent one - so a single file could hold two widths under one
   spelling, which is how this surfaced: an interface section and an
   implementation section of the same unit disagreed about what LongWord meant,
   and the compiler reported "declaration differs from previous declaration"
   between two byte-identical lines.

   WHAT TO DO. Nothing, unless your own code declares interfaces or callbacks
   that the library implements, using LongWord for a wire value. On Windows it
   will continue to match either way; if you build for a 64-bit POSIX target,
   change those to UInt32 as well.

   THE REST OF THE LIBRARY IS DELIBERATELY NOT CONVERTED, and the reasons
   differ - this is not a job left half done. An audit of every other unit
   holding these types put them in three groups:

     NOT REACHABLE FROM A POSIX BUILD. The great majority: the superseded
     stSSH*/stSFTP*/stMP* generations, the third-party transport bridges
     (Indy, Synapse, NexusDB, DXSock, RemObjects, MIDAS) and units that use
     the Windows API unconditionally. None is in a supported runtime package,
     or none can be compiled for a POSIX target, so the widening cannot bite.

     WOULD BE BROKEN BY THE CONVERSION. A smaller set uses these types as
     MACHINE WORDS - pointer arithmetic, object references held as tokens, a
     TVarData overlay whose size must track the platform, and the compat
     aliases that DEFINE UInt32 and NativeInt for older compilers. There
     UInt32 is a truncation, not a fix; the correct type is NativeUInt.

     CORRECT AS THEY STAND. Every TStream descendant. System.Classes declares
     Read, Write, Seek and SetSize with Longint, and that widens on POSIX64
     like everything else - so an override must ALSO say Longint or it stops
     overriding. Int32 there compiles clean on Windows and fails on Linux64
     with "method not found in base class".

   A WARNING FOR ANYONE TEMPTED TO SWEEP THE REST. Pascal is case-insensitive
   and a search for "LongWord" is not: a further 183 sites are spelled Longint
   or Longword and do not appear in a naive inventory at all. They are
   overwhelmingly the TStream overrides above - so a case-insensitive sweep
   would find precisely the sites that must NOT be changed.

   AND A WARNING ABOUT VERIFYING IT. A Windows build cannot detect any of
   this. LongWord IS UInt32 on Win32 and Win64, so a half-converted interface
   or override compiles cleanly there and fails only on a 64-bit POSIX target.
   The green Windows package matrix is not evidence about this class of change;
   a Linux64 compile is.


31. The SFTP server now builds and runs on Linux

   Previously Windows-only, and not by intent - it had simply never been pointed
   at a POSIX compiler. Three things were needed: the type change above, a
   platform-split cipher registration (stRijndaelBase has a bare `asm`
   procedure with no pure-Pascal path, so the legacy cipher units cannot link on
   Linux64 at all - a POSIX build uses stAes + stAESNI), and POSIX
   implementations of the two functions that read and write file attributes.

   The POSIX attribute path is the more direct of the two: SFTP permission bits
   ARE POSIX mode bits, so st_mode goes on the wire unchanged, where the Windows
   path has to synthesise a plausible mode from the read-only attribute.

   The SFTP self-test builds for Linux64 and passes 34/34 there against 31/31 on
   Win32, the three extra being POSIX-only symbolic-link cases. macOS and iOS
   compile but have not been run.


--------------------------------------------------------------------------------
 SNIP, ACME, AND FIXES
--------------------------------------------------------------------------------

32. NEW - snip carried over TLS

   TsnipTLSClient (StreamSec.Snip.TLSClient) and TsnipTLSServer
   (StreamSec.Snip.TLSServer) are a TLS-carried sibling of the SSH-based snip
   pair. The client creates and owns its TLS configuration and connects,
   handshakes, opens the snip channel and logs the Snif user in with the
   Tunnel Bound KAPA - Start is the one-call form and fails closed (the
   connection is dropped) on a rejected login; StartTransport plus LoginKAPA
   split the same bring-up for applications that supply a client-side pepper
   or keep the negotiated session key. The server is not a complete server
   but an application-protocol plugin (ALPN token 'snip') registered with
   TsmAsyncTLSServer.Protocols, so the TLS identity and policy stay on that
   component.

   Channel binding is RFC 9266 TLS-Exporter, from the new
   TCustomTLS_ContentLayer.ExportKeyingMaterial (RFC 8446 section 7.5), and it
   is TLS 1.3 ONLY BY DESIGN. Nothing is captured on TLS 1.2, so the export is
   empty there and an augmented-PAKE login over 1.2 fails closed rather than
   proceeding unbound.

   The Snif class server that dispatches remoted calls belongs to the plugin:
   created with it, freed with it, never nil, and reached through a read-only
   property.

       property ClassServer: TsnifClassServer read fClassServer;

   What the instance carries is per-server state - the user list, the roles, the
   authentication events. The REMOTED CLASSES are a different thing: they go
   into a process-wide registry through a CLASS procedure, so that call names
   the type rather than the instance:

       TsnifClassServer.RegisterServerClass(TMyRemotedThing);  // once
       snip := TsnipTLSServer.Create(Self);
       snip.ClassServer.OnRequestOTP := MyOtpHandler;          // per server

   IT IS READ-ONLY BECAUSE THERE IS NOTHING TO ASSIGN. TsnifClassServer is not
   a registered component - it cannot be dropped on a form or a data module, so
   a settable property would advertise a design-time association the Object
   Inspector is unable to make, and every host would write the same two lines
   of construction and ownership by hand.

   Do not free it; its lifetime is the plugin's.

   OTP account recovery is a single call on the client: RecoverAccount brings
   the transport up, has the server deliver a one-time code out of band (the
   server application's ClassServer.OnRequestOTP event sends the email/SMS),
   collects the code and a replacement password through the published
   OnOTPCode / OnNewPassword events, uploads the new verifier and drops the
   connection - the OTP session may do nothing else. On True, SnifPassword
   already holds the new password, so Start is the next call. While an event
   handler waits on the user, a background thread sends one empty TLS record
   per RecoveryHeartbeatInterval (default 15 s, 0 disables): invisible to the
   application protocol on both ends, but authenticated traffic that re-arms
   the server's IdleTimeout and keeps NAT state alive through a wait that may
   last minutes. (Deliberately not a KeyUpdate: KeyUpdates with no application
   data between them are capped as a flood per RFC 9846.) Recovery is TLS 1.3
   only, like the KAPA login itself.

   Fixed while proving that flow end to end over real sockets: an
   uninitialized out-parameter in TsnifUser.HasRole made the implicit
   change-password grant store stack garbage as a role-info object, which a
   later role check dereferenced - an access violation that surfaced (or not)
   at the mercy of the transport's call stack. The remote-call layer in
   StreamSec.Snic.ClassClient and the class server now also raise messages
   that say what actually failed ("no response to the call - the connection
   closed") instead of the placeholder text they carried.


33. NEW - TsmAcmeRenewalManager.ManageClientCertificate: renewal without
    ACME code

   A TsmAcmeClient already carries everything an issuance needs - Domains,
   CertificateKey, and PfxFileName to persist the result. Set this property
   and Start registers that certificate and keeps it renewed, issuing the
   first one itself if the machine has none:

       FRenew.Acme := FAcme;
       FRenew.ManageClientCertificate := True;
       FRenew.Start;

   Both are published, so on a data module that is two entries in the Object
   Inspector and no code at all. ObtainCertificate need never be called by the
   application: the first issuance runs on the manager's own thread, which is
   where a call that waits minutes on a certificate authority belongs, rather
   than on a UI thread or the one a service is started from.

   It is safe on a machine that already holds a certificate. The manager reads
   the leaf back out of the client's PfxFileName and schedules from that
   certificate's real validity, rather than treating it as not-yet-issued -
   which is due immediately and would obtain a fresh certificate on every
   restart. Let's Encrypt's duplicate-certificate limit allows five of those a
   week.

   It also does nothing when the application has registered a certificate of
   its own with Manage, so it cannot duplicate one registered by hand.

   Accompanying it: a Manage overload taking no arguments (the same
   registration, at a moment of your choosing), TryBeginRenewal to bracket a
   manual obtain with the same serialisation a scheduled renewal takes, and
   stAcmeStorage.LoadLeafFromPFX to read an end-entity certificate back out of
   a PFX - the inverse of InstallIssuedCertificate. ACME.txt section 1,
   STEP 6.


34. NEW - ACME managed mode against the sharded server

   TsmAcmeClient.AsyncTLSServer points the client at a TsmAsyncTLSServer, as
   TLSServer does for a single TsmSimpleTLSInternalServer; they are mutually
   exclusive and assigning both raises. The tls-alpn-01 challenge is answered
   on every shard and the issued leaf installed into every shard, so nothing
   else in the ACME flow reads differently.

   AlpnTarget reports whichever server a client provisions, as the interface
   both server classes implement, for callers that want to bracket an obtain
   without caring which kind it is.

   ObtainCertificate gains an overload naming the certificate being replaced,
   which travels to the CA as the RFC 9773 "replaces" field so an ARI-aware
   authority can correlate a renewal with what it supersedes.


35. FIXED - stAcmeStorage did not compile for POSIX targets

   The atomic-replace helper's POSIX branch called rename(), but Posix.Stdio
   exports that entry point as __rename and declares no plain rename at all,
   so the call bound to the legacy Pascal Rename intrinsic - the one that
   renames an open file variable - and failed with two E2008s naming no unit.
   Windows targets were unaffected, the branch being inside {$ELSE}.

   It calls __rename with a NUL-terminated UTF-8 path. Linux, macOS, iOS and
   Android targets that use the ACME persistence layer compile.


36. FIXED - ImportFromPFX could not read a BER-encoded PKCS#12 file

   ImportFromPFX, on TsmSimpleTLSInternalServer and every component that
   inherits it, reads the file as DER and falls back to a BER conversion when
   the DER reader rejects it. The fallback ran and was then discarded: the file
   was read as DER a second time unconditionally, which threw away the
   converted structure and raised eASN1EncodingError out of the import. A
   BER-encoded PFX could therefore not be imported at all, and PKCS#12 files
   are commonly BER. DER files were unaffected.

   The same path also verified the file's password-derived MAC twice - once on
   its own account and once inside the copy that follows - the first result
   being discarded. Both redundant reads are gone, so a BER PFX imports and a
   DER one costs one MAC verification rather than two.


37. FIXED - unaligned word access in the pure-Pascal cipher primitives

   The pure-Pascal XOR and block helpers stride their operands as 64- or
   32-bit words at addresses the CALLER chose. That is routine: CTR, CFB, OFB,
   CBC, GCM, CCM and EAX all XOR at an arbitrary offset into a larger buffer,
   and CBC encrypts in place inside the caller's message. So the address is
   very often not a multiple of the operand size.

   x86 and x64 tolerate that, which is why it went unnoticed. Strict-alignment
   CPUs do not: a 64-bit access to an odd address faults. For Delphi that means
   the 32-bit ARM targets, where the paired LDRD/STRD instructions require
   alignment even where a plain load does not - so a 32-bit Android or iOS
   build could fault inside any of those modes, depending only on where in a
   buffer the caller happened to start.

   Every affected helper now takes the word-strided path only when its operands
   are aligned, and walks bytes otherwise: XORBytes, XORBlock64/128/256 and
   AddBlock64/128 in stSecUtils, and XORBytes, XORBytesCopy, XORBytesBackup,
   XORBytesABCDcr64, XORBlock and IncBlock in stBlockCipher. The AES block
   routines stage through an aligned local when the caller's block is not
   aligned. The AEAD modes needed no changes of their own - they are composed
   entirely from these helpers, so fixing the helpers fixes the modes.

   NOTHING CHANGES ON x86 OR x64. The guards are inside
   {$IFDEF STRICT_ALIGNMENT}, which ver.inc defines only for CPUARM32 under
   Delphi (and for MIPS, SPARC, ARM, RISC-V and 68k under FPC). Where the CPU
   tolerates unaligned access the check AND the byte-wise fallback compile out
   entirely, leaving the original straight-line word path with no branch -
   measurable as a slightly SMALLER Win64 binary than before the change. Define
   NO_STRICT_ALIGNMENT to force them off.

   The guards branch on operand ADDRESSES and public lengths only, never on
   anything secret, so no data-dependent timing is introduced on the targets
   that do compile them in.

   Found by porting the library to a big-endian, strict-alignment target rather
   than by a report from the field: aligned test buffers hide this entire class
   of bug, which is why the mode tests now cover an unaligned start as well.


38. NEW - stAESCT: constant-time software AES, and AES routed through the
    class registry

   The software AES in stAES is table-driven: its lookup tables are indexed
   with bytes derived from the key and the data, so on any CPU with a shared
   data cache the lookup addresses leak through cache timing. stAESNI avoids
   the tables with the AES-NI instructions, but only where those exist: the
   Win64 compile, on CPUs that have them. Win32, x64 CPUs without AES-NI and
   every POSIX target ran the tables.

   stAESCT closes that gap: the same twelve cipher classes (ECB, CBC, CFB,
   OFB, CTR, key wrap, CCM, EAX, GCM, SSH, SSH-CTR, SSH-GCM), implemented as
   a bitsliced boolean circuit - the Boyar-Peralta S-box, following
   BearSSL's aes_ct - in portable Pascal. No branch and no memory address
   anywhere in encrypt, decrypt or the key schedule depends on a key or data
   byte. Byte-wise little-endian block access makes it endian- and
   alignment-neutral, so the same code serves every target unconditionally.

   Registration is automatic and keyed on the same CPU probe stAESNI uses,
   so the two units partition the machines between them: AES-NI hardware
   where it exists, constant-time software everywhere else. The table
   implementation remains in stAES for code that names its classes directly,
   but no registered AES mode resolves to it any more.

   Two changes ride along:

   stAESNI gains the SSH-CTR and SSH-GCM cipher classes it predated, so an
   SSH endpoint on an AES-NI machine no longer falls back to the tables for
   aes128/192/256-ctr and aes256-gcm@openssh.com.

   stAESNI also now compiles under Free Pascal on System V x86-64 targets
   (Linux, macOS, BSD): a second assembler arm with the SysV register
   convention, taking no alignment assumption on the key schedule. The same
   CPU probe partitions machines there too, so a POSIX build gets hardware
   AES where the CPU has it and the constant-time implementation where it
   does not. Verified with FPC 3.2.2 on Linux x86-64 (the same ~1.5 GB/s as
   the Win64 build) and on big-endian MIPS and PowerPC - no AES-NI there, so
   registration falls to stAESCT, whose self-test passing on those targets
   is also the first big-endian run of the constant-time implementation.

   And stAESNI now has a Win32 arm: the AES-NI instructions work identically
   in 32-bit mode, only the register convention differs, so a 32-bit
   application on a CPU that has them - which is most machines running Win32
   software today - gets the same ~1.5 GB/s hardware AES instead of either
   the tables or the constant-time fallback. Every supported compiler (XE3
   through Delphi 13) assembles the 32-bit arm; the constant-time
   implementation now serves only x86 CPUs that genuinely lack AES-NI, plus
   every non-x86 target.

   The TLS record layer now obtains its AES classes from the registry
   (MustFindCipherClass) instead of naming stAES's classes directly. It had
   been pinned to the table implementation since before stAESNI existed -
   TLS bulk AES never used AES-NI. With the pin removed, TLS AES-GCM on one
   x64 core goes from ~610 MB/s (table asm) to ~1.5 GB/s (AES-NI). The TLS,
   SSH and snip endpoint units force-link both stAESNI and stAESCT, so a
   statically linked application gets the right implementation without
   listing any crypto unit.

   The constant-time implementation costs where it runs, and it runs exactly
   where the tables used to and hardware AES cannot: x86 CPUs without
   AES-NI (either bitness) and every non-x86 target. Measured on one x64
   core, AES-128 does ~50 MB/s constant-time against ~610 MB/s for the
   table assembler now in stAESBG. That trade is deliberate: the machines
   that pay it are the machines that were leaking.

   THE TABLE ASSEMBLER MOVED OUT OF stAES INTO stAESBG. stAES is portable
   Pascal; the x86 and x64 assembler that used to sit inside it under IFDEF
   is a unit of its own. Four units now implement the same twelve classes:

       stAESNI   AES-NI or ARMv8 crypto. Fastest, constant time.
       stAESCT   bitsliced software. Slowest, constant time.
       stAESBG   x86/x64 table assembler. Fast, NOT constant time.
       stAES     portable Pascal tables. The reference, NOT constant time.

   AN APPLICATION THAT LINKS ONLY stAES GETS THE PASCAL. On Win32 and Win64
   that is about 340 MB/s where the assembler did about 610; link stAESBG to
   get it back. The assembler itself is byte-for-byte what it was, and
   stAESBG differs from stAES on those two targets ONLY - on every other
   target it compiles to nothing and registers nothing.

   MOST APPLICATIONS SHOULD NOT LINK stAESBG. The hardware it exists for has
   been rare since AES-NI arrived in 2010, and where AES-NI is present
   stAESNI registers ahead of it and its assembler never runs. stAES and
   stAESCT between them cover every machine with an implementation robust
   for the threat model at hand, and stAESNI adds hardware speed wherever
   the CPU has the instructions. stAESBG never displaces stAESNI or
   stAESCT, whatever order the units initialize in.

   DO NOT READ THAT AS "stAESCT IS THE FAST ONE". It is the SLOWEST of the
   four - about 40 MB/s against 340 for stAES's Pascal on one x64 core -
   because a bitsliced circuit buys its constant-time property with
   throughput. It is what you choose when the threat model needs constant
   time, never what you choose for speed.

   THE SPLIT IS ALSO A LICENSING BOUNDARY. Brian Gladman's terms are the
   most demanding of the library's third-party licences: they are the only
   ones obliging a BINARY distribution to reproduce the notice in its
   DOCUMENTATION, in as many words. While that assembler lived in stAES,
   every application that used AES incurred the duty. An application that
   does not link stAESBG no longer does.

   It is not the library's only third-party code, and stAESCT is not free
   of a notice either: its bitsliced core is a translation of BearSSL's
   aes_ct, under the MIT licence, reproduced at the top of that unit. MIT
   asks that the notice accompany copies and says nothing about
   documentation, so it is a far lighter duty - but it is not absent. Of
   the four AES units, only stAES and stAESNI carry no third-party
   copyright at all.

   BOTH CONSTANT-TIME IMPLEMENTATIONS CAN BE COMPILED OUT, and with them
   every line of BearSSL-derived code in the library. Define ST4_NO_AES_CT
   to remove stAESCT entirely, ST4_NO_GHASH_CT to remove tGhashCT and the
   carry-less multiply helpers it uses. Each define also removes the
   BearSSL notice from its unit, because the notice is required only while
   the translated code is present. The library's own uses clauses honour
   ST4_NO_AES_CT - they name stAES in stAESCT's place - so the TLS, SSH and
   snip stacks still build with it set; it changes which implementation
   they resolve to, not whether they compile.

   READ THE PRICE BEFORE SETTING EITHER. What they remove is the
   constant-time implementation, so what remains on a CPU without the
   hardware is the table one: AES falls back to stAES, GHASH to the Shoup
   8-bit table (64 KiB per instance). Both are indexed by SECRET bytes and
   therefore cache-timing variable - precisely the exposure those units
   exist to remove, on precisely the machines they exist for. Where the CPU
   HAS the instructions nothing changes at all, because the hardware paths
   are unaffected and are constant time already.

   The judgement they are for is the one set out below under the second
   practical note: an application whose threat model carries no
   cache-timing exposure, that would rather not carry a third-party notice
   it does not need. An application that cannot make that judgement
   confidently should leave both undefined, which is the default.

   tRijndael_ECB.ConstantTime reports which kind of implementation a class
   is: False for stAES and stAESBG, True for stAESNI and stAESCT. Ask the
   class rather than assuming - which one is registered depends on the CPU
   and on which of these units the application links.

   stAESNI DOES NOT FALL BACK TO THE TABLES. On a target with no hardware
   arm compiled, its routines assert rather than quietly running stAES's
   tables: correct AES with a cache-timing leak, under a class whose name
   says otherwise, is a worse outcome than a stop. This is reachable only by
   naming stAESNI's classes directly - nothing obtained from the registry is
   affected.

   CHOOSING BETWEEN THEM - two practical notes.

   FIRST, ON A DELPHI BUILD FOR A NON-WINDOWS TARGET, PREFER
   ChaCha20-Poly1305. The hardware AES paths are reached by a Delphi
   Win32/Win64 compile, by FPC on SysV x86-64, or by FPC on aarch64; a
   DELPHI build for Linux64, macOS, iOS or Android has none, so AES
   resolves to the constant-time software implementation. On the ARM
   targets that is a COMPILER limit rather than a missing switch: the
   crypto-extension paths exist, but only under FPC, for the reason
   given below.
   Measured on one x64 core, ChaCha20-Poly1305 runs about 180 MB/s against
   80-95 MB/s for constant-time AES-GCM: roughly twice the throughput at no
   security cost, both being constant-time. On Windows the same preference
   would cost an order of magnitude, so decide it per target. It is already
   the default (TTLSOptions.BulkCipherChaCha20Poly1305 is prPrefer, and
   chacha20-poly1305@openssh.com heads the SSH list); what needs attention
   is an application that reorders or trims those lists. It matters most
   for CLIENTS, which is what Delphi's POSIX and mobile targets mostly are.

   SECOND, THE CONSTANT-TIME AES IS NOT AUTOMATICALLY THE RIGHT CHOICE FOR
   AN OFFLINE APPLICATION. What it removes is the AES table cache-timing
   leak, and exploiting that needs a channel to carry the measurement: a
   co-resident process reading the CPU cache (multi-tenant hosting, another
   local user, sandboxed untrusted code), or timing observed over very many
   operations - which an online service hands an attacker by design, since
   the attacker chooses when the operation runs. A desktop tool encrypting
   a local file on a single-user machine has neither, and performs too few
   operations per key to leak a key in any case; there the constant-time
   path costs real time and buys nothing. The exceptions are worth knowing,
   because they are about the threat model rather than about networking: a
   shared or multi-user machine, a machine running untrusted local code, a
   long-lived key used across very many operations (volume or database
   encryption), or a policy that simply requires side-channel resistance.
   Note also that the question only arises where the CPU lacks AES-NI -
   otherwise hardware AES is both constant-time and fastest. The unit
   header of stAESCT elaborates, including how linkage selects the
   implementation.

   ARMv8 HARDWARE AES AND GHASH, UNDER FREE PASCAL. stAESNI and stGHash
   gained ARM crypto-extension paths - AESE/AESD/AESMC/AESIMC for the AES
   bodies including the four-block interleave, and PMULL for GHASH both
   per block and aggregated four blocks at a time (one reduction per 64
   bytes rather than per 16) - for FPC on aarch64 Linux, Android and
   macOS. On those targets AES and GCM
   now run in hardware where the CPU provides it, instead of the
   constant-time software fallback. Measured on an Apple M1 (macOS 26.5.2,
   one core, AES-128): AES-GCM goes from 99 MB/s to 923, a factor of nine,
   and raw AES-ECB reaches 11.9 GB/s against 73 MB/s constant-time. GHASH
   alone runs at 3.4 GB/s aggregated against 305 MB/s constant-time;
   aggregating four blocks per reduction rather than one is worth about
   3.4x on GHASH and 1.7x on GCM.

   Three things about it are worth knowing.

   It is FPC-ONLY, and not for want of trying: Delphi's ARM compilers
   reject inline assembler outright ("E1025 Unsupported language feature:
   'ASM'"), so Delphi's mobile and macOS-ARM targets keep the constant-time
   implementation and the ChaCha20-Poly1305 advice above continues to
   apply to them.

   Detection is mandatory and is not CPUID. The crypto extensions are
   OPTIONAL in ARMv8 - shipping ARMv8 parts exist without them - and
   executing AESE where they are absent is an illegal-instruction fault,
   not a slow path. ARM has no userspace CPUID, and the feature register
   cannot be read portably from user mode, so the test is per-OS: Linux
   and Android read the AT_HWCAP auxiliary vector from /proc/self/auxv
   using raw system calls, which adds no libc dependency, while macOS asks
   sysctlbyname for hw.optional.arm.FEAT_AES (and FEAT_PMULL for GHASH,
   which is a separate feature bit). Note for anyone maintaining this: the
   older hw.optional.armv8_crypto key does NOT exist on current macOS -
   verified absent on 26.5.2 - so testing for it would silently disable
   hardware AES on precisely the machines that have it.

   IT CAN BE TURNED OFF FROM THE PROJECT. Define ST4_NO_ARM_CRYPTO in the
   project's conditional defines and the ARM assembler is compiled out
   entirely, leaving stAESCT and the constant-time GHASH exactly as
   before; the library-wide ST4_NO_ASM does the same. Nothing needs to be
   defined to enable it.

   Verified on an emulated aarch64 Linux target AND on real Apple silicon:
   the FIPS-197 known answers for all three key sizes through the hardware
   path, 900 random-key blocks in which the ARM, table and constant-time
   implementations must agree byte-for-byte in both directions, the GCM
   and mode known answers, and the whole KAT set run a second time with
   the opt-out defined - which must, and does, fall back to the
   constant-time implementation with every vector still passing.

   CONSTANT-TIME TAG ACCEPTANCE (same day). Reviewing whether
   ChaCha20-Poly1305 is constant-time - it is, including the Poly1305 final
   freeze, which uses a masked select rather than a conditional subtraction
   - turned up a gap one level up, in the AEAD and MAC tag COMPARISONS.
   Only the TLS-side ChaCha20-Poly1305 compared tags in constant time;
   every other acceptance decision used CompareMem, whose early exit leaks
   how many leading bytes of a submitted tag were correct. That is the
   classic byte-at-a-time forgery oracle. Its reach is limited in the
   protocol paths, where a bad tag is fatal to the connection and the key
   changes with it, but the same code also serves CMS and file decryption,
   where an attacker is not limited to one attempt per key.

   There is now one helper, stSecUtils.EqualMemConstantTime, whose running
   time depends only on the length, and every tag or MAC acceptance uses
   it: GCM, CCM, EAX, OMAC and XCBC-MAC in stBlockCipher, the SSH
   ChaCha20-Poly1305, the Helix MAC, and the RFC 3217 key-unwrap integrity
   checks in stDes, st3DES and stArc2. Comparisons of PUBLIC data - DER
   structures, GUIDs, test vectors - are untouched.

   Verified with a negative control, which this change needs more than most:
   every existing test supplies a correct tag, so a comparison that always
   returned True would pass all of them. The new check drives the real
   verification entry point with the authentic tag and with every
   single-byte corruption at all sixteen positions, for each AES
   implementation; the control was itself proven able to fail.

   GHASH (same day, completing the GCM story). GHASH had the same two gaps
   AES had. Its PCLMULQDQ hardware path existed only on Delphi Win64, so
   Win32 and every FPC target ran the fallback - and that fallback is a
   64 KiB Shoup table whose lookups are indexed by SECRET bytes, the classic
   GHASH cache-timing channel (with a 64 KiB per-connection cost besides).
   Now: the hardware path covers Delphi Win32 and FPC SysV x86-64 as well,
   and bulk data goes through an aggregated four-block multiply on the
   64-bit ABIs (key powers H^4..H, one reduction per 64 bytes). Where the
   CPU lacks PCLMULQDQ, a new constant-time software GHASH takes over -
   carry-less multiplication via integer multiplies over 2-bit-spaced
   masked operands (after BearSSL's ghash_ctmul64), no secret-dependent
   branch or index. The table implementation is no longer selected by
   anything (tGhash.NewTable keeps it reachable for reference and tests).
   Measured per x64 core: hardware GHASH ~1.4 -> ~4.8 GB/s, taking AES-NI
   GCM from ~1.0 to ~1.9 GB/s in both directions; Win32 GCM goes from ~500
   (leaky table) to ~870 MB/s (hardware GHASH); the constant-time GHASH
   runs ~380 MB/s - well above the constant-time AES it pairs with, so
   constant-time GCM stays AES-bound at ~90 MB/s and loses nothing for
   closing the leak. Verified by the GCM spec TC2/TC3 known answers per
   implementation, ragged cross-implementation agreement, the FPC KAT set
   on Linux x86-64 + big-endian MIPS/PowerPC, and live TLS 1.3.

   BLOCK BATCHING (same day). tBlockCipher gained a batched-ECB primitive
   (EncryptBlocksToDst / DecryptBlocksToDst, default = the per-block loop),
   and the parallelizable modes now feed it: the CTR, GCM and SSH-CTR
   keystream loops stage eight counter blocks at a time, CBC decrypt runs
   eight-block strides, and the ECB loops batch outright. CBC encrypt, OFB
   and CFB encrypt are serial by construction and unchanged. stAESCT
   overrides the primitive to fill BOTH slots of its bitsliced core;
   stAESNI overrides it with four blocks interleaved through the AES round
   instructions, hiding their latency chain. Measured per x64 core,
   AES-128: AES-NI CTR ~900 -> ~3500 MB/s, CBC decrypt ~1000 -> ~5100,
   GCM ~560 -> ~1000 in both directions (the table-driven GHASH is now the
   GCM ceiling); constant-time GCM ~45 -> ~90, CBC decrypt ~37 -> ~74, CTR
   ~49 -> ~96. Verified by NIST SP 800-38A F.2.1/F.5.1 and GCM TC3 known
   answers driven one-shot AND split at ragged 1/7/8/16/25/7-byte call
   boundaries through all three implementations, the FPC KAT set on Linux
   x86-64 + big-endian MIPS/PowerPC, and live TLS 1.3 handshakes.

   COUNTER STAGING (2026-08-09, closing the same thread). With AES in
   hardware the batched keystream modes stopped being AES-bound, and what
   remained was the staging: handing eight blocks to the batch primitive
   meant eight IncBlock calls and eight 16-byte Moves, which on an Apple M1
   accounted for roughly three quarters of CTR time. The counters are now
   rebuilt word-wise instead. The 128-bit block is held as four native
   32-bit words; the top three change once in 2^32 blocks, so their
   big-endian image is computed once per call and merely stored, leaving one
   byte-swap and two 64-bit stores per block, and one load and write-back of
   the counter per call rather than per block. Which of the two is faster is
   a per-target question, and it was measured rather than assumed: Delphi
   x64 keeps the per-block loop, because there IncBlock has a hand-written
   x64 asm arm and a 16-byte Move is a single SSE pair, so two calls per
   block cost less than the rebuild; every other target takes the word-wise
   path, as does any stride too short to amortise the per-call load.
   Measured, AES-128, 1 MiB, MB/s: FPC aarch64 (Apple M1) CTR 1245 -> 2380
   and GCM 923 -> 1405; Delphi Win32 CTR 2030 -> 2543 and GCM 887 -> 907;
   Delphi Win64 unchanged at ~3190 and ~1920.

   Verified additionally by partition invariance: for message lengths 3 to
   130 bytes, EVERY way of cutting a message into three non-empty
   consecutive pieces must encrypt - and where the mode allows it, decrypt -
   to exactly what the single-call path produces. That is 301311 splits
   across seven mode and padding combinations per implementation. It found
   no defect here, but it is strictly stronger than the fixed ragged-split
   vectors above: with a deliberate one-block counter error injected, those
   vectors still pass and the partition sweep fails. The sweep runs on
   Win32, Win64, Linux64 and macOS ARM64; the FPC KAT set covers Linux
   x86-64, aarch64 (Linux and macOS) and big-endian MIPS/PowerPC, the last
   of which is the only place the big-endian half of the counter
   serialisation executes - a deliberately flipped byte order there fails
   those KATs on both big-endian targets and passes on x86-64.

   Verified by known answer against FIPS-197 appendix B and C and RFC 3394,
   by the S-box circuit against the lookup table over all 256 inputs, by 900
   random-key cross-checks in which the bitsliced, table and AES-NI
   implementations must produce identical blocks, and by live TLS 1.3 and
   TLS 1.2 (CBC and GCM) handshakes through the re-routed record layer.


39. FIXED - the HasRole defect was a class, and the class has been swept

   The uninitialized out-parameter fixed in TsnifUser.HasRole is a
   language-level trap, not a one-off: Delphi auto-initializes only MANAGED
   out parameters (strings, dynamic arrays, interfaces). An out parameter of
   an object, record, enum or integer type keeps whatever the caller's stack
   happened to hold. Every out parameter of an unmanaged type in the library
   has therefore been audited - roughly 670 declaration sites, each
   implementation traced through all of its exit paths - and the following
   were fixed. Everything else was verified to assign its out parameters on
   every success path.

   In the ASN.1 coders, the implicit-tag path of tBERCoder.CheckReadTag and
   tDERCoder.CheckReadTag answered success without assigning the header
   record it hands back, and the BER coder went on to read that garbage
   itself: its indefinite-length closing-tag accounting was decided by
   whatever was on the stack. The header is now zeroed on entry and the BER
   accounting runs only when a header was actually read in that call. In the
   same units, the ReadContent overload that parses UTCTime and
   GeneralizedTime values ignored the time parser's Boolean result, so a
   malformed time string in a certificate returned normally with an
   unassigned TSystemTime - stack garbage as a validity date. The record is
   now zeroed first: a malformed time reads as the obviously invalid year 0.

   In the SSH option lists, SelectAsClient and SelectAsServer left their
   aCorrectGuess out-parameter unassigned when the peer shared no common
   algorithm name, and the kex-init readers consume that flag even then -
   garbage decided whether a guessed first kex packet was decoded or
   discarded on a handshake that was already failing. No selection now means
   no correct guess.

   Two hygiene defects of the same family: PVKToPrivateKeyBlob freed its out
   pointer on the exception path without re-nilling it, leaving a dangling
   reference visible to any caller that catches; and the NexusDB transports
   encoded a server version into their connect reply that the session
   registration call is not guaranteed to have written.

   One BEHAVIOUR CHANGE, deliberate: the untyped-buffer overload of
   tBaseDrbg.RawRandom silently discarded the DRBG status, so a failed
   generate handed the caller its own uninitialized memory as random output.
   It now raises eRandom on failure, exactly as the tBytes overload always
   has. Code that relied on the silent path was relying on weak randomness.


40. FIXED - a BER-loaded CMS message re-encoded ANY attribute values with a
    spurious placeholder header, failing signature verification

   A structure loaded with the BER coder (as the CMS components do internally)
   re-encodes structurally, member by member, rather than copying the load
   buffer the way a DER-loaded structure can. An ANY value resolved through an
   information-object class - a signed or unsigned attribute value whose
   declared arm is a raw container, such as openssl's ESS signingCertificateV2
   - decodes into a tag-less wrapper object holding the value's own TLV as a
   child. The structural encoder derived a tag from that wrapper's zeroed
   members and emitted it: a two-byte UNIVERSAL|CONSTRUCTED|0 header (hex 20
   len) around the otherwise intact value, a tag that is never legal ASN.1.

   Any signature computed over such a re-encode fails verification: an
   RFC 3161 signature time-stamp token on a message the component loaded (the
   attribute travels inside the token's signedAttrs), and equally a BER-loaded
   countersignature carrying such values. The encoder now recognizes the
   wrapper's undefined tag and emits only its contents, so the structural
   re-encode reproduces the wire bytes and the same file verifies identically
   through the DER and BER loaders.

   Also FIXED in the same machinery: saving a DER-loaded structure back out
   through its own coder could leave lazily-unread members in a state their
   accessors mistake for fully read - the save consumed only the outer tags,
   the accessors then indexed field arrays that were never populated, and the
   next member access after a SaveToStream crashed with an access violation.
   The save-time read now materializes the field offsets it advances past, so
   reading members after saving works no matter which side went first.

41. FIXED - EnvelopedData encrypted with whichever cipher happened to be
    registered first, not the one the application asked for

   TstMPEnvelopedData chose its content cipher from SMIMECapabilities item
   zero. That collection is pre-filled by the constructor from the cipher
   registry, in the registry's OID-sorted order, so item zero was never the
   item the application added - and the order changed with the set of cipher
   units a program happened to link. Adding a unit that pulls in more ciphers
   (as the CMS component now does, by way of the OCSP and time-stamp
   transports) moved a different cipher into slot zero. A program asking for
   AES-256-CBC could get RC2 with a 64-bit key, which is what shipped on the
   wire, and decryption then failed outright.

   Selection now honours the request. Capability items the application adds or
   assigns take precedence over the constructor-filled defaults, in the order
   the application listed them. When the application adds none, the strongest
   registered AES-CBC is used rather than whatever sorted first, so merely
   linking another cipher unit can no longer change the content encryption
   algorithm. BEHAVIOUR CHANGE, and the reason this is worth reading: a
   requested cipher that this build does not register is now an eCipherError
   from Encrypt, where before it was silently replaced by a different
   algorithm - usually a weaker one. Applications that relied on the
   substitution were shipping a cipher they never asked for.

   Also FIXED in the same path: stSecUtils.GetSMIMECapabilities, the tree
   overload, recorded each cipher's key sizes as the tree node index instead
   of the key length, so the pre-filled capability list advertised key sizes
   that had nothing to do with the ciphers named beside them.


42. FIXED - intersecting a correspondent's S/MIME capabilities kept only RC2,
    and destroyed the local capability list while it ran

   tSMIMECapabilities.AssignStruct takes the SMIMECapabilities attribute a
   correspondent advertised (RFC 8551 section 2.5.2) and reduces the local
   capability list to what both sides support. Three defects made it unusable.

   The surviving entry was added inside the branch that handles RC2 rather
   than after it, so a capability naming any other cipher was resolved,
   accepted, and then dropped on the floor. A correspondent advertising only
   AES intersected to nothing, and the function reported failure.

   The result was assigned back inside the per-item loop instead of after it.
   The list being overwritten is the same list the membership test reads, so
   the local capabilities were replaced by the partial result while the loop
   was still walking the advertised set: once one advertised capability failed
   to match, nothing later in the set could match either.

   An RC2 capability raised "ARC2: Invalid key size - 0" outright. Recovering
   the effective key size from the RC2ParameterVersion needs an unkeyed cipher
   instance, and the code asked for a keyed one with a zero-length key. The
   same construction is corrected in the capability test the EnvelopedData
   decoder uses to decide whether a received message was encrypted with a
   cipher the application admits, which raised that exception for any
   RC2-encrypted message.

   Also corrected: the key size and keyed-IV flag were handed to the cipher
   lookup uninitialized. That lookup reads the key size before it writes it -
   a size already in the variable is taken as given when it falls inside the
   cipher's accepted range - so a stray value could fix the wrong key length
   on a capability. RC2 accepts 1 to 128 bytes, which is most of the range a
   stray value can land in.


43. NEW - TsnifUserFileStorage: the Snif user list, persisted

   TsnifClassServer holds its user list in memory and has no opinion about
   persistence; this component supplies it, backed by an INI file (one
   section per user: the auth blob in hex, the roles, the failure counters,
   any pending one-time-code hash and its expiry). LoadInto seeds the server
   at startup; Attach wires OnUserUpdated so a live change - a KAPA password
   commit, a bumped failure counter - is written through automatically. It is
   auth-scheme-agnostic: the AuthData blob is whatever the active scheme
   produced (a KAPA password file or the legacy verifier).

   The two timestamps (LastFailure, OtpExpiry) are stored as ASN.1
   GeneralizedTime text - 20260805230405.12Z - so the file can be read and
   edited by hand; 0 stands for never. The loader ALSO accepts the decimal
   Int64 form (the raw TDateTime bit pattern) that earlier builds wrote, so
   an existing file loads unchanged and comes back in the readable form the
   next time it is saved.

44. FIXED - a remotable method returning an EMPTY array raised on the client

   A snif method whose result was a list worked for one row and failed for
   none. Any "list the rows" method met this the first time its list was
   empty - a new installation, a filter that matched nothing, a directory
   with no files in it - and the caller saw a decode error rather than an
   empty result.

   TWO THINGS MEET TO PRODUCE IT, which is why it presented as a decode fault
   when nothing was wrong with the decoder. TValue.GetIsEmpty answers True
   for a dynamic array of length zero, so the class server's "only marshal a
   result when one was returned" guard - written for methods that return
   nothing - elides the value and never converts it; and the zero value of
   the wire-kind enumeration is the one that means "bytes", so what the
   client then decodes is an empty byte string where an array was expected.

   The conversion layer now answers an empty array of the expected type for
   that shape. ENCODING IS UNCHANGED and was never the problem: an array that
   is transmitted still carries its length, so the wire format does not move
   and a client and a server built either side of this fix interoperate.


--------------------------------------------------------------------------------
 PDF SIGNING, AND RFC 3161 TIMESTAMPS
--------------------------------------------------------------------------------

45. NEW - TstTimeStampClient: an RFC 3161 timestamp client

   StreamSec.DSI.Tsp is a complete Time-Stamp Protocol client. It builds the
   TimeStampReq, posts it to the authority as application/timestamp-query over
   the same HTTP transport the OCSP client uses, and decodes the TimeStampResp.
   RequestTimeStamp timestamps data; RequestTimeStampDigest timestamps an
   imprint you already hold; VerifyToken and VerifyTokenDigest check a token
   on its own, at any later time, against the data it claims to cover.

   THE RESPONSE IS CHECKED, NOT TRUSTED. The token's CMS SignedData is
   verified against the TSA certificate carried in it; that certificate must
   bear the mandatory id-kp-timeStamping extended key usage; the imprint in
   the TSTInfo must equal the digest that was sent; the nonce must come back
   unchanged; and genTime must fall within MaxClockSkew seconds of local time.
   Nonce is on by default, so a replayed token does not pass.

   Configure TsaURL, HashAlgorithm, Nonce, NonceLength, PolicyOID (to demand
   one particular TSA policy), Timeout and MaxClockSkew; read the outcome back
   through LastStatus, LastStatusText, LastGenTime, LastTsaCertificate,
   LastTokenDER and LastError. The component is not on the palette: it is
   normally driven through TstPdfSigner.TimeStampURL or from the CMS layer,
   each of which owns an instance for you.

   TstTimeStampClient also gains the ExtKeyUsagePolicy property described in
   entry 46, for the id-kp-timeStamping purpose RFC 3161 2.3 requires of a TSA
   certificate. Its default is ekupAllowUnconstrained, which is exactly what
   this client has always done - and worth knowing, because CheckExtKeyUsage
   answers True for a certificate carrying NO extendedKeyUsage at all, so such
   a TSA certificate has always passed. That is looser than the RFC;
   ekupRequire is the conformant setting, and is not the default only because
   tightening it would reject tokens that verify today.

   The client is interop-tested against an OpenSSL time-stamp authority.

46. NEW - TstPdfSigner: PAdES signatures, B-B through B-LTA

   StreamSec.Pdf.Signer signs a PDF the way ISO 32000 12.8 requires: BY
   INCREMENTAL UPDATE. The original bytes are never rewritten. An update
   section is appended carrying the signature field, its widget annotation and
   the signature dictionary, and the detached CMS SignedData is then patched
   into the reserved /Contents hole once the two /ByteRange spans have been
   digested. SignData works on streams, SignFile on paths.

   The CMS comes from the same TstCustomMPSignedData machinery the rest of the
   library signs with, so every algorithm the key manager can drive is
   available here with no PDF-specific code path. KeysAndCerts is the
   certificate manager, ContentDigestAlg picks the digest, ContentsSize
   reserves the hole, and FieldName, Reason, Location and ContactInfo populate
   the dictionary.

   ALL FOUR PAdES BASELINE LEVELS (ETSI EN 319 142-1) ARE REACHABLE:

     B-B     SubFilter ETSI.CAdES.detached. The profile is more than a name:
             the ESS signing-certificate-v2 signed attribute is REQUIRED and
             the signingTime attribute is FORBIDDEN (the time lives in the
             dictionary /M entry), and selecting it sets both accordingly.
             The default remains adbe.pkcs7.detached, the universally
             accepted form.
     B-T     add TimeStampURL and the signature carries an embedded RFC 3161
             signature timestamp, obtained by the client in entry 45.
     B-LT    ExtendToLT / ExtendToLTFile append a /DSS holding the
             certificates, OCSP responses and CRLs needed to validate the
             signature later, so it survives the signer certificate expiring
             or its responder disappearing. Fill the material with
             PdfAddCert / PdfAddOcsp / PdfAddCrl.
     B-LTA   AddDocumentTimestamp appends a document timestamp over the whole
             file; ExtendToLTA does the LT extension and that timestamp in two
             updates (the timestamp must cover the DSS). Repeating it renews
             the archival protection.

   Extension is itself incremental, so raising an already-signed document to
   B-LT or B-LTA does not disturb the signature it already carries.

   VISIBLE SIGNATURES. Set VisibleLeft, VisibleBottom, VisibleRight and
   VisibleTop in PDF user space and the widget gets a real appearance stream
   (/AP /N) instead of the zero-sized rectangle an invisible signature uses;
   VisibleText is what it draws.

   CERTIFICATION SIGNATURES. Certify makes this a DocMDP certification
   signature rather than an ordinary approval signature: the dictionary gains
   a /Reference with TransformMethod /DocMDP carrying the CertifyLevel
   permission in /P, and the catalog gains a /Perms /DocMDP pointing back at
   it. CertifyLevel is 1 (no changes permitted), 2 (form fill-in and signing,
   the default) or 3 (also annotations). ISO 32000 allows exactly ONE
   certification signature per document, and it must be the FIRST one.

   A signing certificate now has an extended key usage to name. stOIDs declares
   id_kp_documentSigning (RFC 9336, 1.3.6.1.5.5.7.3.36) and tExtKeyUsageSyntax
   registers it, so it reads back by name rather than as a bare arc. That is
   the purpose a PDF signature serves, as against code signing or mail. Naming
   it is a RESTRICTION rather than a free improvement: a relying party that
   pins a list of acceptable key purposes will refuse a certificate whose EKU
   it does not list, while one that does not constrain EKU accepts either
   shape.

   Acting on that purpose is a new property on both PDF components,
   ExtKeyUsagePolicy, with three states rather than a Boolean because the
   middle one is the useful setting for a new deployment: ekupIgnore does not
   look at extendedKeyUsage and is what these components have always done, so
   NOTHING CHANGES ON UPGRADE; ekupAllowUnconstrained accepts a certificate
   that names no purpose but refuses one that names only others (the RFC 5280
   rule, and what iCertificate.CheckExtKeyUsage answers on its own);
   ekupRequire additionally insists the extension be present. On TstPdfSigner
   a rejection refuses to produce the signature; on TstPdfVerifier it makes
   the signature invalid, and the new OnKeyUsageRejected event gets the last
   word - raised ONLY on the rejecting path, so an unassigned handler can
   never weaken the policy. The shared tExtKeyUsagePolicy type and the
   CheckExtKeyUsagePolicy helper live in StreamSec.DSI.PkixCert.

47. NEW - TstPdfVerifier: what the signature actually covers

   Verifying a PDF signature is not the same as verifying its CMS. A PDF may
   legitimately be appended to after signing - that is how a second signature
   is added - and the two classic attacks both live in that gap. INCREMENTAL
   SAVING appends a revision that supersedes an object the signature covered.
   SIGNATURE WRAPPING crafts a /ByteRange whose two spans leave attacker bytes
   unsigned in the gap between them. TstPdfVerifier is built to catch both:
   the gap between the signed spans must be EXACTLY one PDF hex string - the
   /Contents slot and nothing else - which a wrapped ByteRange fails even when
   it appears to cover the whole file.

   VerifyData and VerifyFile answer a tPdfSignatureStatus:

     pssValid          the CMS verified and the ranges cover the whole file
     pssValidModified  the CMS verified, but bytes were appended afterwards
     pssInvalid        a signature is present and did not verify
     pssNoSignature    the document carries no signature field
     pssError          the document could not be assessed at all

   pssValidModified is the interesting answer, and appended bytes are
   therefore CLASSIFIED rather than merely detected. LastModificationClass and
   ModificationOf[] report which of these happened:

     pmcNone            nothing was appended after this signature
     pmcSignatureOnly   only legitimate growth: new objects, the AcroForm
                        /Fields and page /Annots that adding a signature field
                        touches, and the /DSS + /Extensions a B-LT extension
                        adds
     pmcContentChanged  an object the signature covered was SUPERSEDED by a
                        later revision - the shadow-attack surface
     pmcUnparsable      the appended revision could not be analysed

   So a document that was signed twice, or raised to B-LT, does not read as
   tampered with, while one whose page content was swapped does.

   EVERY SIGNATURE IS EXAMINED, not just the first - checking only the first
   lets a document pass on the strength of one good signature. SignatureCount,
   Signatures[], StatusOf[], ErrorOf[] and ModificationOf[] are all indexed in
   AcroForm /Fields order. Where a signature carries a timestamp, its verified
   time is surfaced through LastTimeStampTime, and LastTimeStampError says why
   when it could not be checked.

   EXTERNAL VALIDATION. What this produces is not judged only by the code that
   produced it: signed documents validate under openssl and under pyHanko, and
   the embedded timestamps resolve to the issuing authority.

48. NEW - CAdES baseline signatures, B-B through B-LTA

   StreamSec.DSI.CAdES raises an ordinary CMS signature to the ETSI EN 319 122-1
   baseline levels. It is a set of VERBS over an already-encoded SignedData
   rather than a property you set before signing, because that is what the
   standard actually requires: the revocation data a B-LT signature embeds must
   post-date the signature timestamp, so at the moment the signature is produced
   that data does not yet exist. B-LT and B-LTA are things done to a signature
   later, often by a party holding no key at all.

     B-B    SignData with IncludeSigningCertificateV2 and a SHA-2 digest
     B-T    ... and TimeStampURL, which attaches the RFC 3161 signature
            timestamp
     B-LT   ExtendToLT - certificate-values and revocation-values
     B-LTA  ExtendToLTA - the above, then an archive timestamp

   CAdESLevelOf reads a signature back and reports the level the BYTES reach,
   which is a different question from the level someone configured. It refuses
   to skip a rung: validation data added to a signature carrying no timestamp
   leaves it at B-B, because B-LT is defined as B-T plus that data.

   Everything above B-B is an unsigned attribute, so augmenting is purely
   additive and an already-valid signature stays valid. The archive timestamp
   (archive-time-stamp-v3) is the intricate one: its imprint is a nine-element
   concatenation of the original encodings, and the ats-hash-index-v3 that goes
   with it is injected into the timestamp token's own SignerInfo by rewriting
   bytes, never by re-encoding the token - re-serialising would destroy the
   timestamping authority's signature.

   The validation material type is format-neutral: PAdES and CAdES need exactly
   the same certificates, OCSP responses and CRLs, so an archivist gathers them
   once. Note that revocation-values requires the inner BasicOCSPResponse rather
   than the OCSPResponse a responder returns; the unwrapping is done for you.

   EXTERNAL VALIDATION. The archive timestamp is not judged by the code that
   produced it. Signatures are stamped by a live public timestamping authority,
   and the imprint is then recomputed independently, with a different ASN.1
   library, and compared against the value the authority actually signed; the
   three arms of the hash index are cross-checked entry by entry the same way.
   pyHanko reports the resulting CMS intact and valid.

   DEMO. Demos\<version>\CMS gains CAdESDemo alongside the existing CMSDemo, for
   every compiler from XE3 to Delphi 13. It deliberately does not sign - CMSDemo
   already shows that - but opens an existing signature, reports the level its
   bytes actually reach, and extends it.

   DOCUMENTATION. PKIX.txt now maps the standards this rests on. Its RFC section
   gains an AdES entry covering time-stamping (RFC 3161, RFC 5816), CAdES (ETSI
   EN 319 122-1, and TS 101 733 for the structures that survive in older
   signatures) and PAdES (ISO 32000 clause 12.8, ETSI EN 319 142-1), together
   with two details that are easy to get silently wrong: SHA-2 algorithm
   parameters are absent rather than NULL (RFC 5754), and an OCSP response
   carried in SignedData.crls is wrapped per RFC 5940 rather than stored bare.
   S/MIME, previously a single line, now has its own section - RFC 8551 and
   8550, and the ESS attributes of RFC 2634 and 5035, the last of which is also
   what every AdES baseline requires.

49. Package membership

   Everything above is compiled by every supported compiler. The new units are
   in the contains clause of all fourteen runtime packages, StrSecIV170 (XE3)
   through StrSecIV370 (Delphi 13):

     the mail units       StreamSec.Mail.Message, .SMIMEBroker, .SMTPClient
     the TLS clients      StreamSec.Mobile.TLSClient, .HTTPSClient,
                          StreamSec.Http.Http2Client
     the async server     StreamSec.Mobile.AsyncTLSServer, .AsyncTLSReactor
                          and its platform backends
     the HTTP stack       StreamSec.Http.Server, .Hpack, .Http2Frames,
                          .Http2Conn, StreamSec.Mobile.HTTPS
     the jail             stFileJail, stFileJail.Windows, stFileJail.Posix,
                          stMimeTypes
     constant-time AES    stAESCT
     PDF and timestamps   StreamSec.Pdf.Model, StreamSec.Pdf.Signer,
                          StreamSec.DSI.Tsp
     CAdES                StreamSec.DSI.CAdES
     ini configuration    stIniFile
     the socket layer     stWinsock2

   stWinsock2 replaces stJwaWinsock2, stJwaWS2tcpip and stJwaQos in all
   fourteen; those three are still distributed but belong to no package - see
   entry 61.

   Design-time registration follows in all fourteen design packages for the
   units that register components: StreamSec.Mail.Reg (TsmEmail, TsmSMTPClient,
   TsmAdvancedSMTPClient on the StreamSec Mobile page; TstSMIMEBroker on
   StreamSec Tools), StreamSec.Mobile.TLSClientReg,
   StreamSec.Mobile.AsyncTLSServerReg and StreamSec.Pdf.Reg (TstPdfSigner and
   TstPdfVerifier on the StreamSec Tools page, beside the CMS components they
   build on, with their palette icons in StreamSec.Pdf.Reg.dcr). The jail
   registers nothing - none of its units declares a component, and neither the
   PDF object model in StreamSec.Pdf.Model (plain classes, not components) nor
   TstTimeStampClient appears on the palette.


--------------------------------------------------------------------------------
 THE DEMOS
--------------------------------------------------------------------------------

50. NEW - StreamSecWebServer: a whole server, not a snippet

   Demos\Delphi 13\StreamSecWebServer is a working HTTPS deployment. It is
   where most of what this release adds is shown doing its job together
   rather than one component at a time: the asynchronous TLS server carrying
   the HTTP stack, a document root served through a file jail, snip on its own
   ALPN token as a private administration channel, ACME renewal in managed
   mode, and the Snif user store behind the login.

   Three projects:

     StreamSecWebServer.dproj      the server - a Windows service when the
                                   service manager starts it, a desktop
                                   application when you double-click it, the
                                   same data module either way
     AdminClient\WebAdminClient.dproj
                                   a VCL administration client that reaches
                                   the server over the administration channel:
                                   files under a document root, the forum, and
                                   read-only access to the log files
     Tools\ProvisionAdmin.dproj    creates an administration account; the
                                   password is typed there and never reaches
                                   a configuration file

   It also carries a download forum with per-user package access, one-time
   codes by mail for sign-in and for recovering administration access, and a
   peer screen that can offer the administration protocol to some source
   ranges and not others.

   The server generates /robots.txt and /sitemap.xml for each host it is
   configured to serve, rather than leaving them to be written by hand: the
   host's own root and content pages, plus the forum's sections and topics on
   whichever host the forum answers on. A name that is only an alias gets
   neither, because a request for it is redirected to the canonical name. A
   real file of either name in the document root wins over the generated one.

   THE SITEMAP LISTS ONLY WHAT AN ANONYMOUS VISITOR CAN ALREADY REACH. It is
   built by asking the forum the same visibility question a request asks, with
   nobody signed in, so a members-only section contributes nothing to it: not
   its topics, not their identifiers, not the fact that it exists. No section
   or topic name is written to either file. The download tree is excluded
   because access to it is granted per account, and the attachment tree because
   it follows the visibility of the section a file was posted in. The ?cmd=
   endpoints are disallowed as a class, so crawling cannot arrive at a sign-in
   or a download handler.

   The one-time-code mailer verifies its relay against a trust store of its
   own, configured in [Mail] beside that relay's host and credentials rather
   than in [Keys]. It holds one or two certificate authorities and at most one
   client identity, and it serves the relay and nothing else: the store the
   rest of the server uses for ACME and for revocation checks neither vouches
   for the relay nor is widened by it. A certificate in a trust store is a full
   anchor for everything that store is used for, so the only way to keep two
   trust decisions apart is to keep two stores.

   THE OTP MAIL TAB WORKS OUT WHICH AUTHORITY THAT IS. It asks the configured
   relay which one it expects a client to hold and takes that single
   certificate - from the Windows certificate store, or straight from the chain
   when the relay sends its own root - writes it beside the executable and
   names it in [Mail]. One certificate is taken; the rest of the Windows store
   is neither imported nor trusted, which is the point of asking rather than
   loading a public bundle and hoping.

   IT WILL NOT START UNTIL YOU SUPPLY WHAT WAS REMOVED, and that is deliberate
   rather than an oversight: it ships with no certificates, no accounts, no
   forum data and no mail relay. README.txt lists what is missing. FIRSTRUN.txt
   is the one to read before the first start - which settings MUST be set and
   which SHOULD be, separately for a new installation and for a deployment
   that is replacing an older server, and what the log says about each
   decision the server made because the configuration did not say otherwise.


51. NEW - the mail server demo: a small mail host on one datamodule

   Demos\<your IDE>\MailServer is SMTP, POP3 and IMAP running together over
   one maildir and one account store. Mail arrives, lands in a mailbox, and
   comes back out again - which is the part that is hard to see when each
   component is demonstrated on its own.

   THE ARRANGEMENT IS THE DATAMODULE. MailServerModule.dfm carries all of it -
   one TLS engine shared by all three servers, one TsmMailStore in each
   server's Store property, one TsmMailUsers answering for all of them, and the
   SMTP inbound and submission roles on separate listeners because they differ
   in whether they may relay. Every one of those links is an Object Inspector
   property; nothing is constructed and no object reference is assigned in
   code.

   Three things stay in code, and the demo says why: the certificate, because
   ImportFromPFX takes a password and a key is loaded rather than configured;
   the mailbox root, because it defaults to a directory beside the executable;
   and the ORDER - store before servers, engine before any listener offering
   STARTTLS. Active is deliberately NOT streamed True, because a datamodule
   that opened listening sockets while loading would bind them before the
   certificate existed.

   THE PORTS DEFAULT TO 2525, 2587, 2110 AND 2143. Binding anything below 1024
   needs elevation on Windows and CAP_NET_BIND_SERVICE on POSIX, and a demo
   that will not start unless it is run as an administrator teaches the wrong
   thing about what these components require. Change them for a real
   deployment. The listeners bind 127.0.0.1.

   It also shows the one thing every VCL application using these servers has
   to get right: OnLog and the session events are raised from CONNECTION
   THREADS, so the handler cannot touch a control. The queueing lives on the
   datamodule rather than the form, because the reason it is needed is on the
   server side - the form is handed finished lines on the main thread.

   Server.pfx and root.cer ship with it, password 'abc' - the same demo
   certificate the TLS demos use, issued to nobody and trusted by nothing.
   readme.txt covers what to point a mail client at, and what to expect when
   two clients open one mailbox at once: IMAP allows it, POP3 does not.

   What it deliberately leaves out: an outbound queue, a smarthost, MX
   delivery, DKIM signing and a service wrapper. All of them are supported
   (entries 4, 7 and 10) and all of them would bury the wiring this demo
   exists to show.

52. FIXED - a memory leak in elliptic-curve scalar multiplication

   A TLS handshake over x25519 or x448 leaked one elliptic-curve point and the
   curve object it pinned - about 7 allocations per endpoint, so roughly 14 per
   connection with both ends on this library. On a server that is per
   CONNECTION and unbounded: it does not level off, and nothing frees it until
   the process exits. The same defect was then found in the NIST prime-curve
   arithmetic, where it costs 6 allocations per scalar multiplication.

   THE CAUSE, because the shape is worth recognising elsewhere. The scalar
   multiplication writes its answer through an UNTYPED `var aResult`:

     function GroupOpIteration(const aGenerator: iGroupElement;
                               const aIterationCount: iDSInteger;
                                 var aResult): Boolean;

   and stored it with Supports(lResult,IInterface,aResult). An untyped var (or
   untyped out) is invisible to the compiler's reference counting, and
   QueryInterface writes the new pointer straight over the old one. Whatever
   the caller had in that variable was never released - and callers do pass a
   variable that already holds a point, because the TLS 1.3 key exchange reuses
   the peer's public key as the destination for the shared secret. Each
   handshake therefore dropped one point on the floor, and that point held the
   curve, and the curve held its generator.

   All six implementations - X25519, X448, Ed25519, Ed448 and the two NIST
   ones - now release the caller's previous value before storing the new one,
   after the new value exists, so that a self-aliased call
   (P.GroupOpIteration(...,P)) cannot free the generator it is still using.

   THE NIST CURVES HAD THE SAME DEFECT, and it was measured rather than
   assumed: 6 allocations leaked per call whenever the destination already held
   a point, and 0 when it was empty. TLS never tripped it, because the prime-
   curve key exchange takes a different route - but ECDSA and CMS do call it,
   so anything signing or verifying in a loop was losing memory steadily.

   IT WAS NEVER A COMPILER REGRESSION, which was worth ruling out: the same
   probe built with every compiler from XE3 (CV24) to Florence (CV37) leaks the
   same 6 allocations per call on all fourteen. A typed out/var interface
   parameter IS finalised by the compiler at the call site; an UNTYPED one
   cannot be, because nothing knows its type. That is a property of the
   language, not of a code generator that might drift between releases.

   Verified by measurement rather than by inspection: a single-threaded,
   socket-free loopback that hands a client engine and a server engine memory
   streams, counting live allocations AFTER both engines are freed. Before, it
   retained a fixed baseline plus exactly 14 blocks per handshake, linearly,
   over 2, 6 and 21 handshakes; after, the per-handshake term is zero and the
   baseline is unchanged. RFC 7748 and RFC 8032 vectors, ECDSA and the CMS
   primitive vectors all pass unchanged, and the full 14-compiler package
   matrix builds clean.

   NOTHING TO CHANGE IN YOUR CODE. If you run a long-lived TLS server that
   negotiates x25519 - which is the common case, since it is what current
   clients prefer - this is the difference between steady memory and memory
   that grows with the connection count.

53. NEW - TstMemIniFile: an ini file that survives being saved

   TMemIniFile holds a model of sections and keys and writes the file back from
   that model, which is all it has: comments, blank lines and the order things
   were written in are not part of it and do not survive UpdateFile. For a
   configuration file whose comments carry the operator's documentation, the
   first save erases the manual.

   TstMemIniFile, in stIniFile.pas, descends from it and keeps the file's own
   lines alongside the parsed model. UpdateFile compares the model against the
   state it was loaded in and applies only what differs: a changed value is
   rewritten in place, keeping its position and its spacing; a new key is added
   inside its own section; a deleted key costs its own line and no comment.
   Anything untouched is left exactly as it was, and a file saved without any
   change at all comes back byte for byte identical.

   IT IS A DROP-IN REPLACEMENT. Every read and every write is the inherited
   one, so adopting it is a change of type and nothing else.

   IT ALSO READS A '#' LINE AS A COMMENT, which TMemIniFile does not: that one
   takes "# Host = 10.0.0.1" for a key named "# Host". A commented-out example
   therefore arrives as live configuration and is written back as though it had
   been asked for. Here both the reader and the writer treat '#' as a comment,
   so a file is read the way it looks.


--------------------------------------------------------------------------------
 PUBLIC KEY FORMATS
--------------------------------------------------------------------------------

54. NEW - SubjectPublicKeyInfo for EdDSA and for the composite key types

   A key component writes its public half through whichever entry its
   PublicKeyFormat list selects, and that list held no entry named for
   Ed25519, Ed448, composite ML-KEM or composite ML-DSA. The two composite
   kinds were offered their certificate formats and nothing else, and a
   certificate format has a certificate to write: a key pair that has just
   been generated has none, so its public half could not be written at all.
   EdDSA keys were offered the discrete-log entries they share a family with,
   none of which is the encoding an Ed25519 or an Ed448 key calls for.

   Six formats close that, named the way the others are:

     SubjectPublicKeyInfo-DER-EdDSA
     SubjectPublicKeyInfo-PEM-EdDSA
     SubjectPublicKeyInfo-DER-CompositeMLKEM
     SubjectPublicKeyInfo-PEM-CompositeMLKEM
     SubjectPublicKeyInfo-DER-CompositeMLDSA
     SubjectPublicKeyInfo-PEM-CompositeMLDSA

   The EdDSA pair writes what RFC 8410 asks for: id-Ed25519 or id-Ed448, the
   algorithm parameters absent, and the raw public key carried in the BIT
   STRING. The composite pairs write the composite algorithm's own object
   identifier, parameters likewise absent, over the concatenated component
   keys - the same subjectPublicKeyInfo the library already puts into a
   composite certificate.

   Each of the six accepts only its own kind of key, on the way out and on
   the way back in, so a key of another kind is refused rather than written
   through an encoding that does not describe it.

   The practical difference is to a key that no certificate has been issued
   for yet. A DKIM signing key is the clearest case: it is generated, its
   private half is kept, and its public half belongs in DNS rather than in a
   certificate. Writing that public half is a matter of choosing the format.

--------------------------------------------------------------------------------
 THE REST PAIR
--------------------------------------------------------------------------------

55. NEW - TsmRESTClient: a JSON-REST client with a trust domain of its own

   StreamSec.Http.Rest calls a JSON-REST API over the library's own TLS stack.
   TsmRESTClient is the component; TsmCustomRESTClient is the base a project
   subclasses when it would rather write code than drop a control. Either way
   what it supplies is the part every integration otherwise rewrites: a base
   URL, a bearer token that is fetched once and reused, a single retry when the
   service says the token has expired, and headers that survive HTTP/2.

   IT TRUSTS WHAT YOU GIVE IT AND NOTHING ELSE. The client owns its own
   TsmSimpleTLSInternalServer rather than borrowing the global one, so the
   anchors that let it reach a payment gateway are not also trusted by
   everything else the program connects to. Add them in OnConfigureTrust, or
   name a file in ExtraAnchorFile:

       lRest.BaseURL := 'https://api.example.com';
       lRest.OnConfigureTrust := ConfigureTrust;   { add your anchors here }
       lRest.OnAuthorization := Authorization;     { 'Bearer ...' }

   RevocationChecking selects how a certificate's revocation status is treated:
   rvcSoft accepts a status that cannot be obtained, rvcHard refuses it, and
   rvcOff does not ask. Soft is the default, which is what a public API
   normally wants.

   THREE WAYS IN, AND THE DIFFERENCE MATTERS. Execute adds the authorization
   header the component supplies, and on a 401 asks for a fresh credential once
   and repeats the request. ExecuteJson does that and parses the answer.
   ExecuteRaw takes an explicit authorization header and never retries, which is
   what a token request itself uses - otherwise fetching a token would recurse
   through the very event that asks for one.

   EVERY EXTENSION POINT IS BOTH A VIRTUAL METHOD AND AN EVENT, so a dropped
   component and a subclass are equally first-class: ConfigureTrust /
   OnConfigureTrust, AuthorizationHeader / OnAuthorization, and Reauthorize /
   OnReauthorize, which decides whether a 401 is worth retrying and clears the
   cached credential.

   Header names go on the wire in lower case, always. HTTP/1.1 does not care;
   HTTP/2 rejects anything else, and a client that worked until the server
   negotiated h2 is the kind of fault that is found in production rather than
   in testing. IdempotencyHeader names the key header, so a service that spells
   it its own way needs no code.

56. NEW - TsmRESTServer: the server counterpart of TsmRESTClient

   StreamSec.Http.RestServer answers a JSON-REST API on the HTTPS server the
   way TsmRESTClient calls one. It is a component that MOUNTS on the HTTP
   router rather than occupying a path in it, so the recommended wiring - one
   router shared by TsmHTTPSv1dot1 and TsmHTTPSv2 - means a single REST server
   pointed at either of them answers HTTP/1.1 and HTTP/2 alike.

   What it supplies is what a REST API otherwise re-implements per project:
   routes with captured path segments ('/orders/{id}'), 404 / 405-with-allow /
   204-for-OPTIONS resolution, JSON request bodies validated before a handler
   sees them, RFC 9457 application/problem+json errors, an authentication
   seam, and idempotency.

   Drop it, set Protocol to either HTTPS component, and register routes:

       lRest.Protocol := lHttp11;         { or lHttp2 - one router, both wires }
       lRest.BasePath := '/api';
       lRest.AddRouteEvent('GET', '/orders/{id}', Form1.GetOrder);
       lRest.AddRoute('POST', '/orders', lCreateHandler);   { iRestHandler }

   A handler receives the decoded captures, the parsed body and the
   authenticated principal, and answers with SendJson, SendCreated,
   SendNoContent or SendProblem. Everything the shared core already offered -
   headers, cookies, session, and what the TLS handshake decided, including a
   client certificate - remains reachable through the request.

   THE TWO HALVES ARE DESIGNED TO MEET. The client's idempotency header and
   the server's default to the same name, so a client that sends a key gets
   deduplication without either side being configured: a repeated key replays
   the first answer verbatim rather than executing twice, a duplicate that
   arrives while the first is still running is refused 409, and a 5xx is never
   stored, so a retry after a transient failure really does retry. The
   client's single re-authenticate-and-retry on 401 lands on the server's own
   401. Both sides emit lowercase header names, which HTTP/2 requires and
   HTTP/1.1 does not mind.

   AUTHENTICATION IS DENY-BY-DEFAULT ONCE CONFIGURED. With no OnAuthenticate
   handler and no override the API is open, which is what an unconfigured
   component should be. The moment a policy exists, the request is refused
   unless the policy allows it - so a handler that forgets a case denies
   rather than admits. It runs before the request body is parsed, and a route
   may be marked exempt for health checks. For mTLS, authorize on the issuer
   and serial number of the client certificate rather than on a rendered
   distinguished name.

   A CAPTURED SEGMENT IS DECODED AFTER THE PATH IS SPLIT, never before, so an
   encoded separator stays data: '/orders/17%2F3' is one identifier reading
   '17/3', not two path segments. That ordering is the reason the library
   leaves paths raw everywhere else, applied here.

   The bundled idempotency store keeps its entries in memory, with a one-hour
   lifetime and a bound on how many it will hold. Replay protection therefore
   ends when the process does; iRestIdempotencyStore is the seam to implement
   over a durable store when that matters.

   Registering a mount needed one addition to the shared core:
   iHttpPrefixRouter, an optional companion interface on the router reached
   with Supports. It is separate from iHttpRouter rather than added to it
   because iHttpRouter is a published contract and extending it would break
   every implementation outside this library at once. A prefix matches on path
   segment boundaries only, and an exact route still wins - so a static file
   or a health endpoint may live inside a REST server's subtree.

57. FIXED - status codes the library itself sends now carry their reason phrase

   HttpReasonPhrase knew twenty-two status codes and fell back to the literal
   text 'Status <n>' for the rest. Several codes the library sends were in
   that remainder, so a correct response carried a meaningless reason phrase -
   most visibly 416, which SendFileRange has been answering since it was
   written, and which read as 'Status 416' in the HTTP/1.1 status line and in
   any error document built from the phrase.

   The table now covers the codes this library produces, 416 among them, plus
   the ordinary REST statuses (409, 415, 422, 429 and the rest). Nothing about
   the fallback changed: a code outside the table still renders as before.

   HTTP/2 carries no reason phrase at all, so this is visible on HTTP/1.1 and
   in anything that formats a phrase for itself.

58. FIXED - an EdDSA private key written as unencrypted PKCS#8 could not be
    read back

    Saving an Ed25519 or Ed448 key through PKCS8-Plain-EdDSA or
    PKCS8-Plain-PEM-EdDSA produced a correct file - other implementations read
    it - but loading that file again through the PEM form of either failed. The
    key came back with an empty seed, reported as 'tEdDSAPrivateKey: the seed
    must be 32 bytes'.

    RFC 8410 carries the seed in a CurvePrivateKey OCTET STRING nested inside
    the privateKey OCTET STRING. That inner value is not resolved while the
    structure is still open for editing, and this one loader did not close it,
    so the seed read as empty. The encrypted EdDSA loader, the RSA loader and
    the SubjectPublicKeyInfo loaders all did.

    It affected any application that persists an EdDSA key and reloads it on the
    next start - a DKIM signing key above all, which has to outlive the process
    for its published DNS record to stay valid.

59. NEW - TsmCCADBTrustAnchors: the public root set, compiled in

    A client that must verify a server it did not choose - an MX host, an
    MTA-STS policy endpoint, a URL it was handed - needs the public roots, and
    until now every such application had to be handed them as a file. That is
    the weakest part of the arrangement: the file comes from somewhere nobody
    recorded, an application pointed at the wrong one trusts the wrong issuers,
    and one pointed at nothing trusts none and fails every handshake for a
    reason its log never mentions.

    IT IS FOR THE CASE WHERE THE ANCHOR CANNOT BE SETTLED EARLIER, and only
    that case. If the program chose the authority at COMPILE time, compile that
    one root in. If the operator can name it at CONFIGURATION time, let them
    name it. A certificate in a store anchors everything that store validates,
    so a public set does not buy trust in one destination: it lets every
    authority in the set vouch for every peer that engine ever verifies. What
    this set answers is the question a program cannot answer earlier, because
    the peer is not known until run time - the MX host for a recipient domain
    that arrived with a message, that domain's policy host, a URL it was
    handed. WHAT ARRIVES LATE IS THE PEER, NOT THE ANCHORS: they still go in
    while the form loads, and "only at run time" is never a reason to install
    trust late.

    TsmCCADBTrustAnchors carries the set in the library. Point Engine at a TLS
    engine and the roots are installed when loading finishes, which is before
    the application's own TLSSetupClient and before anything has connected -
    where anchors want to be. Clear
    AutoInstall to install by hand instead, and for an engine built at run time
    with nothing to drop a component beside, the plain function AddCCADBRoots
    does the same work. Install and AddCCADBRoots both return how many roots
    went in, and the Installed property reports it afterwards.

    ONE INSTANCE PER TRUST DOMAIN, and the component shape is what makes that
    natural. The same list means different things in different places: on a
    client leg it says which servers may prove who they are, but on a LISTENER
    the root list is also the anchor set for CLIENT certificates, so installing
    public roots there would make every certificate any public CA ever issued a
    valid credential against that server. There is deliberately no process-wide
    default and no fallback engine.

    THE SET IS DATED. Established reports the day the embedded list was taken,
    Source the URL it came from, and RootCount how many roots that is - class
    functions over compile-time constants, so a program can log all three
    without holding an instance. A root program removes CAs as well as adding
    them, so a compiled-in list is a statement about a moment; an application
    that logs Established gives an operator the one fact needed to judge
    whether a build has grown too old to be believed.

    Failures are reported through OnProblem, naming the CA, and never raised: a
    program holding all but one of the roots is a working program, and a silent
    count of zero is the failure the design exists to make visible.

    The unit is in the contains clause of all fourteen runtime packages, and
    all fourteen design packages put the component on the StreamSec Mobile
    palette page.

60. NEW - stVersion: the library's own version, as a compiled-in constant

   The release number was reachable only from the name of the distribution
   archive and the top of this file. stVersion carries it in the library:

       cStreamSecToolsVersion   '4.1.2.355'
       cStreamSecToolsMajor     4     cStreamSecToolsRelease   2
       cStreamSecToolsMinor     1     cStreamSecToolsBuild     355
       cStreamSecToolsProduct   'StreamSec Tools'
       cStreamSecToolsVendor    'StreamSec HB'

   StreamSecToolsAtLeast compares against them, so code can gate on a
   version without parsing a string:

       if StreamSecToolsAtLeast(4,1,2) then ...

   The unit also carries the identity an application needs when it must
   declare this library as a component of its own software bill of
   materials - a package URL and a licence reference - and
   gStreamSecToolsBanner, which puts the product name and version into the
   linked image so a shipped executable can be identified by inspection.

   A version string belongs to exactly one distribution archive and is never
   reused.

   The unit is in the contains clause of all fourteen runtime packages.

--------------------------------------------------------------------------------
 THE SOCKET LAYER
--------------------------------------------------------------------------------

61. The Winsock declarations are now the library's own

   On Windows the socket layer takes its Winsock 2 declarations from a single
   unit, stWinsock2 - an independent translation of the Windows SDK headers
   winsock2.h, ws2def.h, ws2ipdef.h and ws2tcpip.h. It replaces three
   third-party units that the library carried under a separate licence:
   stJwaWinsock2, stJwaWS2tcpip and stJwaQos.

   Nothing in your own code has to change for this. The names are Microsoft's
   and are unchanged, as are the record layouts, so anything that referred to
   TSocket, TSockAddrIn, PSockAddr or the WSA* routines compiles against the
   same declarations it had before. What changes is which unit supplies them:

       uses ... stJwaWinsock2, stJwaWS2tcpip;   ->   uses ... stWinsock2;

   The three replaced units are still distributed and still compile. They are
   marked deprecated, so a uses clause that names one is reported (W1006)
   rather than broken, and they are in no package - a project that still wants
   them compiles them from source. Being self-contained, they declare their
   own types: use one set or the other within a unit, not both.

   stWinsock2 covers the stream and datagram paths, name resolution (including
   inet_pton, inet_ntop and getnameinfo), overlapped I/O, the readiness
   mechanisms, and the fragmentation and ICMP-reset controls a datagram
   service needs on Windows. It is not the whole of winsock2.h: the WSAAsync*
   and WSAService* families, protocol enumeration, multicast group management
   and the QOS structures are absent. Code that used one of those can keep the
   deprecated unit or declare what it needs.

   Two record layouts are corrected for 64-bit Windows along the way. servent
   places s_proto before s_port there, and the replaced declaration carried
   only the 32-bit order, so s_port overlapped half of a pointer:
   tWinSocket.LookupService returned a meaningless number for every service
   name on Win64. WSAData is reordered on Win64 in the same way; nothing reads
   its fields, so that one had no visible effect.

62. FIXED - a socket could only be opened to an address, not to a host name

   tAbstractSocket.Open resolves a host name, so a name may be given wherever
   an address literal could be given:

       lSocket.Open('www.example.com',443);

   The address used to be handed straight to the platform's literal parser -
   IsIP/IsIP6 on Windows, inet_pton on POSIX - and anything that was not an
   address raised before a packet was sent. Every client component in the
   library resolves first to work around that: TsmTLSClient, the SSH clients
   and the OCSP and HTTP clients all call LookupHost themselves. TsnipTLSClient
   does not, so its Host property - documented to prefer a DNS name, since that
   name is also what the server certificate must match - accepted an address
   and nothing else, and ServerName had to be set by hand alongside it.

   The widening is confined to the connect path. Listen is untouched and still
   binds a literal, because a bind address names a local interface and
   resolving one would let a name decide which interface a server listens on.
   A caller that resolves its own address takes exactly the route it took
   before - a literal never reaches the resolver - and a name that does not
   resolve raises the same error it always did rather than a new one.

--------------------------------------------------------------------------------
 TLS DEFAULTS
--------------------------------------------------------------------------------

63. BEHAVIOUR CHANGE - TTLSOptions defaults to the hardened profile

   A newly created TLS engine no longer offers the CBC record ciphers, triple
   DES, RC4, static RSA key transport, or MD5 and SHA-1 as handshake hashes.
   What remains is the AEAD suites over an ephemeral key agreement - ECDHE
   preferred, DHE allowed - together with the named groups a current peer
   offers, now including the post-quantum hybrids.

   This is what an external TLS scanner grades. A server left on the previous
   defaults was marked down on several counts at once, any one of which was
   enough on its own: no forward secrecy on the static key agreements, and
   primitives no longer accepted for the rest. A deployment that had already
   set these properties by hand is unaffected, because it was setting them to
   these values.

   WHAT YOU LOSE is a peer that has nothing else to offer. Every current
   browser and library negotiates one of the remaining suites first, so the
   handshake that changes is the one with software old enough to be limited to
   3DES or a CBC suite. Set the property back if you have such a peer:

       Options.BulkCipherAES128 := prAllowed;    { AES-128-CBC }
       Options.BulkCipherTripleDES := prAllowed;

   THE PUBLISHED PROPERTIES NO LONGER CARRY A default SPECIFIER, which changes
   what is written to a .dfm rather than what any of them do. A value equal to
   the specifier used to be omitted from the form file and then came back as
   whatever the constructor had set - so a property the designer showed as off
   could load as on. Every one of them is now streamed explicitly. Existing
   .dfm files load exactly as before; the difference appears the next time a
   form is saved.

================================================================================
 End.
================================================================================