API Reference
StreamSec.Mobile.TlsLayer
TLSLayer Unit
Feature notes: TLS implementation notes (RFC map)
Classes, interfaces and records
classTTLS_RecordLayer
constructor Create(AsServer: Boolean);
destructor Destroy; override;
function LoadFragmentFromStream(Src, CCS, Alert, Handshake, Data: TStream; var Error: Integer; var RecordType: TRecordType): Integer;
function SaveFragmentToStream(Src, Dst: TStream; var Error: Integer; RecordType: TRecordType): Integer;
procedure SetNegotiatedVersion(const Value: TProtocolVersion);
TLS 1.3 (NEW): set the negotiated version once supported_versions has been parsed from the ServerHello / ClientHello. Switches the record layer onto the 1.3 code paths (inner content type, dummy CCS, HKDF traffic keys).
procedure BeginSkipRejectedEarlyData(aMaxBytes, aMaxRecords: Integer);
TLS 1.3 (NEW): install a read (Incoming=True) or write (Incoming=False) record-protection key set directly from a TLS 1.3 traffic secret, instead of via ChangeCipherSpec.
Full description »
procedure BeginSkipHrrEarlyData(aMaxRecords: Integer);
Arm the HelloRetryRequest window described on FTls13SkipHrrRecords.
procedure InstallTLS13TrafficKeys(Incoming: Boolean; HashClass: THashClass; const TrafficSecret: tBytes);
procedure UpdateTLS13Key(Incoming: Boolean);
TLS 1.3 (NEW, KeyUpdate - RFC 8446 / RFC 9846 sec.4.6.3): advance the read (Incoming=True) or write traffic key to application_traffic_secret_N+1 and reinstall the cipher (a fresh cipher object resets the record sequence number to 0, as sec.5.3 requires on a key change).
function Tls13SendKeyExhausted: Boolean;
TLS 1.3 (NEW, RFC 9846 sec.5.5): True once the number of records encrypted under the current write key has reached the AEAD confidentiality limit, i.e. a KeyUpdate MUST be sent before any further application data.
property PRNG: iRawRandom read FPRNG write FPRNG;
The owning connection's secondary generator; assigned once by TTLS_ContentLayer.Create and forwarded to every cipher instantiated in ChangeCipherSpec (see tTLSEncryption.PRNG).
property OnCompress: TCompressEvent read FOnCompress write FOnCompress;
property OnDecompress: TDecompressEvent read FOnDecompress write FOnDecompress;
property OnChangeCipherSpec: TNotifyEvent read FOnChangeCipherSpec write SetOnChangeCipherSpec;
classTTLS_ContentLayer
(no public members)
classTTLS_HandshakeProtocol
constructor Create(AsServer: Boolean; AOwner: TTLS_ContentLayer);
destructor Destroy; override;
function Add(var H: PTLSHandshake; var Len: Integer; Response: TStream): Integer;
property Done: Boolean read GetDone;
property PeerAuthenticated: Boolean read FPeerAuthenticated;
TLS 1.3 (NEW, task 6/7)
classTTLS_ContentLayer
inherits from TCustomTLS_ContentLayer
constructor Create(AsServer: Boolean);
constructor CreateQUIC(aAsServer: Boolean; const aHandler: iQUICTLSHandler; const aTransportParameters: TBytes);
function StartQUIC: Integer;
CRYPTO input is ordered and reassembled by QUIC before delivery. Each message is bounded to 1 MiB. Calls are serialized; callbacks cannot reenter the session. Application records and TLS KeyUpdate do not apply to QUIC.
function ReceiveQUICHandshake(aLevel: tQUICTLSLevel; const aData: TBytes): Integer;
procedure ClearQUICResumptionOffers;
Clears borrowed ticket offers before a QUIC client starts. No ticket is freed. A transport can reinstall its validated owned credential.
procedure EnableQUICEarlyData(aEnabled: Boolean);
Enable only before StartQUIC, after the transport has supplied bounded restoration and application configuration policy. Defaults to False. Accepted is latched across completion; no EndOfEarlyData is sent.
property QUICEarlyDataOffered: Boolean read GetQUICEarlyDataOffered;
property QUICEarlyDataAccepted: Boolean read FEarlyDataAccepted;
property QUICPeerTransportParameters: TBytes read fQUICPeerParameters;
destructor Destroy; override;
function Accept(Src, Response: TStream): Integer; overload; override;
Delegates to
Accept, forwarding Src, nil and Response, and returns its result.
function Accept(Src, EarlyData, Response: TStream): Integer; overload; override;
Delegates to
Accept, forwarding Src, nil and Response, and returns its result.
function Close(Response: TStream): Integer; override;
function Connect(Response: TStream): Integer; override;
function DecodeData(Src, Data, Response: TStream): Integer; overload; override;
Delegates to
DecodeData, forwarding Src, Data, nil and Response, and returns its result.
function DecodeData(Src, Data, EarlyData, Response: TStream): Integer; overload; override;
Delegates to
DecodeData, forwarding Src, Data, nil and Response, and returns its result.
function EncodeData(Src, Response: TStream): Integer; override;
function ExportKeyingMaterial(const aLabel : AnsiString; const aContext: tBytes; aLen : Integer): tBytes; override;
RFC 8446 sec.7.5 exporter (see TCustomTLS_ContentLayer.ExportKeyingMaterial): delegates to the handshake protocol, which captured the exporter_master_secret when the 1.3 handshake completed.
procedure BeginEarlyData(Accepted: Boolean);
EARLY DATA (NEW): driven by the TLS 1.3 handshake driver. BeginEarlyData is called when the client's early_data is accepted (or rejected) for this connection; SignalEndOfEarlyData is called when the EndOfEarlyData handshake message has been processed. The boundary lets the consumer frame exactly one HTTP request per 0-RTT flight (RFC 8470).
procedure SetEarlyDataRejected;
Report a REFUSED 0-RTT offer for the status property only. Deliberately does NOT set FEarlyDataActive - see the call site in HandleClientHello13.
procedure SignalEndOfEarlyData;
function KeyUpdate(aRequestPeerUpdate: Boolean; Response: TStream): Integer;
TLS 1.3 (NEW, RFC 9846 sec.4.6.3): application-triggered post-handshake KeyUpdate - sends a KeyUpdate (aRequestPeerUpdate also asks the peer to update its keys) and rotates our write key. No-op (Result < 0) unless a TLS 1.3 handshake has completed.
function TestHandshakeMessage(const aMessage: tBytes; aResponse: TStream): Integer;
TEST BUILDS ONLY: the define is set by test harnesses, never by the packages, so shipped code does not contain this.
Full description »
property EarlyDataActive: Boolean read FEarlyDataActive;
property PrivateKeyRing: TsmStreamSecII read FPrivateKeyRing write SetPrivateKeyRing;
property RecordLayer: TTLS_RecordLayer read FRecordLayer;
Types (enumerations, sets, aliases)
setTTLSHandshakeSet
TTLSHandshakeSet = set of hello_request..finished;
Routines