abla/tls/pure/record

Generated from source.

Import with import "abla/tls/pure/record".

Source: abla/tls/pure/record/entry.ab

TLS_CHANGE_CIPHER_SPEC (val)

val TLS_CHANGE_CIPHER_SPEC

TLS record type for a ChangeCipherSpec message.

TLS_ALERT (val)

val TLS_ALERT

TLS record type carrying an alert.

TLS_HANDSHAKE (val)

val TLS_HANDSHAKE

TLS record type carrying handshake message bytes.

TLS_APPLICATION_DATA (val)

val TLS_APPLICATION_DATA

TLS record type for application data or encrypted TLS 1.3 content.

TLS_AEAD_AES_128_GCM (val)

val TLS_AEAD_AES_128_GCM

Record protection selector for AES-128-GCM.

TLS_AEAD_AES_256_GCM (val)

val TLS_AEAD_AES_256_GCM

Record protection selector for AES-256-GCM.

TLS_AEAD_CHACHA20_POLY1305 (val)

val TLS_AEAD_CHACHA20_POLY1305

Record protection selector for ChaCha20-Poly1305.

TLS_MAX_PLAINTEXT (val)

val TLS_MAX_PLAINTEXT

The most plaintext one record carries (section 5.1), and the most a protected record's payload (ciphertext with its tag) may be (section 5.2).

TLS_MAX_EMPTY_RUN (val)

val TLS_MAX_EMPTY_RUN

Maximum accepted run of consecutive empty records.

TLS_MAX_SEQUENCE (val)

val TLS_MAX_SEQUENCE

RFC 8446 section 5.5: a key protects a limited number of records. AES-GCM: 2^24 (the analysis allows 2^24.5), after which the sender updates its key; ChaCha20-Poly1305 has no limit that matters, 2^34 is far inside it. A sequence number never wraps: past 2^62 records nothing more is sealed or opened.

tlsRecordLimit (fun)

fun tlsRecordLimit(aead: int): int

Returns the per-key record limit, using the larger allowance for ChaCha20-Poly1305.

TLS_MAX_CIPHERTEXT (val)

val TLS_MAX_CIPHERTEXT

Maximum TLS 1.3 ciphertext record length in bytes.

TlsRecordProtection (class)

class TlsRecordProtection(val aead: int, val key: string, val iv: string, var sequence: int, var gcm: AesGcmKey? = null)

One direction's protection: the traffic key, the IV (12 bytes) and the next record's sequence number.

tlsRecordProtectionRelease (fun)

fun tlsRecordProtectionRelease(var protection: TlsRecordProtection): void

Ends what a protection holds beyond its key and IV strings (which its owner wipes): the expanded AES key (dropped: wiped and freed).

tlsRecordProtection (fun)

fun tlsRecordProtection(aead: int, key: string, iv: string): TlsRecordProtection

Returns fresh protection state using the supplied algorithm, key, and IV and a zero sequence number.

tlsAeadKeyLength (fun)

fun tlsAeadKeyLength(aead: int): int

The key length of an AEAD, 0 for one this layer does not know.

tlsRecordNonce (fun)

fun tlsRecordNonce(iv: string, sequence: int): string

The per-record nonce: the IV with the sequence number (big-endian, left-padded to 12 bytes) xored in.

TlsRecordHeader (class)

class TlsRecordHeader(val ok: bool, val type: int, val version: int, val length: int)

A record header: type, legacy version, payload length.

tlsPlaintextRecord (fun)

fun tlsPlaintextRecord(type: int, version: int, content: string): string

A plaintext record (used before the handshake keys exist): a header with the legacy version (0x0301 on a first ClientHello for compatibility, else 0x0303), then the content as is.

tlsParseRecordHeader (fun)

fun tlsParseRecordHeader(data: string, offset: int): TlsRecordHeader

Reads the 5-byte header at offset of data. ok is false when fewer than five bytes remain.

TlsOpenedRecord (class)

class TlsOpenedRecord(val ok: bool, val type: int, val content: string, val error: string)

The result of opening one record: the inner content type and the content.

tlsProtectRecord (fun)

fun tlsProtectRecord(var protection: TlsRecordProtection, contentType: int, content: string,
    padding: int = 0): CryptoResult

Protects one record's content: the 5-byte header (application_data, 0x0303), then the AEAD of content || type || padding zero bytes. The result's bytes are the whole record; ok is false for a content longer than 2^14 or an unusable key.

tlsOpenRecord (fun)

fun tlsOpenRecord(var protection: TlsRecordProtection, record: string): TlsOpenedRecord

Opens one whole record (header included) that protection protected: checks the header (type application_data, version 0x0303, a length that matches record and is at most 2^14 + 256), authenticates and decrypts, strips the zero padding and the content type. A record that is all zeros inside, or whose content exceeds 2^14, is refused.

Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.