API Reference
StreamSec.Mobile.Tls
TLS Unit
Feature notes: TLS implementation notes (RFC map)
Classes, interfaces and records
classETLSEngineError
inherits from Exception
Root of the TLS engine exception hierarchy. Every unit of the Mobile TLS engine (StreamSec.Mobile.TlsClass, TlsLayer, TlsEncryption, TlsInternalServer, ...) raises a descendant of this class, so an application can catch the engine with a single handler. Deliberately NOT called eTLSError: that name is taken by the legacy stTLSIntf, and Delphi identifiers are case-insensitive, so the two would shadow each other in any unit that used both.
(no public members)
recordTProtocolVersion
major, minor: Byte;
recordTTLSPlainText
contentType: Byte;
version: TProtocolVersion;
length: TPlainTextLength;
fragment: TPlainTextFragment;
recordTTLSCompressed
contentType: Byte;
version: TProtocolVersion;
length: TCompressedLength;
fragment: packed array [0..MaxCompressedLength-1] of Byte;
recordTTLSEncrypted
contentType: Byte;
version: TProtocolVersion;
length: TEncryptedLength;
fragment: packed array [0..MaxCipherTextLength-1] of Byte;
classTCustomTLSSession
constructor Create;
destructor Destroy; override;
procedure Access;
function IsExpired: Boolean; virtual; abstract;
recordTTLSSecurityParams
entity: TConnectionEnd;
prf_algorithm: THashAlgorithm;
TLS 1.2 and up
bulk_cipher_algorithm: TBulkCipherAlgorithm;
cipher_type: TCipherType;
key_size: Word;
key_material_length: Word;
is_exportable: Boolean;
fixed_iv_length: Word;
ctAead
record_iv_length: Word;
TLS 1.1 and up
mac_algorithm: THashAlgorithm;
compression_algorithm: TCompressionMethod;
master_secret: TMasterSecret;
client_random: TRandomString;
server_random: TRandomString;
encrypt_then_mac: Boolean;
recordTTLSKeys
hLen: Byte;
server_write_MAC_secret: packed array [0..63] of Byte;
kLen: Byte;
server_write_key: packed array [0..31] of Byte;
bLen: Byte;
server_write_iv: packed array [0..31] of Byte;
recordTTLSAlert
alertDescription: Byte;
recordTSignatureAndHashAlgorithms
rsa: THashAlgorithms;
dsa: THashAlgorithms;
ecdsa: THashAlgorithms;
recordTInternalClientHello
client_version: TProtocolVersion;
random: TRandom;
session_id: TSessionID;
cipher_suite_count: Word;
cipher_suites: TCipherSuites;
compression_count: Byte;
compression_methods: TCompressionMethods;
server_name: string;
secure_renegotiation:Boolean;
client_verify: OctetString;
encrypt_then_mac: Boolean;
supported_signature_algorithms: TSignatureAndHashAlgorithms;
offered_sig_schemes: tBytes;
TLS 1.3 (NEW): the raw 2-byte SignatureScheme codepoints the peer offered that do not map onto the legacy hash/sig pairs above (EdDSA / ML-DSA / Composite ML-DSA). On decode this captures everything seen on the wire so the server can match a non-classical leaf; on encode the client appends these (from TLSOptions, via Tls13SigSchemes) to signature_algorithms. Two bytes big-endian per scheme.
offered_cert_sig_schemes: tBytes;
TLS 1.3 (NEW): the raw 2-byte SignatureScheme codepoints the peer offered in a separate "signature_algorithms_cert" extension (RFC 8446 sec.4.2.3), which constrains the signatures the server's CERTIFICATES may carry (independently of the CertificateVerify constraint in signature_algorithms). Empty when the extension is absent - then signature_algorithms applies to certificates too.
status_request: Boolean;
OCSP stapling (RFC 6066): True when the ClientHello carried a status_request extension (the client wants a stapled OCSP response for the server cert).
TLS 1.3 (NEW): extra NamedGroup codepoints (2 bytes big-endian each) appended to the supported_groups extension beyond the fixed classical EC/FFDHE list - the TLSOptions-enabled PQ/hybrid groups (pure ML-KEM, ECDHE+ML-KEM hybrids). Required so the key_share group is also advertised in supported_groups (peers reject a key_share for a group absent from supported_groups).
legacy_sig_hashes: Boolean;
Encode only: which optional parts of the fixed classical lists the client offers. legacy_sig_hashes adds the SHA-1 and SHA-224 (hash, signature) pairs to signature_algorithms (RFC 9155 bars SHA-1 there; TLSOptions.HashAlgorithmSHA1 decides), dsa_sigs adds the DSA pairs (TLSOptions.SignatureDSS),...
Full description »
dsa_sigs: Boolean;
ffdhe_groups: Boolean;
supported_groups: TCurves;
protocol_name_list: TApplicationProtocols;
TLS 1.3 (NEW): a pre-built block of additional ClientHello extensions (each type||len||data), appended verbatim by TLS_EncodeClientHello after the built-in 1.2 extensions.
Full description »
recordTClientHello
client_version: TProtocolVersion;
random: TRandom;
data: packed array [0..$FFFFFF] of Byte;
recordTInternalServerHello
server_version: TProtocolVersion;
random: TRandom;
session_id: TSessionID;
cipher_suite: TCipherSuite;
compression_method: TCompressionMethod;
secure_renegotiation:Boolean;
client_server_verify:OctetString;
encrypt_then_mac: Boolean;
protocol_name_list: OctetString;
has_sni: Boolean;
status_request: Boolean;
OCSP stapling (RFC 6066): on the SERVER, set True to emit an empty status_request extension in the ServerHello (promising a CertificateStatus); on the CLIENT, TLS_DecodeServerHello sets it True when the server echoed one.
selected_version: Word;
TLS 1.3 (NEW): populated from the ServerHello extensions by TLS_DecodeServerHello. selected_version is the supported_versions value (e.g. $0304); it stays 0 for a TLS <=1.2 ServerHello, so the legacy path is taken. server_key_share_* carry the negotiated group and server public (the public is empty for a HelloRetryRequest that only selects a group).
server_key_share_group: Word;
server_key_share: tBytes;
selected_psk_identity: Integer;
TLS 1.3 (NEW, task 10): pre_shared_key - the server's selected_identity (index into the client's offered PSKs). -1 means the server did not accept a PSK (full handshake / no resumption).
recordTServerHello
server_version: TProtocolVersion;
random: TRandom;
data: packed array [0..33 + 2 + 1] of Byte;
recordTCertificate
certificate_list: packed array [0..$FFFFFF] of Byte;
recordTServerRSAParams
rsa_modulus: iDSInteger;
rsa_exponent: iDSInteger;
recordTServerDHParams
dh_p: iDSInteger;
dh_g: iDSInteger;
dh_Ys: iDSInteger;
recordTECParameters
curve_type: TECCurveType;
primeCurve: iECurve;
curveName: Word;
NamedCurve, a uint16 (RFC 8422 sec.5.4).
recordTServerECDHParams
curve_params: TECParameters;
public_key: iECPoint;
md5_hash: packed array [0..15] of Byte;
sha_hash: packed array [0..19] of Byte;
recordTSignature
signature: tBytes;
input: TSignatureInput;
recordTInternalServerKeyExchange
Signed: TSignature;
SignHash: THashAlgorithm;
The hash the server signed with, as the signed decoders read it (TLS 1.2: from the SignatureAndHashAlgorithm on the wire; TLS 1.0/1.1: haSHA1 for DSA/ECDSA, haDefault for the MD5+SHA-1 RSA pair). Set only by the decoders that verify a signature; the caller checks it against RFC 9155.
KEA: TKeyExchangeAlgorithm;
rsaParams: TServerRSAParams;
dhParams: TServerDHParams;
ecdhParams: TServerECDHParams;
recordTServerKeyExchange
data: packed array [0..$FFFFFF] of Byte;
recordTInternalCertificateRequest
certificate_types: TCertificateTypes;
supported_sign_algs: TSignatureAndHashAlgorithms;
supported_sign_schemes: tBytes;
Exact TLS 1.2 request pairs, including unknown schemes, in wire order. The legacy sets above contain only understood hash/signature pairs. Leave empty when constructing a request from those sets.
certificate_authorities: TX501Names;
recordTCertificateRequest
data: packed array [0..$FFFFFF] of Byte;
recordTPreMasterSecret
version: TProtocolVersion;
random: packed array [0..45] of Byte;
recordTClientDHPublic
fEncoding: TPublicValueEncoding;
dh_Yc: IDSInteger;
recordTInternalClientKeyExchange
rsaEncryptedPreMasterSecret: tBytes;
clientDHPublic: TClientDHPublic;
recordTClientKeyExchange
data: packed array [0..$FFFFFF] of Byte;
recordTInternalCertificateVerify
signature: TSignature;
recordTCertificateVerify
data: packed array [0..$FFFFFF] of Byte;
recordTFinished
verify_data: packed array [0..35] of Byte;
recordTTLSHandshake
msg_type: Byte;
length: array [0..2] of Byte;
recordTSSL2ClientHello
msg_length: packed array [0..1] of Byte;
msg_type: Byte;
version: TProtocolVersion;
cipher_spec_length: Word;
session_id_length: Word;
challenge_length: Word;
data: packed array [0..$3FFFF] of Byte;
Types (enumerations, sets, aliases)
typeTCompressionMethod
TCompressionMethod = Byte;
arrayTCompressionMethods
TCompressionMethods = array of TCompressionMethod;
typeTSessionID
TSessionID = OctetString;
enumTTLSVersion
TTLSVersion = (tlsvSSL30,tlsvTLS10,tlsvTLS11,tlsvTLS12);
arrayTPlainTextFragment
TPlainTextFragment = packed array [0..MaxPlainTextLength-1] of Byte;
typeTPlainTextLength
TPlainTextLength = 0..MaxPlainTextLength;
typePTLSPlainText
PTLSPlainText = ^TTLSPlainText;
typeTCompressedLength
TCompressedLength = 0..MaxCompressedLength;
typePTLSCompressed
PTLSCompressed = ^TTLSCompressed;
typeTEncryptedLength
TEncryptedLength = 0..MaxCipherTextLength;
typePTLSEncrypted
PTLSEncrypted = ^TTLSEncrypted;
arrayTCipherSuite
TCipherSuite = array [0..1] of Byte;
arrayTCipherSuites
TCipherSuites = array of TCipherSuite;
enumTConnectionEnd
TConnectionEnd = (ceServer,ceClient);
enumTBulkCipherAlgorithm
TBulkCipherAlgorithm = (bcaNull,bcaRC4,
bca3DES,
bcaAES128,bcaAES256,
bcaAES128_GCM,bcaAES256_GCM,
// Application specific:
bcaAES192,
bcaAES128_CTR,bcaAES192_CTR,bcaAES256_CTR,
bcaTwoFish128,bcaTwoFish192,bcaTwoFish256,
bcaTwoFish128_CTR,bcaTwoFish192_CTR,bcaTwoFish256_CTR,
bcaBlowFish128,bcaBlowFish128_CTR,
bcaChaCha20_Poly1305);
enumTCipherType
TCipherType = (ctStream,ctBlock, // SSL 3.0 and up
ctAead); // TLS 1.2 and up
typeTRandomString
TRandomString = stTLSUtils.TRandomString;
typeTRandomString
TRandomString = StreamSec.Mobile.TLSUtils.TRandomString;
typePMasterSecret
PMasterSecret = ^TMasterSecret;
arrayTMasterSecret
TMasterSecret = packed array [0..47] of Byte;
typePTLSSecurityParams
PTLSSecurityParams = ^TTLSSecurityParams;
typeTRandom
TRandom = stTLSUtils.TRandom;
typeTRandom
TRandom = StreamSec.Mobile.TLSUtils.TRandom;
setTHashAlgorithms
THashAlgorithms = set of THashAlgorithm;
arrayTCurves
TCurves = array of Word;
arrayTApplicationProtocols
TApplicationProtocols = array of OctetString;
typePClientHello
PClientHello = ^TClientHello;
typePServerHello
PServerHello = ^TServerHello;
typePCertificate
PCertificate = ^TCertificate;
enumTKeyExchangeAlgorithm
TKeyExchangeAlgorithm = (keaNull,keaRSA,keaDH,keaDHE,
keaECDH, keaECDHE);
enumTECCurveType
TECCurveType = (ctReserved,ctExplicitPrime,ctExplicitChar2,ctNamedCurve);
enumTSignatureAlgorithm
TSignatureAlgorithm = (saAnon,saRSA,saDSS,saECDSA);
enumTSignatureAlgorithm13
TLS 1.3 (NEW): the certificate/private-key cache signature-algorithm index. It EXTENDS the four classical TSignatureAlgorithm values (kept at the same ordinals 0..3, so a TSignatureAlgorithm widens to this type by a plain ordinal cast - see Sig13) with one entry per TLS 1.3 signature algorithm that needs its own certificate slot. This is done opportunistically: an rsaEncryption public key serves every RSA and RSA-PSS SignatureScheme, so a single sa13RSA index suffices; ECDSA likewise shares sa13ECDSA (the leaf curve fixes the scheme). EdDSA (Ed25519/Ed448) and ML-DSA (44/65/87) each get their own value, matched against the leaf subjectPublicKey when populating the cache.
TSignatureAlgorithm13 = (sa13Anon,sa13RSA,sa13DSS,sa13ECDSA,
sa13Ed25519,sa13Ed448,
sa13MLDSA44,sa13MLDSA65,sa13MLDSA87,
sa13RSAPSS,sa13Composite1,sa13Composite2,sa13Composite3,
sa13Composite4,sa13Composite5,sa13Composite6,sa13Composite7,
sa13Composite8,sa13Composite9,sa13Composite10,sa13Composite11,
sa13Composite12,sa13Composite13);
typePServerKeyExchange
PServerKeyExchange = ^TServerKeyExchange;
arrayTCertificateTypes
TCertificateTypes = array of Byte;
arrayTRawNames
TX501Names = array of TX501Name;
TRawNames = array of OctetString;
typeTX501Names
TX501Names = TRawNames;
typePCertificateRequest
PCertificateRequest = ^TCertificateRequest;
enumTPublicValueEncoding
TPublicValueEncoding = (pveImplicit,pveExplicit);
typePClientKeyExchange
PClientKeyExchange = ^TClientKeyExchange;
typePCertificateVerify
PCertificateVerify = ^TCertificateVerify;
typePTLSHandshake
PTLSHandshake = ^TTLSHandshake;
typePSSL2ClientHello
PSSL2ClientHello = ^TSSL2ClientHello;
arrayTSSL2CipherSpec
TSSL2CipherSpec = packed array [0..2] of Byte;
arrayTTLSHandshakes
TTLSHandshakes = array of PTLSHandshake;
arraytRCArray
tRCArray = array of iCertificate;
typeTGMTUnixTime
TGMTUnixTime = stTLSUtils.TGMTUnixTime;
typeTGMTUnixTime
TGMTUnixTime = StreamSec.Mobile.TLSUtils.TGMTUnixTime;
Routines