Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Mobile.TlsEncryption

Feature notes: TLS implementation notes (RFC map)

Classes, interfaces and records

classtTLSEncryption

procedure Decrypt(Src: PTLSEncrypted; CTLen: Integer; var Dst: PTLSCompressed; var CLen: Integer; var Error: Integer); virtual; abstract; procedure Encrypt(Src: PTLSCompressed; CLen: Integer; var Dst: PTLSEncrypted; var CTLen: Integer; var Error: Integer); virtual; abstract; function NewRecordIV(var aIV): Boolean; virtual; property PRNG: iRawRandom read fPRNG write fPRNG;
The generator used for the CBC explicit record IV, which is transmitted in the clear ahead of each record. The record layer assigns its connection's SECONDARY generator here (TCustomTLS_ContentLayer.ConnRandom); when unset, NewRecordIV falls back to the global primary generator. Mirrors the per-direction iSSHParameters.PRNG the SSH transport already uses.
property RecordIVLength: Integer read GetRecordIVLength;

classtTLSEncryption10

inherits from tTLSEncryption

constructor Create(const aKeys : tTLSKeys; aCipherClass: tCipherClass; aHashClass : tHashClass; aServerWrite: Boolean); destructor Destroy; override;

classtTLSEncryption10Stream

inherits from tTLSEncryption10

procedure Decrypt(Src: PTLSEncrypted; CTLen: Integer; var Dst: PTLSCompressed; var CLen: Integer; var Error: Integer); override; procedure Encrypt(Src: PTLSCompressed; CLen: Integer; var Dst: PTLSEncrypted; var CTLen: Integer; var Error: Integer); override;

classtTLSEncryption10Block

inherits from tTLSEncryption10

procedure Decrypt(Src: PTLSEncrypted; CTLen: Integer; var Dst: PTLSCompressed; var CLen: Integer; var Error: Integer); override; procedure Encrypt(Src: PTLSCompressed; CLen: Integer; var Dst: PTLSEncrypted; var CTLen: Integer; var Error: Integer); override;

classtTLSEncryption10BlockEtM

inherits from tTLSEncryption10

procedure Decrypt(Src: PTLSEncrypted; CTLen: Integer; var Dst: PTLSCompressed; var CLen: Integer; var Error: Integer); override; procedure Encrypt(Src: PTLSCompressed; CLen: Integer; var Dst: PTLSEncrypted; var CTLen: Integer; var Error: Integer); override;

classtTLSEncryption11Block

inherits from tTLSEncryption10Block

(no public members)

classtTLSEncryption11BlockEtM

inherits from tTLSEncryption10BlockEtM

(no public members)

classtTLSEncryption12Aead

inherits from tTLSEncryption

constructor Create(const aKeys : tTLSKeys; aCipherClass: tCipherClass; aRecIVLength: Integer; aServerWrite: Boolean); destructor Destroy; override; procedure Decrypt(Src: PTLSEncrypted; CTLen: Integer; var Dst: PTLSCompressed; var CLen: Integer; var Error: Integer); override; procedure Encrypt(Src: PTLSCompressed; CLen: Integer; var Dst: PTLSEncrypted; var CTLen: Integer; var Error: Integer); override; function NewRecordIV(var aIV): Boolean; override;

classtTLSEncryption12Poly1305

inherits from tTLSEncryption

RFC 7905: implicit-nonce AEAD (ChaCha20-Poly1305) for TLS 1.2. Unlike tTLSEncryption12Aead (AES-GCM, with an 8-byte explicit per-record nonce), the 12-byte nonce is write_iv XOR seq_num (as in TLS 1.3) and there is NO explicit record IV on the wire (RecordIVLength = 0). The additional_data keeps the TLS 1.2 form: seq_num(8) || type(1) || version(2) || length(2). The cipher is driven through iCompoundMode, never iGCMParameters.

constructor Create(const aKeys : tTLSKeys; aCipherClass: tCipherClass; aServerWrite: Boolean); destructor Destroy; override; procedure Decrypt(Src: PTLSEncrypted; CTLen: Integer; var Dst: PTLSCompressed; var CLen: Integer; var Error: Integer); override; procedure Encrypt(Src: PTLSCompressed; CLen: Integer; var Dst: PTLSEncrypted; var CTLen: Integer; var Error: Integer); override;

classtTLSEncryption13Aead

inherits from tTLSEncryption

TLS 1.3 (NEW): AEAD record protection per RFC 8446 sec.5.2 / 5.3. Differences from tTLSEncryption12Aead:
* per-record nonce = write_iv XOR seq_num (the iv is the full 12-byte static value; there is NO explicit nonce on the wire, so RecordIVLength = 0);
* additional_data = the 5-byte record header only - opaque_type (=23, application_data), legacy_record_version (=0x0303) and length - with NO sequence number folded in (the seq_num lives in the nonce);
* the genuine content type travels as the last byte of the inner plaintext (TLSInnerPlaintext), and the outer record type is always 23. Encrypt appends that type byte; the matching strip on the receive side is done by TTLS_RecordLayer.RecordLayerDecodeNext (StreamSec.Mobile. TlsLayer), so Decrypt here only removes the AEAD tag.

constructor Create(const aKeys : tTLSKeys; aCipherClass: tCipherClass; aServerWrite: Boolean); destructor Destroy; override; procedure Decrypt(Src: PTLSEncrypted; CTLen: Integer; var Dst: PTLSCompressed; var CLen: Integer; var Error: Integer); override; procedure Encrypt(Src: PTLSCompressed; CLen: Integer; var Dst: PTLSEncrypted; var CTLen: Integer; var Error: Integer); override;