modus
Menu
On this page

The module tls_tcp

TLS 1.3 over TCP and the wire borders of QUIC as a library module of the system.

Each export calls the support packages modus:tls_tcp and modus:quic over bytes and tables of the caller, so a process that imports the module reads and writes the same bytes as a process that compiles the packages in.

  • The caller supplies the memory: the module allocates nothing and keeps nothing between two calls. It has no package variable that is not read-only: a library module has no data that the loader writes for one base.
  • The bytes are hostile input: in an isolated call they are in the call region, which another thread can change during the call. Each export copies the few bytes that it reads into its own frame once, then checks and reads the copy only.
  • A refusal is an error record and a negative result, and it writes no byte and no record of the caller.

See: From the desktop of today to a light web browser in the repository, Shared libraries as modules: where the border goes in the repository, Shared libraries as modules: where the border goes: The subtle points in the repository

tls_tcp module with no entry

Hash
d4cb34d1946c601ba3bbc18ee00a7ffdf5578fccd041581a332d537a37ebb6d5
Size
24576 bytes
Exports
8
Imports
0
Imported by
0
License
MIT

TLS 1.3 over TCP and the wire borders of QUIC as a library module of the system

FactValue
KindModules with no entry
Sourcesrc/modules/libraries/tls_tcp
Boot imageyes: in the boot image, 24576 bytes in this build
Build settingsnone: the defaults of the source
Importsnone
Imported bynone

Neighbours

It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.

Exports

ExportWhat it does
cipher_suite_supported(suite_word: Integer) -> Integerreports whether suite_word names a TLS 1.3 cipher suite implemented by this module (1 = supported, 0 = unsupported)
record_max_plaintext_bytes() -> Integerreturns the RFC 8446 maximum plaintext record payload size in bytes (16 384)
record_max_ciphertext_bytes() -> Integerreturns the RFC 8446 maximum encrypted record payload size in bytes (16 640)
tls_record_header_parse(input: Bytes(Read), header: Table(Record_Header, Change)) -> Integerreads the 5-byte header of a TLS 1.3 record (RFC 8446, section 5.1) at the start of the bytes of argument 1, and writes it into the first record of the table of argument 2: its content type, its legacy version and the length of its payload
tls_record_header_write(content_type_word: Integer, payload_length: Integer, output: Bytes(Change)) -> Integerwrites the 5-byte header of a TLS 1.3 record (RFC 8446, section 5.1) at the start of the bytes of argument 3: the content type, the legacy version 0x0303, and the payload length, the most significant byte first
quic_variable_length_integer_read(input: Bytes(Read), integer: Table(Variable_Length_Integer, Change)) -> Integerreads the variable-length integer of QUIC (RFC 9000, section 16) at the start of the bytes of argument 1, and writes its value and its size into the first record of the table of argument 2
quic_variable_length_integer_write(value: Integer, output: Bytes(Change)) -> Integerwrites a value as a variable-length integer of QUIC (RFC 9000, section 16), in its shortest encoding, at the start of the bytes of argument 2
quic_header_probe(packet: Bytes(Read), probe: Table(Quic_Header_Probe, Change)) -> Integerreads the form of the header of a QUIC packet at the start of the bytes of argument 1 and, for a long header, its version (RFC 9000, sections 17.2 and 17.3), into the first record of the table of argument 2

cipher_suite_supported

cipher_suite_supported(suite_word: ) -> 

cipher_suite_supported reports whether suite_word names a TLS 1.3 cipher suite implemented by this module (1 = supported, 0 = unsupported).

Parameters
  • suite_word:
Result
When it fails
a negative result, and the error record
Source
src/modules/libraries/tls_tcp/tls_tcp.odin:63

record_max_plaintext_bytes

record_max_plaintext_bytes() -> 

record_max_plaintext_bytes returns the RFC 8446 maximum plaintext record payload size in bytes (16 384).

Parameters
none
Result
Source
src/modules/libraries/tls_tcp/tls_tcp.odin:74

record_max_ciphertext_bytes

record_max_ciphertext_bytes() -> 

record_max_ciphertext_bytes returns the RFC 8446 maximum encrypted record payload size in bytes (16 640).

Parameters
none
Result
Source
src/modules/libraries/tls_tcp/tls_tcp.odin:81

tls_record_header_parse

tls_record_header_parse(input: (Read), header: (, Change)) -> 

tls_record_header_parse reads the 5-byte header of a TLS 1.3 record (RFC 8446, section 5.1) at the start of the bytes of argument 1, and writes it into the first record of the table of argument 2: its content type, its legacy version and the length of its payload. The result is 5, the bytes of the header, or -1 with an error record: a nil place, or a nil address with bytes (Bad_Address); fewer than 5 bytes (Too_Small, argument 1: value the count, limit 5); a table with no record (Too_Small, argument 2, Records: value the count, limit 1); a content type that is not 20 to 23 (Bad_Value, argument 1: value the byte, limit 23, found 1, the number of the byte); a legacy version other than 0x0303 (Bad_Value, argument 1: value the version, limit 0x0303, found 2); a length over 16 640 for application data or over 16 384 for another type (Too_Long, argument 1: value the length, limit the most). The first ClientHello with the legacy version 0x0301 is refused too: the handshake of the package reads that one record. Nothing is written on a refusal.

Parameters
  • input: (Read)
  • header: (, Change)
Result
When it fails
a negative result, and the error record
Source
src/modules/libraries/tls_tcp/tls_tcp.odin:87

tls_record_header_write

tls_record_header_write(content_type_word: , payload_length: , output: (Change)) -> 

tls_record_header_write writes the 5-byte header of a TLS 1.3 record (RFC 8446, section 5.1) at the start of the bytes of argument 3: the content type, the legacy version 0x0303, and the payload length, the most significant byte first. The result is 5, or -1 with an error record: a content type that is not 20 to 23 (Bad_Value, argument 1: value the word, limit 23); a negative length (Bad_Value, argument 2: value the length, limit the most); a length over 16 640 for application data or over 16 384 for another type (Too_Long, argument 2: value the length, limit the most); a nil place, or a nil address with bytes (Bad_Address, argument 3, found 1); fewer than 5 bytes (Too_Small, argument 3: value the count, limit 5). Nothing is written on a refusal.

Parameters
  • content_type_word:
  • payload_length:
  • output: (Change)
Result
When it fails
a negative result, and the error record
Source
src/modules/libraries/tls_tcp/tls_tcp.odin:154

quic_variable_length_integer_read

quic_variable_length_integer_read(input: (Read), integer: (, Change)) -> 

quic_variable_length_integer_read reads the variable-length integer of QUIC (RFC 9000, section 16) at the start of the bytes of argument 1, and writes its value and its size into the first record of the table of argument 2. The result is the bytes that it takes, 1, 2, 4 or 8, or -1 with an error record: a nil place, or a nil address with bytes (Bad_Address); no byte (Too_Small, argument 1: value 0, limit 1); fewer bytes than the two high bits of the first byte name (Too_Small, argument 1: value the count, limit the size); a table with no record (Too_Small, argument 2, Records: value the count, limit 1). It accepts an encoding longer than the shortest, as RFC 9000 does outside a frame type. Nothing is written on a refusal.

Parameters
  • input: (Read)
  • integer: (, Change)
Result
When it fails
a negative result, and the error record
Source
src/modules/libraries/tls_tcp/tls_tcp.odin:189

quic_variable_length_integer_write

quic_variable_length_integer_write(value: , output: (Change)) -> 

quic_variable_length_integer_write writes a value as a variable-length integer of QUIC (RFC 9000, section 16), in its shortest encoding, at the start of the bytes of argument 2. The result is the bytes written, 1, 2, 4 or 8, or -1 with an error record: a negative value or a value over 2^62 - 1 (Bad_Value, argument 1: value the value, limit 2^62 - 1); a nil place, or a nil address with bytes (Bad_Address, argument 2, found 1); fewer bytes than the encoding takes (Too_Small, argument 2: value the count, limit the size). Nothing is written on a refusal.

Parameters
  • value:
  • output: (Change)
Result
When it fails
a negative result, and the error record
Source
src/modules/libraries/tls_tcp/tls_tcp.odin:225

quic_header_probe

quic_header_probe(packet: (Read), probe: (, Change)) -> 

quic_header_probe reads the form of the header of a QUIC packet at the start of the bytes of argument 1 and, for a long header, its version (RFC 9000, sections 17.2 and 17.3), into the first record of the table of argument 2. It is the first look of a receiver, before it chooses a connection: it reads no connection identifier and no length. The result is the bytes read, 1 for a short header and 5 for a long header, or -1 with an error record: a nil place, or a nil address with bytes (Bad_Address); no byte, or a long header of fewer than 5 bytes (Too_Small, argument 1: value the count, limit 1 or 5); a table with no record (Too_Small, argument 2, Records: value the count, limit 1); the Fixed Bit clear in a short header or in a long header of version 1 (Bad_Value, argument 1: value the first byte, limit 0x40, found 1, the number of the byte). A long header of another version, Version Negotiation (version 0) included, has no Fixed Bit to check. Nothing is written on a refusal.

Parameters
  • packet: (Read)
  • probe: (, Change)
Result
When it fails
a negative result, and the error record
Source
src/modules/libraries/tls_tcp/tls_tcp.odin:245

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

Integer wire form

A wire form of the module contract: one word of a call. A signed integer of 64 bits, in a register.

Error_Record record of a module

A record of the module tls_tcp: 56 bytes, aligned on 8 bytes, 0 bytes of padding.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

Bytes wire form

A wire form of the module contract: one word of a call. Bytes with no description.

Table wire form

A wire form of the module contract: one word of a call. Records of one description that follow each other (a table).

Record_Header record of a module

A record of the module tls_tcp: 6 bytes, aligned on 2 bytes, 1 bytes of padding.

  • content_typeu801 bytes
  • padding11 bytes
  • legacy_versionu1622 bytes
  • lengthu1642 bytes

Variable_Length_Integer record of a module

A record of the module tls_tcp: 16 bytes, aligned on 8 bytes, 0 bytes of padding.

  • valuei6408 bytes
  • sizei6488 bytes

Quic_Header_Probe record of a module

A record of the module tls_tcp: 8 bytes, aligned on 4 bytes, 3 bytes of padding.

  • formu801 bytes
  • padding13 bytes
  • versionu3244 bytes