Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Mobile.StreamSecII

Feature notes: TLS implementation notes (RFC map)

Classes, interfaces and records

classEStreamSecII

inherits from ESecComp

Raised by the StreamSecII component and the private key ring it owns, for a configuration or key-store problem. Descends from ESecComp (StreamSec.Mobile.SecComp), the base of the component layer's exceptions.

(no public members)

classTTLSOptions

inherits from TPersistent

constructor Create(AOwner: TComponent);
Internal wiring: this options object is created and owned by its parent TsmStreamSecII (passed as AOwner) - applications reach a live instance via the component's TLSOptions property rather than constructing one.
destructor Destroy; override;
Frees the internal CipherSuiteNames list. Called by the owning TsmStreamSecII when it is destroyed - applications do not free this object themselves.
procedure BeginUpdate;
Call BeginUpdate before changing several algorithm-preference properties in a batch and EndUpdate afterwards: this suppresses the intermediate OnChange notifications (and the cipher-suite recomputation they drive) so the list is rebuilt only once, when the outermost EndUpdate runs.
procedure EndUpdate;
Closes a BeginUpdate batch; the outermost EndUpdate fires the deferred OnChange and rebuilds the cipher-suite list once. Pair exactly one EndUpdate with each BeginUpdate (calls nest via a counter).
function GetNamedPropValue(const APropName: string): Integer;
Read/write a published preference property by its name via RTTI, returning or setting its ordinal value. Handy for generic UI/config code that iterates option names without a compile-time reference to each property.
procedure SetNamedPropValue(const APropName: string; AValue: Integer);
The write half of the RTTI accessor pair: sets the named published preference property to the ordinal AValue. Used by the same generic UI/config code that assigns options by name rather than by a compile-time reference.
function ComputeTls13SigSchemes: tBytes;
TLS 1.3 (NEW): the enabled non-classical SignatureSchemes as 2-byte big-endian codepoints in descending preference order (prPrefer before prAllowed; prNotAllowed omitted). Currently emits the EdDSA (SignatureEdDSA) and ML-DSA (SignatureMLDSA) schemes and opt-in experimental private-use Composite ML-DSA profiles. Fed to the content layer's Tls13SigSchemes for offering + accept gating.
property CipherSuites: TCipherSuites read FCipherSuites write SetCipherSuites;
The raw, ordered list of two-byte cipher-suite codepoints derived from the algorithm-preference properties below (recomputed whenever any of them changes). Read it to inspect exactly what will be offered/accepted; assign it to override the auto-computed list with an explicit hand-picked set. This is the non-published counterpart of the CipherSuiteNames display list.
property AllowDualSockets: Boolean read FDualSockets write SetDualSockets;
Deprecated - do not copy. When set it maps to the content layer's AcceptHelloRequest (legacy renegotiation-as-server behaviour); leave False.
property BulkCipherAES128: TPreference read FBulkCipherAES128 write SetBulkCipherAES128;
BulkCipher* : per-algorithm preference (prNotAllowed/prAllowed/prPrefer) for the record-layer symmetric cipher. Full description »
property BulkCipherAES192: TPreference read FBulkCipherAES192 write SetBulkCipherAES192;
AES-192-CBC - rarely used (standard stacks offer only 128/256). prNotAllowed by default; enable only for a peer that specifically needs a 192-bit key.
property BulkCipherAES256: TPreference read FBulkCipherAES256 write SetBulkCipherAES256;
AES-256-CBC record cipher (non-AEAD, TLS 1.2 and earlier); prNotAllowed by default. Enable only for a peer that cannot do AEAD; it then ranks below the GCM/ChaCha suites.
property BulkCipherAES128GCM: TPreference read FBulkCipherAES128GCM write SetBulkCipherAES128GCM;
AES-128-GCM AEAD; a preferred modern suite and one of the TLS 1.3 record ciphers. Keep at prPrefer for a hardened profile.
property BulkCipherAES256GCM: TPreference read FBulkCipherAES256GCM write SetBulkCipherAES256GCM;
AES-256-GCM AEAD; a preferred modern suite, also used by TLS 1.3. prPrefer by default.
property BulkCipherChaCha20Poly1305: TPreference read FBulkCipherChaCha20Poly1305 write SetBulkCipherChaCha20Poly1305;
ChaCha20-Poly1305 AEAD (RFC 7905 / TLS 1.3); preferred by default and the fastest choice on CPUs without AES hardware.
property BulkCipherAES128CTR: TPreference read FBulkCipherAES128CTR write SetBulkCipherAES128CTR;
AES-128 in counter mode - a StreamSec extended (non-IANA) suite, in effect only when OnlyStandardCipherSuites is False. Off by default; leave off for third-party interop.
property BulkCipherAES192CTR: TPreference read FBulkCipherAES192CTR write SetBulkCipherAES192CTR;
AES-192-CTR - StreamSec extended (non-IANA) suite, usable only when OnlyStandardCipherSuites is False. Off by default.
property BulkCipherAES256CTR: TPreference read FBulkCipherAES256CTR write SetBulkCipherAES256CTR;
AES-256-CTR - StreamSec extended (non-IANA) suite, usable only when OnlyStandardCipherSuites is False. Off by default.
property BulkCipherTwoFish128: TPreference read FBulkCipherTwoFish128 write SetBulkCipherTwoFish128;
Deprecated - leave prNotAllowed. Twofish-128 record cipher - a StreamSec extended (non-IANA) suite, usable only when OnlyStandardCipherSuites is False. Off by default.
property BulkCipherTwoFish192: TPreference read FBulkCipherTwoFish192 write SetBulkCipherTwoFish192;
Deprecated - leave prNotAllowed. Twofish-192 - StreamSec extended (non-IANA) suite, usable only when OnlyStandardCipherSuites is False. Off by default.
property BulkCipherTwoFish256: TPreference read FBulkCipherTwoFish256 write SetBulkCipherTwoFish256;
Deprecated - leave prNotAllowed. Twofish-256 - StreamSec extended (non-IANA) suite, usable only when OnlyStandardCipherSuites is False. Off by default.
property BulkCipherTwoFish128CTR: TPreference read FBulkCipherTwoFish128CTR write SetBulkCipherTwoFish128CTR;
Deprecated - leave prNotAllowed. Twofish-128 in counter mode - StreamSec extended (non-IANA) suite, usable only when OnlyStandardCipherSuites is False. Off by default.
property BulkCipherTwoFish192CTR: TPreference read FBulkCipherTwoFish192CTR write SetBulkCipherTwoFish192CTR;
Deprecated - leave prNotAllowed. Twofish-192-CTR - StreamSec extended (non-IANA) suite, usable only when OnlyStandardCipherSuites is False. Off by default.
property BulkCipherTwoFish256CTR: TPreference read FBulkCipherTwoFish256CTR write SetBulkCipherTwoFish256CTR;
Deprecated - leave prNotAllowed. Twofish-256-CTR - StreamSec extended (non-IANA) suite, usable only when OnlyStandardCipherSuites is False. Off by default.
property BulkCipherBlowFish128: TPreference read FBulkCipherBlowFish128 write SetBulkCipherBlowFish128;
Blowfish-128 record cipher - a StreamSec extended (non-IANA) suite, usable only when OnlyStandardCipherSuites is False. Off by default.
property BulkCipherBlowFish128CTR: TPreference read FBulkCipherBlowFish128CTR write SetBulkCipherBlowFish128CTR;
Blowfish-128 in counter mode - StreamSec extended (non-IANA) suite, usable only when OnlyStandardCipherSuites is False. Off by default.
property BulkCipherARC4: TPreference read FBulkCipherARC4 write SetBulkCipherARC4;
RC4 stream cipher - cryptographically broken; prNotAllowed by default. Enable only to interoperate with obsolete peers.
property BulkCipherTripleDES: TPreference read FBulkCipherTripleDES write SetBulkCipherTripleDES;
3DES-CBC - a slow legacy 64-bit-block cipher (Sweet32-exposed); prNotAllowed by default. Enable only to interoperate with obsolete peers.
property CipherSuiteNames: TStrings read FCipherSuiteNames write SetCipherSuiteNames stored False;
Auto generated - do not copy. Read-only human-readable names of the currently computed CipherSuites, for display/logging; the setter is a no-op.
property EphemeralDHKeySize: Integer read FEphemeralDHKeySize write SetEphemeralDHKeySize;
Bit-size of the ephemeral finite-field Diffie-Hellman group the SERVER generates for DHE key agreement (client side ignores it). Raise it for stronger PFS at the cost of slower handshakes; changing it recomputes the cipher-suite list.
property EphemeralDHQSize: Integer read FEphemeralDHQSize write SetEphemeralDHQSize;
Bit-size of the DHE subgroup order (q) paired with EphemeralDHKeySize on the SERVER; rarely changed.
property EphemeralECDHKeySize: TECKeySize read FEphemeralECDHKeySize write SetEphemeralECDHKeySize;
deprecated - use SupportedGroups. Single ECDHE curve selector (ecsAuto picks by cipher strength); superseded by the SupportedGroups set.
property SupportedGroups: TECKeySizes read FSupportedGroups write SetSupportedGroups;
The set of named groups offered for key agreement, both in the TLS 1.2 supported_groups extension and as TLS 1.3 key_share candidates. Full description »
property HashAlgorithmMD5: TPreference read FHashAlgorithmMD5 write SetHashAlgorithmMD5;
HashAlgorithm* : per-digest preference feeding both the legacy cipher-suite MAC/PRF selection and the TLS 1.2 signature_algorithms hash choices. The weak legacy digests (MD5, SHA-1, RIPEMD-160) are prNotAllowed by default; changing any recomputes the cipher-suite list.
property HashAlgorithmSHA1: TPreference read FHashAlgorithmSHA1 write SetHashAlgorithmSHA1;
SHA-1 for MAC/PRF and TLS 1.2 signature hashing. Weak; prNotAllowed by default. Enable only for a legacy peer that needs it.
property HashAlgorithmRipeMD160: TPreference read FHashAlgorithmRipeMD160 write SetHashAlgorithmRipeMD160;
RIPEMD-160 - a rarely-supported legacy digest; prNotAllowed by default.
property HashAlgorithmSHA256: TPreference read FHashAlgorithmSHA256 write SetHashAlgorithmSHA256;
SHA-256; the preferred modern digest (prPrefer by default) and the TLS 1.2 baseline.
property HashAlgorithmSHA384: TPreference read FHashAlgorithmSHA384 write SetHashAlgorithmSHA384;
SHA-384; used by the AES-256-GCM/SHA-384 suites. Allowed by default.
property HashAlgorithmSHA512: TPreference read FHashAlgorithmSHA512 write SetHashAlgorithmSHA512;
SHA-512; allowed by default for peers that offer it.
property KeyAgreementDH: TPreference read FKeyAgreementDH write SetKeyAgreementDH;
KeyAgreement* : per-mechanism preference for the (legacy 1.2 and earlier) key-exchange half of a cipher suite. The default is ECDHE only, at prPrefer; DHE, which RFC 10015 deprecates in TLS 1.2, and the static RSA, DH and ECDH ones are prNotAllowed. Changing any recomputes the cipher-suite list. Applies to both client (offer) and server (accept) sides.
property KeyAgreementDHE: TPreference read FKeyAgreementDHE write SetKeyAgreementDHE;
Ephemeral finite-field Diffie-Hellman (TLS 1.2 and earlier) - prNotAllowed by default: RFC 10015 bars the FFDHE suites in TLS 1.2. Enable only for a peer that offers nothing better.
property KeyAgreementECDH: TPreference read FKeyAgreementECDH write SetKeyAgreementECDH;
Static (non-ephemeral) elliptic-curve DH - no forward secrecy; prNotAllowed by default.
property KeyAgreementECDHE: TPreference read FKeyAgreementECDHE write SetKeyAgreementECDHE;
Ephemeral elliptic-curve DH - the preferred forward-secret key exchange (prPrefer by default).
property KeyAgreementRSA: TPreference read FKeyAgreementRSA write SetKeyAgreementRSA;
Static RSA key transport - no forward secrecy; prNotAllowed by default. Enable only for a legacy peer that offers nothing forward-secret.
property OnlyStandardCipherSuites: Boolean read FOnlyStandardCipherSuites write SetOnlyStandardCipherSuites;
When True (default) only IANA-registered cipher suites are considered; set False to also enable StreamSec's private/experimental extended suites (the $FF-prefixed range in ComputeCipherSuites). Leave True for interoperability with third-party peers.
property RequestClientCertificate: Boolean read FRequestClientCertificate write SetRequestClientCertificate;
SERVER-side: when True the server sends a CertificateRequest asking the client for a certificate (mutual TLS). Has no effect client-side. Pair with RequireClientCertificate to decide whether a missing client cert is fatal.
property RequireClientCertificate: Boolean read FRequireClientCertificate write SetRequireClientCertificate;
SERVER-side: when True (default) a requested-but-absent or unverifiable client certificate aborts the handshake; when False the connection may proceed anonymously. Only meaningful together with RequestClientCertificate.
property RequireEncryptedClientCertificate: Boolean read FRequireEncryptedClientCertificate write SetRequireEncryptedClientCertificate;
SERVER-side hardening: require the client certificate to be delivered inside the encrypted part of the handshake (rather than in the clear). Default False; enable only when the peer supports it.
property RequireHostNameExtension: Boolean read FRequireHostNameExtension write SetRequireHostNameExtension;
SERVER-side: when True, refuse a ClientHello that carries no Server Name Indication (or no matching name) instead of falling back to a default/ no-name certificate - used for SNI-based virtual hosting where an unnamed request must not be served.
property SecureRenegotiation: Boolean read FSecureRenegotiation write SetSecureRenegotiation;
When True (default) require RFC 5746 secure renegotiation; a peer that does not advertise it is rejected on renegotiation. Leave True to avoid the classic renegotiation attack.
property ServerSelectsCipherSuite: Boolean read FServerSelectsCipherSuite write SetServerSelectsCipherSuite;
SERVER-side selection policy. When True the server picks the suite by its own CipherSuites preference order (server preference); when False it honours the client's order, only filtering against its accepted set. Set True to enforce a server-driven hardened ordering.
property SignatureAnon: TPreference read FSignatureAnon write SetSignatureAnon;
Signature* : per-algorithm preference for the certificate/handshake authentication algorithm. prNotAllowed drops suites/schemes using it, prPrefer orders them first. These gate both the offered signature_algorithms and the acceptable peer signatures.
property SignatureDSS: TPreference read FSignatureDSS write SetSignatureDSS;
DSA/DSS certificate authentication - legacy (FIPS 186-5 keeps DSA for verification only); prNotAllowed by default. Requires a DSA leaf certificate and a DHE_DSS suite.
property SignatureECDSA: TPreference read FSignatureECDSA write SetSignatureECDSA;
ECDSA certificate/handshake authentication; requires an EC (ECDSA) leaf certificate. Set prNotAllowed to exclude the EC suites.
property SignatureRSA: TPreference read FSignatureRSA write SetSignatureRSA;
RSA certificate authentication - the most widely deployed; preferred by default. Requires an RSA leaf certificate.
property SignatureEdDSA: TPreference read FSignatureEdDSA write SetSignatureEdDSA;
EdDSA (ed25519/ed448) is an RFC 8446 standard TLS 1.3 signature scheme, allowed (offered and accepted) by default. Unlike the classic Signature* above it does not affect the legacy 1.2 cipher-suite computation - it feeds ComputeTls13SigSchemes only.
property SignatureMLDSA: TPreference read FSignatureMLDSA write SetSignatureMLDSA;
Post-quantum ML-DSA TLS 1.3 signature scheme (draft codepoints), opt-in (prNotAllowed by default). Set prAllowed/prPrefer to offer/accept it; feeds ComputeTls13SigSchemes only, not the legacy cipher-suite list.
property SignatureCompositeMLDSA: TPreference read FSignatureCompositeMLDSA write SetSignatureCompositeMLDSA;
Composite ML-DSA (classical + ML-DSA) TLS 1.3 signature scheme on private-use codepoints, opt-in (prNotAllowed by default). TLS 1.3 only; independent of the legacy cipher-suite computation.
property EarlyData: TEarlyDataMode read FEarlyData write SetEarlyData;
EARLY DATA (NEW): TLS 1.3 0-RTT. EarlyData is the server accept/reject policy; MaxEarlyDataSize is advertised in issued session tickets. Both default to the safe behaviour (no 0-RTT) so existing deployments are unaffected. The matching OnTLSEarlyData/OnTLSEndOfEarlyData/ OnTLSCheckEarlyDataReplay events live on the owning component.
property MaxEarlyDataSize: Cardinal read FMaxEarlyDataSize write SetMaxEarlyDataSize;
SERVER-side 0-RTT cap: the max_early_data_size (bytes) advertised in issued NewSessionTickets, bounding how much 0-RTT data a resuming client may send. Only meaningful when EarlyData permits 0-RTT; 0 disables it.
property SessionResumption: Boolean read FSessionResumption write SetSessionResumption;
TLS 1.3 PSK session resumption (RFC 8446 sec.2.2). True (default): the server issues NewSessionTickets and resumes valid ones, the client offers stored tickets. Full description »
property SessionTicketCount: Cardinal read FSessionTicketCount write SetSessionTicketCount;
TLS 1.3 NewSessionTicket batch size (SERVER). Each 1-RTT handshake issues this many single-use tickets, so a resuming client has one per parallel connection. Default 6 = the per-host connection limit contemporary browsers apply to HTTP/1.1. Clamped to [1,255]; ignored when SessionResumption=False.
property VerifyServerName: TVerifyServerName read FVerifyServerName write SetVerifyServerName;
CLIENT-side: which identity forms in the server certificate must match the requested host - the set of IP address, DNS name and/or URI SubjectAltName checks performed during peer validation (default: all three). Narrow it if the app validates the name itself, or to relax a specific check.
property OnChange: TNotifyEvent read FOnChange write SetOnChange;
Fired whenever a preference changes and the cipher-suite list is recomputed (respecting BeginUpdate/EndUpdate batching). The owning component hooks this to react to configuration edits; applications rarely assign it directly.

classTsmStreamSecII — component reference

(no public members)

classTTLSSession

inherits from TCustomTLSSession

constructor Create(AOwner: TsmStreamSecII); destructor Destroy; override; function IsExpired: Boolean; override;
Returns True if FLastAccess + FOwner.SessionKeyLifeSpan is less than Now; otherwise False.

classTsmCertificateObject

inherits from TObject

A wrapper that lets an iCertificate travel as the Object of a TStrings entry (TStrings.Objects is a TObject, not an interface). Returned by FindExpiringTLSServerCertificatesEx. THE CALLER OWNS THESE OBJECTS: the simplest way is to pass a TStringList created with OwnsObjects := True, so the list frees each wrapper when it is cleared or freed; otherwise free aList.Objects[i] yourself.

constructor Create(const aCertificate: iCertificate); property Certificate: iCertificate read FCertificate;

classTTls13ServerTicket

TLS 1.3 (NEW, task 11): server-side resumption ticket state. The server keeps these in memory keyed by the opaque Identity it issued; on resumption it recovers the PSK (and the binding metadata) by looking up the identity the client echoes in pre_shared_key. NamedGroup binds the ticket to the group negotiated when it was issued: a resumption whose key_share group differs is rejected (never HelloRetryRequest-ed), per the design hardening.

function Clone: TTls13ServerTicket;
Detached deep copy (incl. the PSK) a caller owns and frees. Used so the resumption path can read fields + verify the binder off a private copy without holding the store lock across the crypto, and without a use-after-free if a concurrent single-use consume frees the stored original.
destructor Destroy; override;

interfaceiTls13TicketStore

WHERE SERVER-SIDE RESUMPTION TICKETS LIVE.

Shaped so the same interface serves an in-process list, one store shared by every engine shard, and an out-of-process store behind Redis or a database - which is why Consume is a QUESTION, not a command. That single method is the whole of single-use anti-replay: two handshakes can both Peek the same identity and both verify its binder, because the binder crypto deliberately runs without the store lock, so what decides which of them owns the ticket is which one's Consume answers True.

IMPLEMENTATIONS MUST BE THREAD-SAFE. A store handed to several engines is reached from every I/O thread at once, and the async TLS server drives handshakes with no shard lock.

Ticket lifetime is the store's business: Put may reap, and PruneExpired is the explicit hook a long-running server calls.

procedure Put(aTicket: TTls13ServerTicket);
Hand a freshly issued ticket to the store, which TAKES OWNERSHIP.
function Peek(const aIdentity: TBytes): TTls13ServerTicket;
A detached CLONE of the ticket for aIdentity, or nil. The caller owns and frees it. Never removes anything - so an identity echoed in cleartext cannot burn a ticket, which is why the handshake peeks first and claims only after the binder verifies.
function Find(const aIdentity: TBytes): TTls13ServerTicket;
The STORED instance for aIdentity, or nil. The caller must NOT free or modify it - a store may index its Identity and its expiry - and it is valid only while no concurrent Consume runs, so prefer Peek. An out-of-process store answers nil: it has no in-process instance to lend.
function Consume(const aIdentity: TBytes): Boolean;
THE ATOMIC CLAIM. True: this caller removed the ticket and may resume. False: it was already gone - expired, reaped, or claimed by a concurrent handshake - and the caller MUST fall back to a full handshake. False is an ordinary outcome, not an error.
procedure PruneExpired;
Drop everything past its lifetime.
function Count: Integer;
Unexpired tickets held. Diagnostic; racy by nature under concurrency.
function Capabilities: tTicketStoreCapabilities;
What this store can promise - read before enabling 0-RTT.

classtTls13MemoryTicketStore

inherits from TInterfacedObject

implements iTls13TicketStore

The default store, and the one every TsmStreamSecII creates for itself: an in-memory store behind its own lock.

IT HAS ITS OWN LOCK, deliberately not the engine's TLSLock. A store shared by several engines cannot borrow any one engine's lock, and the finer grain is free - nothing needs the session table and the ticket list to move together.

SHARE ONE OF THESE ACROSS SHARDS and resumption stops depending on which shard the client lands on. See TsmAsyncTLSServer.SharedTicketStore, which does exactly that.

NO OPERATION SCANS THE TICKETS. A server keeps every ticket it issues for the ticket's lifetime, SessionTicketCount of them per handshake, so the store holds tickets in proportion to the handshake RATE, and every shard waits on this one lock. An identity is found through a hash index, and expiry is ordered by a binary heap on each ticket's expiry time, so reaping costs a logarithm per ticket reaped and nothing for the tickets still live. The exception is the Put that finds the store full, which doubles its arrays and walks every identity chain once - a pause proportional to what is held, as many puts apart as there are tickets - and the removal that halves them once three quarters are gone. The heap orders by expiry and not by the order tickets were put because the two need not agree: a store accepts any lifetime, and CreatedAt is local wall-clock time, which steps back. Of two tickets put under one identity, the later is found first.

constructor Create; destructor Destroy; override; procedure Put(aTicket: TTls13ServerTicket); function Peek(const aIdentity: TBytes): TTls13ServerTicket; function Find(const aIdentity: TBytes): TTls13ServerTicket; function Consume(const aIdentity: TBytes): Boolean; procedure PruneExpired; function Count: Integer; function Capabilities: tTicketStoreCapabilities;

classTsmPrivateKeyRingComponent — component reference

(no public members)

classTPrivateKeyRing

constructor Create(AOwner: TsmPrivateKeyRingComponent); destructor Destroy; override; function AddPrivateDLKey(const PrivKey: iDLPrivateKey; const PublicKeyIdentifier: OctetString): Integer; function AddPrivateECKey(const PrivKey: iDLPrivateKey; const PublicKeyIdentifier: OctetString): Integer; function AddPrivateRSAKey(const PrivKey: iIFPrivateKey; const PublicKeyIdentifier: OctetString): Integer; function AddPrivateMLDSAKey(const PrivKey: iMLDSAPrivateKey; const PublicKeyIdentifier: OctetString): Integer; function AddPrivateCompositeMLDSAKey(const PrivKey: iCompositeMLDSAPrivateKey; const PublicKeyIdentifier: OctetString): Integer;
Registers an experimental composite TLS 1.3 identity without converting it to either of its component key families.
function AddPrivateMLKEMKey(const PrivKey: iMLKEMPrivateKey; const PublicKeyIdentifier: OctetString): Integer; function CreateKeyPairIF(const Algorithm: ObjectIdentifier; KeySize: Cardinal; const PublKey: ISubjectPublicKeyInfo; SignatureDigestAlg: THashAlgorithm = haSHA1; Exportable: Boolean = False): iIFPrivateKey; function CreateKeyPairDL(const Algorithm: ObjectIdentifier; PSize: Cardinal; QSize: Cardinal; const PublKey: ISubjectPublicKeyInfo; SignatureDigestAlg: THashAlgorithm = haSHA1): iDLPrivateKey; function CreateKeyPairEC(const Algorithm: ObjectIdentifier; Curve: ObjectIdentifier; const PublKey: ISubjectPublicKeyInfo; SignatureDigestAlg: THashAlgorithm = haSHA1): iDLPrivateKey; function CreateKeyPairMLDSA(const Algorithm : ObjectIdentifier; const PublKey : iSubjectPublicKeyInfo; SignatureDigestAlg: tHashAlgorithm = haDefault; SaveSeed : Boolean = False) : iMLDSAPrivateKey; function CreateKeyPairMLKEM(const Algorithm : ObjectIdentifier; const PublKey : iSubjectPublicKeyInfo; SaveSeed : Boolean = False) : iMLKEMPrivateKey; function FindCreatePrivateKeyObj(const Cert: iCertificate; TLS: Boolean = False): iMPPrivateKey; overload; function FindCreatePrivateKeyObj(const PublicKeyIdentifier: OctetString; TLS: Boolean = False): iMPPrivateKey; overload; property LongTermKeyCount: Integer read GetLongTermKeyCount; property LongTermKeys[index: Integer]: iMPPrivateKey read GetLongTermKeys;

classTsmPrivateKeyRingComponent — component reference

inherits from TsmKeyRingComponent

constructor Create(AOwner: TComponent); override;
Creates the component and its own private key ring. An application uses the registered component at design time or constructs it in code to hold the private keys that pair with its certificates. » member page
destructor Destroy; override;
Detaches from any chained PrivateKeyRing and frees this component's own key ring. Standard teardown; applications rarely call it directly. » member page
function AddPrivateDLKey(const PrivKey: iDLPrivateKey; const PublicKeyIdentifier: OctetString): Integer;
Registers a discrete-log (DSA/DH/Nyberg-Rueppel) private key under the given PublicKeyIdentifier so it can later be matched to a certificate. Use this when you already hold an iDLPrivateKey object (e.g. loaded from a key file) rather than generating one via CreateKeyPair. Returns the new key count. » member page
function AddPrivateECKey(const PrivKey: iDLPrivateKey; const PublicKeyIdentifier: OctetString): Integer;
Registers an elliptic-curve private key under the given PublicKeyIdentifier. Same purpose as AddPrivateDLKey but for EC (ECDSA/ECDH) keys; the ring wraps it identically. Returns the new key count. » member page
function AddPrivateRSAKey(const PrivKey: iIFPrivateKey; const PublicKeyIdentifier: OctetString): Integer;
Registers an RSA (integer-factorization) private key under the given PublicKeyIdentifier. Use when importing an existing RSA key to pair with a certificate. Returns the new key count. » member page
function AddPrivateMLDSAKey(const PrivKey: iMLDSAPrivateKey; const PublicKeyIdentifier: OctetString): Integer;
Registers a post-quantum ML-DSA (FIPS 204) signature private key under the given PublicKeyIdentifier. Use when provisioning ML-DSA certificates/keys. Returns the new key count. » member page
function AddPrivateCompositeMLDSAKey(const PrivKey: iCompositeMLDSAPrivateKey; const PublicKeyIdentifier: OctetString): Integer;
Registers an experimental composite TLS 1.3 identity without converting it to either of its component key families. » member page
function AddPrivateMLKEMKey(const PrivKey: iMLKEMPrivateKey; const PublicKeyIdentifier: OctetString): Integer;
Registers a post-quantum ML-KEM (FIPS 203) key-encapsulation private key under the given PublicKeyIdentifier. Use when provisioning ML-KEM decapsulation keys. Returns the new key count. » member page
procedure ClearExpiredSessionKeys(aConservative: Boolean = True); virtual;
Virtual hook for pruning expired ephemeral session keys; the base implementation does nothing (TsmStreamSecII overrides it to clear the actual TLS session cache). Applications normally do not call this directly on the base key-ring component. » member page
function CreateKeyPair(const DstCert: iCertificate; const Algorithm: ObjectIdentifier; ABitSize: Integer; const CurveOID: ObjectIdentifierString = ''; Exportable: Boolean = False; SaveSeed: Boolean = False): Boolean; overload;
Generates a fresh key pair for a new certificate: writes the public part into DstCert's SubjectPublicKeyInfo and stores the matching private key in the ring. Full description »
function CreateKeyPair(const DstCert: iSubjectPublicKeyInfo; const Algorithm: ObjectIdentifier; ABitSize: Integer; const CurveOID: ObjectIdentifierString = ''; Exportable: Boolean = False; SaveSeed: Boolean = False): Boolean; overload;
As above, but takes the SubjectPublicKeyInfo directly. This is the overload that actually creates the key pair, dispatching on the Algorithm OID to the IF/DL/EC/ML-DSA/ML-KEM key generators of the underlying ring. » member page
function FindCreatePrivateKey(const Cert: iCertificate): iMPPrivateKey; overload;
Looks up the private key that matches a certificate (by its public-key identifier), returning nil if this ring holds no matching key. Use it to check whether a given "my" certificate is usable for signing/decryption, or to obtain the key object for a manual crypto operation. » member page
function FindCreatePrivateKey(const PublicKeyIdentifier: OctetString): iMPPrivateKey; overload;
As above, but looks up by a raw PublicKeyIdentifier (the same octet string used when the key was added). » member page
function ValidateMyCert(const Cert: iCertificate): Boolean;
Returns True if this ring holds the private key matching Cert's public key, i.e. the certificate is one of "my" certificates that can be used locally. Use this before assigning a certificate as your own TLS/CMS identity to confirm the corresponding private key is present. » member page
property Exceptions: Boolean read FExceptions write SetExceptions;
Flag intended to switch error signalling to exceptions rather than status returns. In the current Mobile stack the value is only stored, so most applications leave it at its default. » member page
property ExternalIFPrivateKeyClass: TExternalIFPrivateKeyClass read FExternalIFPrivateKeyClass write SetExternalIFPrivateKeyClass;
Metaclass (class-of tExternalIFPrivateKey) intended to represent an RSA (integer-factorization) private key whose signing/decryption is delegated to an out-of-process key store instead of an in-memory key. In the current Mobile stack the value is only stored here (and on the internal server) - no code path reads it back to instantiate such a key - so setting it has no effect in this stack. » member page
property LongTermKeyCount: Integer read GetLongTermKeyCount;
Number of long-term (non-ephemeral) private keys currently held in the ring. Useful for diagnostics or to iterate LongTermKeys. » member page
property LongTermKeys[index: Integer]: iMPPrivateKey read GetLongTermKeys;
Indexed access to the long-term private keys in the ring (0..LongTermKeyCount-1). Use for enumerating loaded identities, e.g. to list or audit available keys. » member page
property DefaultHashAlgorithm: THashAlgorithm read FDefaultHashAlgorithm write SetDefaultHashAlgorithm;
Hash algorithm passed to the key generators when this component generates key pairs via CreateKeyPair. Set it before creating keys/certificates that should use a specific digest. » member page
property PrivateKeyRing: TsmPrivateKeyRingComponent read FPKRComp write SetPrivateKeyRing;
Chains this component to another key-ring component so both share the same underlying private key store. Use this to let several components (e.g. distinct TLS endpoints) draw on one central set of private keys instead of each holding its own; assigning nil reverts to this component's private ring. Only one level of chaining is allowed and self/circular references raise an exception. » member page
property SessionKeyLifeSpan: System.TTime read FSessionKeyLifeSpan write FSessionKeyLifeSpan;
Lifetime of cached ephemeral session keys/TLS sessions before they are considered expired (a TDateTime span; defaults to half an hour). A TLS session is deemed expired once its last-access time plus this span is in the past, so lower it to expire resumable sessions sooner, raise it to keep them longer. » member page

recordTTLSCertRec

FHostName: string; FTLS_Certificate: PTLSHandshake; FCert: iCertificate; FPriv: IInterface; FOcspStaple: TBytes;
OCSP stapling: the raw DER OCSPResponse for this leaf and its nextUpdate (UTC; 0 = none). Fetched lazily by GetOrRefreshTLSServerStaple (via OnFetchOcspStaple) the first time a client asks for a staple and refreshed once nextUpdate passes; stapled into the TLS 1.3 Certificate flight. Empty when no OCSP source is configured or the responder was unreachable.
FOcspStapleNextUpdate: TDateTime;

classTsmStreamSecII — component reference

inherits from TsmPrivateKeyRingComponent

constructor Create(AOwner: TComponent); override;
Standard component constructor. Applications normally drop a TsmStreamSecII on a form (or create it in code) and then configure MyCertificates / CACertificates / TLSOptions before using it as the TLS engine behind a socket component. Create allocates the internal session lists, the lock, the TLSOptions and the collected-certificate store. » member page
destructor Destroy; override;
Standard component destructor. Stops the background OCSP-staple warm-up, clears the server cert cache and any live sessions, and frees the session lists, lock, TLSOptions and the in-memory TLS 1.3 resumption-ticket store. » member page
procedure ClearExpiredSessionKeys(aConservative: Boolean = True); override;
Sweeps out TLS sessions whose keys have expired (and, via ClearExpiredTLSSessions, prunes expired TLS 1.3 resumption tickets). A long-running server calls this periodically to bound memory; it takes the key lock, so it is safe to call while sessions are active. » member page
function FindCreatePrivateKeyTLS(KEA: TKeyExchangeAlgorithm; SignAlg: TSignatureAlgorithm; Version: TProtocolVersion; const ALPN: OctetString; Cert: iCertificate): iMPPrivateKey; overload;
Internal server-side wiring: given the negotiated key-exchange / signature algorithm, protocol version, ALPN and a chosen leaf certificate, returns the matching private key from the server cert cache (or the key ring). Full description »
function FindCreatePrivateKeyTLS(KEA: TKeyExchangeAlgorithm; SignAlg: TSignatureAlgorithm13; Version: TProtocolVersion; const ALPN: OctetString; Cert: iCertificate): iMPPrivateKey; overload;
TLS 1.3 (NEW): the same lookup keyed on the extended signature-algorithm index, so the 1.3 server path can fetch EdDSA / ML-DSA private keys. » member page
function ListTLSServerCertificates(aList: TStrings): Integer;
Use this method for listing all server certificates when the server is running, i.e. AFTER TLSSetupServer has been called, and when you don't want to close the server just to manage certificates. Full description »
function FindExpiringTLSServerCertificates(aExpirationDate: TDateTime; aList: TStrings): Integer;
Use this method for validation of server certificates when the server is running, i.e. AFTER TLSSetupServer has been called, and when you don't want to close the server just to manage certificates. Full description »
function FindExpiringTLSServerCertificatesEx(aElapsedFraction: Double; aList: TStrings): Integer;
As FindExpiringTLSServerCertificates, but the cut-off is expressed as the FRACTION of each certificate's validity period that must have ELAPSED for it to be included, rather than an absolute date. Full description »
procedure ReplaceTLSServerCertificate(const aCert: iCertificate; const aPriv: iMPPrivateKey); overload;
Use this method for replacing a server certificate assigned by TLSSetupServer, without having to close the server and reload all keys and certificates from file. » member page
procedure ReplaceTLSServerCertificate(const aCert: iCertificate; const aPriv: iMPPrivateKey; const aRetired: array of iCertificate); overload;
As above, and every leaf in aRetired is retired: the serving cache drops every row that holds it, so it is no longer selected for a host name or key type the new leaf does not cover, TLSSetupServer does not serve it again and ValidatePublicKeyPairs no longer counts its key type. Full description »
function IsRetiredServerCert(const aCert: iCertificate): Boolean;
True when a replacement retired aCert (see above). Takes TLSLock. » member page
procedure UnretireServerCert(const aCert: iCertificate);
Serves aCert again: an own leaf the application stores anew (for example through ImportFromPFX) is no longer retired. Takes TLSLock. » member page
procedure RetireServerCert(const aCert: iCertificate);
Retires aCert as a replacement would: TLSSetupServer does not serve it and ValidatePublicKeyPairs does not count it until it is stored anew (StoreCertificate, ImportFromPFX) or published again. Rows serving it now stay until the next TLSSetupServer or replacement. For an application that sets the engine up again in the same process with a leaf an earlier run served. Takes TLSLock. » member page
property OnWorkerError: tWorkerFatalEvent read fOnWorkerError write fOnWorkerError; property OnWorkerFatal: tWorkerFatalEvent read fOnWorkerFatal write fOnWorkerFatal; procedure AddTLSApplicationLayerProtocolName(const ALPN: OctetString);
Advertise an additional ALPN protocol name (e.g. 'h2', 'http/1.1') that new sessions will offer (client) or be willing to select (server). Call before opening sessions; duplicates are ignored. New sessions copy the current list. » member page
procedure RemoveTLSApplicationLayerProtocolName(const ALPN: OctetString);
Remove a previously added ALPN protocol name from the advertised list. » member page
procedure RemoveTLSAcmeALPN;
Server-only: tear down an ACME tls-alpn-01 challenge - removes the special 'acme-tls/1' ALPN and clears the self-signed challenge certificates added by AddTLSAcmeALPN. Call once the CA has validated the challenge. » member page
procedure AddTLSAcmeALPN(const aPriv: iMPPrivateKey; const aHostName: string; const aAuthorization: tBytes); overload;
Server-only: install an ACME tls-alpn-01 challenge response. Generates a short-lived self-signed certificate for aHostName carrying the acmeIdentifier extension (aAuthorization = the key authorization digest) and registers the 'acme-tls/1' ALPN so the ACME CA's validation connection is answered w... Full description »
procedure AddTLSAcmeALPN(const aPriv: iMPPrivateKey; const aHostName: string; const aToken: string; const aThumbprint: string); overload;
Server-only: convenience overload that computes the key authorization digest for you from the ACME challenge aToken and the account-key aThumbprint (SHA-256 of token.thumbprint), then calls the tBytes overload above. » member page
function FindTLSSession(const SessionID: TSessionID; var Client: TCustomTLS_ContentLayer; Extract: Boolean = False): Integer; overload;
Look up the content-layer object for an existing session by its TLS SessionID. Apps use this to reach a live session's state; pass Extract=True to detach the session from this component's management (the caller then owns it). Returns the session's index in the UserData list, or -1 if not found. » member page
function FindTLSSession(UserData: Pointer; var Client: TCustomTLS_ContentLayer; Extract: Boolean = False): Integer; overload;
Same lookup keyed on the application-supplied UserData pointer (typically the owning socket/connection object). This is the key the TLS*(UserData,...) methods use to route bytes to the right session. » member page
function TLSAddClientSession: TCustomTLS_ContentLayer;
Create and register a new client-role TLS session pre-configured from this component's TLSOptions, certificates and ALPN. Most apps let TLSConnect create the session implicitly; call this directly only when you need the content-layer object before starting the handshake. » member page
function TLSAddQUICClientSession(const aHandler: iQUICTLSHandler; const aTransportParameters: TBytes): TCustomTLS_ContentLayer;
The client and server TLS sessions of a QUIC connection, which carry the handshake in QUIC CRYPTO frames instead of TLS records. Full description »
function TLSAddQUICServerSession(const aHandler: iQUICTLSHandler; const aTransportParameters: TBytes; aUserData: Pointer = nil): TCustomTLS_ContentLayer; function TLSAddServerSession(UserData: Pointer = nil): TCustomTLS_ContentLayer;
Create and register a new server-role TLS session pre-configured from this component's TLSOptions, certificates and ALPN, tagged with UserData so later bytes can be routed to it. Usually created implicitly by TLSAccept; call directly only for advanced per-session setup (e.g. via OnTLSAddContentLayer). » member page
function TLSClose(const SessionID: TSessionID; Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Cleanly close the session identified by SessionID: emits a close_notify into Response (if given) and releases the session. Use on either side to shut a TLS connection down at the protocol level before closing the socket. » member page
function TLSDecodeData(var SessionID: TSessionID; Src, Data, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Decrypt inbound TLS records from Src into application plaintext Data, writing any handshake/alert bytes that must be sent back into Response, for the session identified by SessionID. Feed socket-received bytes here as they arrive. The SessionID variant is used once a session id is known. » member page
function TLSEncodeData(const SessionID: TSessionID; Data, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Encrypt application plaintext Data into TLS records written to Response for the session identified by SessionID. Call to send application data once the handshake for that session has completed. » member page
function TLSAccept(UserData: Pointer; Src, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Server entry point: process an inbound ClientHello (and subsequent handshake flights) from Src for the connection tagged UserData, writing the server's response bytes to Response. Creates the server session on first call. This is the server counterpart to the client's TLSConnect. » member page
function TLSAccept(UserData: Pointer; Src, EarlyData, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
TLS 1.3 (NEW, task 11): accept with a 0-RTT EarlyData destination. » member page
function TLSClose(UserData: Pointer; Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Cleanly close the session tagged with UserData (close_notify into Response, then release). This is the UserData-keyed counterpart to the SessionID TLSClose, matching the TLSAccept/TLSDecodeData(UserData,...) routing. » member page
function TLSConnect(UserData: Pointer; Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Client entry point: start a TLS handshake for the connection tagged UserData, writing the ClientHello into Response. Full description »
function TLSConnect(const SessionID: TSessionID; Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Client handshake keyed on a SessionID instead of a UserData pointer. Supply a previously issued SessionID to attempt (TLS 1.2) session resumption / abbreviated handshake. » member page
function TLSConnect(UserData: Pointer; const SessionID: TSessionID; Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Client handshake that both tags the session with UserData and offers the given SessionID for resumption - use when you route bytes by UserData but also want to resume a specific prior session. » member page
function TLSConnect(UserData: Pointer; const SessionID: TSessionID; const CipherSuites: TCipherSuites; Response: TStream; ErrorCode: PInteger): Integer; overload;
As above, but also overrides the cipher-suite preference list for just this one client session (instead of inheriting TLSOptions.CipherSuites) - useful when a particular endpoint needs a restricted or specific suite set. » member page
function TLSConnectAsServer(UserData: Pointer; Response: TStream; ErrorCode: PInteger = nil): Integer;
Server-role handshake started without an inbound ClientHello in hand (the caller drives it by passing nil as the accept source). Rarely needed; most servers use TLSAccept, feeding the actual ClientHello bytes. » member page
function TLSDecodeData(UserData: Pointer; Src, Data, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Main per-connection pump keyed on UserData: decrypt inbound records from Src into Data and emit any protocol response into Response. If no session exists yet for UserData it transparently begins a server handshake (routes to TLSAccept), so a server can call this for every inbound chunk from first byte onward. » member page
function TLSDecodeData(UserData: Pointer; Src, Data, EarlyData, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
TLS 1.3 (NEW, task 11): decode with a 0-RTT EarlyData destination. » member page
function TLSEncodeData(UserData: Pointer; Data, Response: TStream; ErrorCode: PInteger = nil): Integer; overload;
Encrypt application plaintext Data into TLS records written to Response for the session tagged UserData. UserData-keyed counterpart to the SessionID TLSEncodeData; call to send application data after the handshake completes. » member page
procedure TLSSetupServer;
Server-only: prepare this component to accept TLS connections. Enumerates the MyCertificates leaves and builds the internal server certificate/key cache (keyed by key-exchange and signature algorithm, incl. Full description »
procedure DoEarlyData(Client: TCustomTLS_ContentLayer; Data: TStream; var Accept: Boolean);
EARLY DATA (NEW): invoked by TTLS_ContentLayer (StreamSec.Mobile.TlsLayer) through its back-reference to this component, mirroring the existing DoTLS* callback pattern. They surface the published events below and the server's EarlyData policy to the application. » member page
procedure DoEndOfEarlyData(Client: TCustomTLS_ContentLayer);
Server-only: called by the content layer when the client's EndOfEarlyData message ends the 0-RTT stream; fires OnTLSEndOfEarlyData so the consumer knows early data is complete and following bytes are 1-RTT. » member page
function CheckEarlyDataReplay(Client: TCustomTLS_ContentLayer; const TicketId, ClientHelloHash: OctetString): Boolean;
Server-only anti-replay gate consulted before accepting 0-RTT (RFC 8446 sec.8): returns True only when the EarlyData policy is edmAccept AND the OnTLSCheckEarlyDataReplay hook confirms the ticket-id / ClientHello-hash pair is fresh; defaults to refusal when no hook is wired. » member page
procedure Tls13StoreServerTicket(aTicket: TTls13ServerTicket);
TLS 1.3 (NEW, task 11): server resumption-ticket store. Tls13StoreServer- Ticket takes ownership; Tls13FindServerTicket returns nil if the identity is unknown or expired (and reaps expired entries). » member page
function Tls13FindServerTicket(const aIdentity: TBytes): TTls13ServerTicket;
Server-side resumption lookup: returns the stored ticket whose opaque identity equals aIdentity (reaping expired ones first) or nil if unknown or expired. Called by the 1.3 server handshake when a client offers a pre_shared_key; applications rarely call it directly. » member page
function Tls13PeekServerTicket(const aIdentity: TBytes): TTls13ServerTicket;
Single-use resumption support. Tls13PeekServerTicket returns a detached CLONE (caller owns + frees) of the stored ticket for aIdentity, or nil - so the handshake can verify the binder off a private copy without holding the store lock across the crypto. Full description »
function Tls13ConsumeServerTicket(const aIdentity: TBytes): Boolean;
Delegates to FTls13TicketStore.Consume, forwarding aIdentity, and returns its result. » member page
function Tls13ServerTicketCount: Integer;
Diagnostic/monitoring: the number of unexpired resumption tickets currently held in the in-memory store (reaps expired ones first). » member page
property Tls13TicketStore: iTls13TicketStore read FTls13TicketStore write SetTls13TicketStore;
WHERE THIS ENGINE KEEPS ITS RESUMPTION TICKETS. Never nil; the constructor installs a private in-memory store, so leaving it alone reproduces the per-engine behaviour exactly. Full description »
function FindTLSServerStaple(const aCert: iCertificate): TBytes;
OCSP stapling: the DER OCSPResponse currently stored for the server leaf aCert (without refreshing), or empty if none. » member page
function GetOrRefreshTLSServerStaple(const aCert: iCertificate): TBytes;
OCSP stapling: a fresh staple for the server leaf aCert - fetched synchronously (via OnFetchOcspStaple) and cached in FTLS12Keys when none is stored or the stored one has expired, else the cached one. The refresh is serialised and completes + stores even if the requesting client disconnects meanwhile. Empty if no OCSP source is wired or the responder is unreachable. » member page
function DoTLSHandleCert(Certificate: PCertificate; Len: Integer; var EndCert: iCertificate; var Status: TCertStatusCodes): Boolean;
Imports a peer certificate chain (received during a handshake) into the engine's OWN CollectedCertificates store, UNDER TLSLock so it serialises against cert/CA hot swaps (TsmCustomTLSInternalServer.AddCertificate/AddCrl) and other concurrent handshakes. Full description »
property OnFetchOcspStaple: TFetchOcspStapleEvent read GetOnFetchOcspStaple write SetOnFetchOcspStaple;
OCSP stapling source, wired by the TLS server component to its Ocsp component. Fired by TLSSetupServer for each server leaf. » member page
procedure PruneExpiredTls13Tickets;
TLS 1.3 (NEW): prune expired resumption tickets from the in-memory store. The store is otherwise only reaped opportunistically (on a resumption lookup / on insert); a long-running server should call this periodically - it is also folded into ClearExpiredTLSSessions so ClearExpiredSessionKeys covers it. Safe to call at any time; takes the TLS lock internally. » member page
property TLSSessionCount: Integer read GetTLSSessionCount;
Number of currently managed TLS sessions (client + server). Handy for diagnostics / monitoring the live connection count on a server. » member page
property TLSSessions[index: Integer]: TCustomTLS_ContentLayer read GetTLSSessions;
Indexed access to the managed TLS session content-layers (0..TLSSessionCount-1), for enumerating live sessions - e.g. to inspect negotiated parameters or force a shutdown. Index is into the internal list and is not stable across changes. » member page
property DefaultCipherAlgorithm: TCipherAlgorithm read FDefaultCipherAlgorithm write SetDefaultCipherAlgorithm;
Legacy default bulk-cipher for the proprietary StreamSec II message protocol. In the current codebase it is only stored on this component (nothing reads it back); it does NOT drive TLS cipher selection - use TLSOptions for TLS. Rarely set by new apps. » member page
property DefaultKeyAgreement: TKeyAgreement read FDefaultKeyAgreement write SetDefaultKeyAgreement;
Legacy default key-agreement for the proprietary StreamSec II message protocol. In the current codebase it is only stored on this component (nothing reads it back). Not used by the TLS handshake (TLS key agreement comes from TLSOptions.KeyAgreement* and SupportedGroups). » member page
property TrustedCertificates: TsmX509TrustedCertificates read FTrustedCertificates write SetTrustedCertificates;
Explicitly trusted peer certificates: any cert assigned here is added to the collected/trusted store so a peer presenting it validates without a full chain. Use to pin specific end-entity certs (e.g. a known server or client cert). » member page
property MyCertificates: TsmX509TrustedCertificates read FMyCertificates write SetMyCertificates;
This endpoint's own certificate(s) plus private keys. On a server these are the leaf certs offered to clients (fed into the cache by TLSSetupServer); on a client they are the certs used for client authentication / mTLS. Assign before use. » member page
property CollectedCertificates: TsmX509TrustedCertificates read FCollectedCertificates write SetCollectedCertificates;
Working store into which chain-building certificates (peer-sent, trusted and CA) are collected during validation. Usually left at its auto-created default; assign only to share one store across components. » member page
property CACertificates: TsmX509TrustedCertificates read FCACertificates write SetCACertificates;
The trust anchors (root/intermediate CAs) used to validate the peer's certificate chain. Assign the CA(s) you trust; on a server it also supplies the CA list sent in CertificateRequest when requiring client certificates. » member page
property TLSOptions: TTLSOptions read FTLSOptions write SetTLSOptions;
The full TLS configuration surface (cipher suites, key-exchange / signature / hash preferences, supported groups, client-auth policy, 0-RTT/resumption, server name verification, ...). This is the primary object apps tune. New sessions inherit their settings from here; assigning copies (Assign) into the live options. » member page
property TLSLeanSessionManagement: Boolean read FTLSLeanSessionManagement write SetTLSLeanSessionManagement;
Inert flag in the current codebase - it is stored (and delegated by the internal server component) but no longer changes session-management behaviour. Left for backward compatibility; new apps need not set it. » member page
property OnTLSChangeCipherSpec: TTLSChangeCipherSpec read FOnTLSChangeCipherSpec write SetOnTLSChangeCipherSpec;
Fires when a session installs new keys (ChangeCipherSpec / key change). Apps can hook this to learn that a (re)handshake has switched the connection to encrypted traffic. Fired for both client and server sessions. » member page
property OnTLSCompress: TTLSCompressEvent read FOnCompress write FOnCompress;
Optional application-supplied record compressor (legacy TLS 1.0-1.2 compression). Leave unassigned to disable compression (the safe modern default); only wire it if you must interoperate with a peer that requires it. » member page
property OnTLSDecompress: TTLSDecompressEvent read FOnDecompress write FOnDecompress;
The decompression counterpart to OnTLSCompress; wire it only if you enabled record compression. Leave unassigned otherwise. » member page
property OnTLSIncomingAlert: TTLSAlertEvent read FOnIncomingAlert write SetOnIncomingAlert;
Fires when this endpoint receives an alert from the peer (e.g. a fatal handshake failure or close_notify). Full description »
property OnTLSOutgoingAlert: TTLSAlertEvent read FOnOutgoingAlert write SetOnOutgoingAlert;
Fires when this endpoint is about to send an alert to the peer. After a fatal outgoing alert the session is Closed (see TCustomTLS_ContentLayer.Closed); a TLSDecodeData that returns normally then releases it, and under a raising handler it stays registered until TLSClose. Full description »
property OnTLSRenegotiate: TTLSRenegotiateEvent read FOnRenegotiate write SetOnRenegotiate;
Server-side hook fired when a peer offers a prior SessionID to resume; the engine looks the session up and this hook lets the app veto the resumption (clear the Allowed flag). Rarely needed; relevant only to TLS 1.2-and-earlier renegotiation / abbreviated handshakes. » member page
property OnTLSSelectCompression: TTLSSelectCompressionEvent read FOnSelectCompression write SetOnSelectCompression;
Server-side hook to choose which (legacy) compression method to accept from the client's offered list. Only relevant if compression is in use; otherwise ignore. » member page
property OnTLSAddContentLayer: TTLSChangeCipherSpec read FOnTLSAddContentLayer write SetOnTLSAddContentLayer;
Fires just after a new session content-layer is created (client or server), before the handshake, giving the app one place to tweak per-session settings. On the server this is where you set per-session TLS 1.3 options (e.g. OfferTLS13) that cannot be expressed globally. » member page
property OnTLSHandshakeDone: TTLSChangeCipherSpec read FOnTLSHandshakeDone write SetOnTLSHandshakeDone;
Fires when a session's handshake has fully completed and the connection is ready for application data. Hook it (once, on the component - it is forwarded from every session) to release queued writes or inspect the negotiated parameters. » member page
property OnTLSEarlyData: TTLSEarlyDataEvent read FOnTLSEarlyData write FOnTLSEarlyData;
EARLY DATA (NEW): TLS 1.3 0-RTT. The server accept/reject policy (EarlyData) and advertised MaxEarlyDataSize now live on TLSOptions. The events below let the consumer implement RFC 8470 ("one HTTP request per early data") and RFC 8446 sec.8 anti-replay. » member page
property OnTLSEndOfEarlyData: TTLSEndOfEarlyDataEvent read FOnTLSEndOfEarlyData write FOnTLSEndOfEarlyData;
Server-side: fires when the client sends EndOfEarlyData, marking the boundary between 0-RTT early data and the 1-RTT application data that follows. » member page
property OnTLSCheckEarlyDataReplay: TTLSCheckEarlyDataReplayEvent read FOnTLSCheckEarlyDataReplay write FOnTLSCheckEarlyDataReplay;
Server-side 0-RTT anti-replay gate (RFC 8446 sec.8): the handler receives the ticket id and ClientHello hash and must clear the result to reject a replayed early-data attempt. Leaving it unassigned refuses all 0-RTT. » member page
property OnTLSNewSessionTicket: TTLSNewSessionTicketEvent read FOnTLSNewSessionTicket write FOnTLSNewSessionTicket;
TLS 1.3 (NEW): client-side NewSessionTicket delivery. Subscribe here (once, at the component) to receive and cache resumption tickets - the per-session OnNewSessionTicket is wired to this by TLSAddClientSession/TLSAddServerSession. » member page

classTDigestStream

inherits from TStream

constructor Create(ADataStream: TStream; AHash: THash); function Read(var Buffer; Count: Longint): Longint; override; function Write(const Buffer; Count: Longint): Longint; override; function Seek(Offset: Longint; Origin: Word): Longint; override; procedure Done(ADigest: Pointer); property DataStream: TStream read FDataStream write SetDataStream; property Digest: OctetString read GetDigest; property Hash: THash read FHash write SetHash;

classTEncryptStream

inherits from TStream

constructor Create(ADataStream: TStream; ACipher: TCipher); destructor Destroy; override; function Read(var Buffer; Count: Longint): Longint; override;
Always returns 0.
function Write(const Buffer; Count: Longint): Longint; override; function Seek(Offset: Longint; Origin: Word): Longint; override; function Done: Integer; property Cipher: TCipher read FCipher write SetCipher; property DataStream: TStream read FDataStream write SetDataStream;

classTDecryptStream

inherits from TStream

constructor Create(ADataStream: TStream; ACipher: TCipher); destructor Destroy; override; function Read(var Buffer; Count: Longint): Longint; override; function Write(const Buffer; Count: Longint): Longint; override;
Always returns 0.
function Seek(Offset: Longint; Origin: Word): Longint; override; function Done: Integer; virtual; property Cipher: TCipher read FCipher write SetCipher; property DataStream: TStream read FDataStream write SetDataStream; property OK: Boolean read FOK;

Types (enumerations, sets, aliases)

typeTCustomTLS_ContentLayer

  TCustomTLS_ContentLayer = StreamSec.Mobile.TlsClass.TCustomTLS_ContentLayer;

enumTPreference

  TPreference = (prNotAllowed,prAllowed,prPrefer);

typeTECKeySize

  TECKeySize = StreamSec.Mobile.TlsClass.TECKeySize;

typeTECKeySizes

  TECKeySizes = StreamSec.Mobile.TlsClass.TECKeySizes;

enumTVerifyServerNameEnum

  TVerifyServerNameEnum = (vsnIP,vsnDNS,vsnURI);

setTVerifyServerName

  TVerifyServerName = set of TVerifyServerNameEnum;

enumTEarlyDataMode

Server policy for client 0-RTT early data (TLS 1.3, RFC 8446 sec.2.3). Declared here so TTLSOptions can carry the EarlyData policy property.

  TEarlyDataMode = (edmDisabled,        // never advertise/accept 0-RTT (default)
                    edmAccept,          // accept and deliver early data
                    edmRejectAndRetry); // omit early_data so the client replays 1-RTT

enumTKeyDerivation

Deprecated - kdfWeakPassword, kdfWeakPassword256 and the kdfWPv2* values name the StreamSec password KDFs (WeakPasswordToPrivKey, WeakPasswordToPrivKey256 and WeakPasswordKDFv2 in stKDF), kept so that existing data can still be read.

  TKeyDerivation = (kdfWeakPassword,kdfP1636_2_sha1,kdfX9_42Concat_sha1,
                    kdfWeakPassword256,kdfP1636_2_sha256,kdfX9_42Concat_sha256,
                    kdfX9_42ASN1DER_sha1,kdfX9_42ASN1DER_sha256,
                    kdfWPv2SHA1,
                    kdfWPv2MD5,
                    kdfWPv2RipeMD160,
                    kdfWPv2SHA256,
                    kdfWPv2SHA384,
                    kdfWPv2SHA512);

enumTKeyAgreement

  TKeyAgreement = (kaOnePassDH,kaStaticDH,kaHybridOnePass,kaMQV1);

enumTCipherAlgorithm

Deprecated - the ca*KIV* values name keyed-IV (KIV) ciphers (see id_kivcipher in stOIDs), and ca*KIVpcfb / ca*KIVppcfb the deprecated PCFB modes as well; they are kept so that existing data can still be read.

  TCipherAlgorithm = (caAES128CBC,caAES128OFB,caAES128CFB,
                      caAES192CBC,caAES192OFB,caAES192CFB,
                      caAES256CBC,caAES256OFB,caAES256CFB,
                      ca3DESCBC,caARC4OFB,
                      caAES128KIVctr, caAES192KIVctr, caAES256KIVctr,
                      caAES128KIVabc, caAES192KIVabc, caAES256KIVabc,
                      caAES128KIVpcfb, caAES192KIVpcfb, caAES256KIVpcfb,
                      caAES128KIVppcfb, caAES192KIVppcfb, caAES256KIVppcfb,
                      caAES128KIVcbc, caAES192KIVcbc, caAES256KIVcbc,
                      caAES128KIVofb, caAES192KIVofb, caAES256KIVofb,
                      caAES128KIVcfb, caAES192KIVcfb, caAES256KIVcfb,
                      caDESKIVctr, ca3DES112KIVctr, ca3DES168KIVctr,
                      caDESKIVabc, ca3DES112KIVabc, ca3DES168KIVabc,
                      caDESKIVpcfb, ca3DES112KIVpcfb, ca3DES168KIVpcfb,
                      caDESKIVppcfb, ca3DES112KIVppcfb, ca3DES168KIVppcfb,
                      caDESKIVcbc, ca3DES112KIVcbc, ca3DES168KIVcbc,
                      caDESKIVofb, ca3DES112KIVofb, ca3DES168KIVofb,
                      caDESKIVcfb, ca3DES112KIVcfb, ca3DES168KIVcfb
                      );

enumTEncodeType

  TEncodeType = (eEncrypt,eDigest,eDigestThenEncrypt,eEncryptThenDigest);

arrayTInternalBuffer

  TInternalBuffer = array [0..65535] of Byte;

procTTLSAlertEvent

  TTLSAlertEvent = procedure (Sender: TObject;
                              Client: TCustomTLS_ContentLayer;
                              var Fatal: Boolean;
                              AlertCode: Integer) of object;

procTTLSSelectCompressionEvent

  TTLSSelectCompressionEvent = procedure (Sender: TObject;
                                          Client: TCustomTLS_ContentLayer;
                                          const CompMethods: array of TCompressionMethod;
                                          var CompMethod: TCompressionMethod) of object;

procTTLSRenegotiateEvent

  TTLSRenegotiateEvent = procedure (Sender: TObject;
                                    Client: TCustomTLS_ContentLayer;
                                    const SessionID: TSessionID;
                                    var Allow: Boolean) of object;

procTTLSCompressEvent

  TTLSCompressEvent = procedure (Sender: TObject;
                                 Client: TCustomTLS_ContentLayer;
                                 Src: PTLSPlainText; PTLen: Integer;
                                 Method: Byte;
                                 var Dst: PTLSCompressed; var CLen: Integer;
                                 var Error: Integer) of object;

procTTLSDecompressEvent

  TTLSDecompressEvent = procedure (Sender: TObject;
                                   Client: TCustomTLS_ContentLayer;
                                   Src: PTLSCompressed; CLen: Integer;
                                   Method: Byte;
                                   var Dst: PTLSPlainText; var PTLen: Integer;
                                   var Error: Integer) of object;

procTTLSChangeCipherSpec

  TTLSChangeCipherSpec = procedure (Sender: TObject;
                                    Client: TCustomTLS_ContentLayer) of object;

procTTLSEarlyDataEvent

Fired for each block of accepted 0-RTT early data. The HTTP consumer should parse ONE request from Data and, per RFC 8470, mark it (Early-Data: 1) or answer 425; set Accept := False to make the engine discard the remainder (e.g. once a complete, non-idempotent request has been seen).

  TTLSEarlyDataEvent = procedure (Sender: TObject;
                                  Client: TCustomTLS_ContentLayer;
                                  Data: TStream;
                                  var Accept: Boolean) of object;

procTTLSEndOfEarlyDataEvent

Fired once, when the client's EndOfEarlyData boundary is reached. After this the connection continues with ordinary 1-RTT application data.

  TTLSEndOfEarlyDataEvent = procedure (Sender: TObject;
                                       Client: TCustomTLS_ContentLayer) of object;

procTTLSCheckEarlyDataReplayEvent

Anti-replay hook (RFC 8446 sec.8). The consumer owns single-use tickets and a strike register; set Accept := False if (TicketId,ClientHelloHash) was seen before, so the same 0-RTT request is never processed twice.

  TTLSCheckEarlyDataReplayEvent = procedure (Sender: TObject;
                                  Client: TCustomTLS_ContentLayer;
                                  const TicketId, ClientHelloHash: OctetString;
                                  var Accept: Boolean) of object;

procTTLSNewSessionTicketEvent

TLS 1.3 (NEW): fired on the CLIENT for each server NewSessionTicket, forwarding the content layer's OnNewSessionTicket up to the component so a consumer can subscribe once (like the other component events) and cache tickets for later resumption / 0-RTT. The Ticket is owned by the content layer and freed after the handler returns - Clone it to retain.

  TTLSNewSessionTicketEvent = procedure (Sender: TObject;
                                  Client: TCustomTLS_ContentLayer;
                                  Ticket: TTls13ClientTicket) of object;

enumtTicketStoreCapability

What a ticket store can honestly promise. Intrinsic properties of the implementation, not of how it happens to be wired up.

  tTicketStoreCapability = (
    { Consume is a true atomic test-and-set: of N concurrent claimants for one
      identity, exactly one is told True. WITHOUT THIS, 0-RTT MUST BE REFUSED -
      single-use is the anti-replay mechanism, and a store that cannot make the
      claim atomic cannot enforce it. 1-RTT resumption is still fine: resuming
      twice from one ticket costs forward secrecy, not replay protection. }
    tscAtomicConsume,
    { Visible to other processes / other nodes, so a client can resume against a
      server it did not handshake with. }
    tscCrossProcess,
    { Survives a process restart. }
    tscPersistent);

settTicketStoreCapabilities

  tTicketStoreCapabilities = set of tTicketStoreCapability;

procTPasswordEvent

  TPasswordEvent = procedure (Sender: TObject; Password: ISecretKey) of object;

arraytTLSCertRow

TLS 1.3 (NEW): the signature-algorithm index is the extended TSignatureAlgorithm13 so the cache can hold EdDSA / ML-DSA leaves (keyed on subjectPublicKey) in addition to the classical RSA/DSS/ECDSA ones. The key-exchange index is unchanged (TLS 1.3 pairs any key exchange with any certificate).

  tTLSCertRow = array of TTLSCertRec;

arrayTTLSCertArray

  TTLSCertArray = array [TKeyExchangeAlgorithm,TSignatureAlgorithm13]
    of tTLSCertRow;

typepTLSCertArray

  pTLSCertArray = ^TTLSCertArray;

procTFetchOcspStapleEvent

OCSP stapling: fired to fetch a fresh DER OCSPResponse for a server leaf. The TLS server component wires it to its Ocsp (TsmOcsp) component. aStapleDER empty on return staples nothing; aNextUpdate is the response's nextUpdate (UTC, 0 = none) so the store knows when to refresh.

  TFetchOcspStapleEvent = procedure (Sender: TObject; const aCert: iCertificate;
                                     var aStapleDER: TBytes;
                                     var aNextUpdate: TDateTime) of object;

Routines