# std::tls API Reference

Public declarations reachable through the documented package entry points. Signatures follow the source snapshot; consult the module guide for support and qualification boundaries.


## Application entry points

Read the [TLS protocol-owner guide](tls.md) for record state, explicit certificate trust and the client-handshake sequence. This inventory does not provide a connected `TlsStream`; raw codecs and test fixtures do not establish network interoperability.

<a id="TLS_ALERT_WIRE_BYTES"></a>

### TLS_ALERT_WIRE_BYTES

Import: `"tls"`.

```vex
export const TLS_ALERT_WIRE_BYTES: usize=2 as usize;
```

<a id="TLS_SIGNATURE_ED25519"></a>

### TLS_SIGNATURE_ED25519

Import: `"tls"`.

```vex
export const TLS_SIGNATURE_ED25519: u16=0x0807 as u16;
```

<a id="TLS_MAX_CERTIFICATE_ENTRIES"></a>

### TLS_MAX_CERTIFICATE_ENTRIES

Import: `"tls"`.

```vex
export const TLS_MAX_CERTIFICATE_ENTRIES: usize=9 as usize;
```

<a id="TLS_MAX_CERTIFICATE_ENTRY_EXTENSIONS"></a>

### TLS_MAX_CERTIFICATE_ENTRY_EXTENSIONS

Import: `"tls"`.

```vex
export const TLS_MAX_CERTIFICATE_ENTRY_EXTENSIONS: usize=32 as usize;
```

<a id="HANDSHAKE_TYPE_CLIENT_HELLO"></a>

### HANDSHAKE_TYPE_CLIENT_HELLO

Import: `"tls"`.

```vex
export const HANDSHAKE_TYPE_CLIENT_HELLO: u8=1;
```

<a id="HANDSHAKE_TYPE_SERVER_HELLO"></a>

### HANDSHAKE_TYPE_SERVER_HELLO

Import: `"tls"`.

```vex
export const HANDSHAKE_TYPE_SERVER_HELLO: u8=2;
```

<a id="HANDSHAKE_TYPE_ENCRYPTED_EXTENSIONS"></a>

### HANDSHAKE_TYPE_ENCRYPTED_EXTENSIONS

Import: `"tls"`.

```vex
export const HANDSHAKE_TYPE_ENCRYPTED_EXTENSIONS: u8=8;
```

<a id="HANDSHAKE_TYPE_CERTIFICATE"></a>

### HANDSHAKE_TYPE_CERTIFICATE

Import: `"tls"`.

```vex
export const HANDSHAKE_TYPE_CERTIFICATE: u8=11;
```

<a id="HANDSHAKE_TYPE_CERTIFICATE_VERIFY"></a>

### HANDSHAKE_TYPE_CERTIFICATE_VERIFY

Import: `"tls"`.

```vex
export const HANDSHAKE_TYPE_CERTIFICATE_VERIFY: u8=15;
```

<a id="HANDSHAKE_TYPE_FINISHED"></a>

### HANDSHAKE_TYPE_FINISHED

Import: `"tls"`.

```vex
export const HANDSHAKE_TYPE_FINISHED: u8=20;
```

<a id="HANDSHAKE_TYPE_KEY_UPDATE"></a>

### HANDSHAKE_TYPE_KEY_UPDATE

Import: `"tls"`.

```vex
export const HANDSHAKE_TYPE_KEY_UPDATE: u8=24;
```

<a id="TLS_LEGACY_VERSION"></a>

### TLS_LEGACY_VERSION

Import: `"tls"`.

```vex
export const TLS_LEGACY_VERSION: u16=0x0303 as u16;
```

<a id="TLS_EXTENSION_SERVER_NAME"></a>

### TLS_EXTENSION_SERVER_NAME

Import: `"tls"`.

```vex
export const TLS_EXTENSION_SERVER_NAME: u16=0 as u16;
```

<a id="TLS_EXTENSION_SUPPORTED_GROUPS"></a>

### TLS_EXTENSION_SUPPORTED_GROUPS

Import: `"tls"`.

```vex
export const TLS_EXTENSION_SUPPORTED_GROUPS: u16=10 as u16;
```

<a id="TLS_EXTENSION_SIGNATURE_ALGORITHMS"></a>

### TLS_EXTENSION_SIGNATURE_ALGORITHMS

Import: `"tls"`.

```vex
export const TLS_EXTENSION_SIGNATURE_ALGORITHMS: u16=13 as u16;
```

<a id="TLS_EXTENSION_ALPN"></a>

### TLS_EXTENSION_ALPN

Import: `"tls"`.

```vex
export const TLS_EXTENSION_ALPN: u16=16 as u16;
```

<a id="TLS_EXTENSION_PADDING"></a>

### TLS_EXTENSION_PADDING

Import: `"tls"`.

```vex
export const TLS_EXTENSION_PADDING: u16=21 as u16;
```

<a id="TLS_EXTENSION_PRE_SHARED_KEY"></a>

### TLS_EXTENSION_PRE_SHARED_KEY

Import: `"tls"`.

```vex
export const TLS_EXTENSION_PRE_SHARED_KEY: u16=41 as u16;
```

<a id="TLS_EXTENSION_EARLY_DATA"></a>

### TLS_EXTENSION_EARLY_DATA

Import: `"tls"`.

```vex
export const TLS_EXTENSION_EARLY_DATA: u16=42 as u16;
```

<a id="TLS_EXTENSION_SUPPORTED_VERSIONS"></a>

### TLS_EXTENSION_SUPPORTED_VERSIONS

Import: `"tls"`.

```vex
export const TLS_EXTENSION_SUPPORTED_VERSIONS: u16=43 as u16;
```

<a id="TLS_EXTENSION_COOKIE"></a>

### TLS_EXTENSION_COOKIE

Import: `"tls"`.

```vex
export const TLS_EXTENSION_COOKIE: u16=44 as u16;
```

<a id="TLS_EXTENSION_PSK_KEY_EXCHANGE_MODES"></a>

### TLS_EXTENSION_PSK_KEY_EXCHANGE_MODES

Import: `"tls"`.

```vex
export const TLS_EXTENSION_PSK_KEY_EXCHANGE_MODES: u16=45 as u16;
```

<a id="TLS_EXTENSION_KEY_SHARE"></a>

### TLS_EXTENSION_KEY_SHARE

Import: `"tls"`.

```vex
export const TLS_EXTENSION_KEY_SHARE: u16=51 as u16;
```

<a id="TLS_NAMED_GROUP_X25519"></a>

### TLS_NAMED_GROUP_X25519

Import: `"tls"`.

```vex
export const TLS_NAMED_GROUP_X25519: u16=29 as u16;
```

<a id="TLS_MAX_HELLO_EXTENSIONS"></a>

### TLS_MAX_HELLO_EXTENSIONS

Import: `"tls"`.

```vex
export const TLS_MAX_HELLO_EXTENSIONS: usize=64 as usize;
```

<a id="TLS_MAX_HELLO_CIPHER_SUITES"></a>

### TLS_MAX_HELLO_CIPHER_SUITES

Import: `"tls"`.

```vex
export const TLS_MAX_HELLO_CIPHER_SUITES: usize=256 as usize;
```

<a id="TLS_MAX_HELLO_GROUPS"></a>

### TLS_MAX_HELLO_GROUPS

Import: `"tls"`.

```vex
export const TLS_MAX_HELLO_GROUPS: usize=64 as usize;
```

<a id="TLS_MAX_HELLO_SIGNATURE_SCHEMES"></a>

### TLS_MAX_HELLO_SIGNATURE_SCHEMES

Import: `"tls"`.

```vex
export const TLS_MAX_HELLO_SIGNATURE_SCHEMES: usize=64 as usize;
```

<a id="TLS_KEY_UPDATE_WIRE_BYTES"></a>

### TLS_KEY_UPDATE_WIRE_BYTES

Import: `"tls"`.

```vex
export const TLS_KEY_UPDATE_WIRE_BYTES: usize=5 as usize;
```

<a id="TLS_MAX_NEGOTIATION_ALPN_BYTES"></a>

### TLS_MAX_NEGOTIATION_ALPN_BYTES

Import: `"tls"`.

```vex
export const TLS_MAX_NEGOTIATION_ALPN_BYTES: usize=1024 as usize;
```

<a id="TLS_MAX_SELECTED_ALPN_BYTES"></a>

### TLS_MAX_SELECTED_ALPN_BYTES

Import: `"tls"`.

```vex
export const TLS_MAX_SELECTED_ALPN_BYTES: usize=255 as usize;
```

<a id="TLS_MAX_RETRY_COOKIE_BYTES"></a>

### TLS_MAX_RETRY_COOKIE_BYTES

Import: `"tls"`.

```vex
export const TLS_MAX_RETRY_COOKIE_BYTES: usize=4096 as usize;
```

<a id="CONTENT_TYPE_CHANGE_CIPHER_SPEC"></a>

### CONTENT_TYPE_CHANGE_CIPHER_SPEC

Import: `"tls"`.

```vex
export const CONTENT_TYPE_CHANGE_CIPHER_SPEC: u8=20;
```

<a id="CONTENT_TYPE_ALERT"></a>

### CONTENT_TYPE_ALERT

Import: `"tls"`.

```vex
export const CONTENT_TYPE_ALERT: u8=21;
```

<a id="CONTENT_TYPE_HANDSHAKE"></a>

### CONTENT_TYPE_HANDSHAKE

Import: `"tls"`.

```vex
export const CONTENT_TYPE_HANDSHAKE: u8=22;
```

<a id="CONTENT_TYPE_APPLICATION_DATA"></a>

### CONTENT_TYPE_APPLICATION_DATA

Import: `"tls"`.

```vex
export const CONTENT_TYPE_APPLICATION_DATA: u8=23;
```

<a id="TLS_VERSION_1_2"></a>

### TLS_VERSION_1_2

Import: `"tls"`.

```vex
export const TLS_VERSION_1_2: u16=0x0303;
```

<a id="TLS_VERSION_1_3"></a>

### TLS_VERSION_1_3

Import: `"tls"`.

```vex
export const TLS_VERSION_1_3: u16=0x0304;
```

<a id="CIPHER_AES_128_GCM_SHA256"></a>

### CIPHER_AES_128_GCM_SHA256

Import: `"tls"`.

```vex
export const CIPHER_AES_128_GCM_SHA256: u16=0x1301;
```

<a id="CIPHER_AES_256_GCM_SHA384"></a>

### CIPHER_AES_256_GCM_SHA384

Import: `"tls"`.

```vex
export const CIPHER_AES_256_GCM_SHA384: u16=0x1302;
```

<a id="CIPHER_CHACHA20_POLY1305_SHA256"></a>

### CIPHER_CHACHA20_POLY1305_SHA256

Import: `"tls"`.

```vex
export const CIPHER_CHACHA20_POLY1305_SHA256: u16=0x1303;
```

<a id="TLS_HANDSHAKE_HEADER_LEN"></a>

### TLS_HANDSHAKE_HEADER_LEN

Import: `"tls"`.

```vex
export const TLS_HANDSHAKE_HEADER_LEN: usize=4 as usize;
```

<a id="TLS_MAX_HANDSHAKE_BODY_LEN"></a>

### TLS_MAX_HANDSHAKE_BODY_LEN

Import: `"tls"`.

```vex
export const TLS_MAX_HANDSHAKE_BODY_LEN: usize=0x00ff_ffff as usize;
```

<a id="TLS_DEFAULT_TRANSCRIPT_LIMIT"></a>

### TLS_DEFAULT_TRANSCRIPT_LIMIT

Import: `"tls"`.

```vex
export const TLS_DEFAULT_TRANSCRIPT_LIMIT: usize=16 as usize * 1024 as usize * 1024 as usize;
```

<a id="TLS_MAX_TRANSCRIPT_LIMIT"></a>

### TLS_MAX_TRANSCRIPT_LIMIT

Import: `"tls"`.

```vex
export const TLS_MAX_TRANSCRIPT_LIMIT: usize=64 as usize * 1024 as usize * 1024 as usize;
```

<a id="HANDSHAKE_TYPE_MESSAGE_HASH"></a>

### HANDSHAKE_TYPE_MESSAGE_HASH

Import: `"tls"`.

```vex
export const HANDSHAKE_TYPE_MESSAGE_HASH: u8=254 as u8;
```

<a id="X509_MAX_INTERMEDIATES"></a>

### X509_MAX_INTERMEDIATES

Import: `"tls"`.

```vex
export const X509_MAX_INTERMEDIATES: usize=8 as usize;
```

<a id="TlsAlert"></a>

### TlsAlert

Import: `"tls"`.

```vex
export struct TlsAlert
```

**Implements:** `Copy`

**Public fields:**

- `level`: `TlsAlertLevel`
- `description`: `TlsAlertDescription`

<a id="TlsHandshakeFeedResult"></a>

### TlsHandshakeFeedResult

Import: `"tls"`.

```vex
export struct TlsHandshakeFeedResult
```

**Implements:** `Copy`

**Public fields:**

- `kind`: `TlsHandshakeFeedKind`
- `consumed`: `usize`
- `messageType`: `u8`
- `bodyLen`: `usize`
- `encodedLen`: `usize`

<a id="TlsHandshakeAssembler"></a>

### TlsHandshakeAssembler

Import: `"tls"`.

```vex
export struct TlsHandshakeAssembler
```

Allocation-free, one-message-at-a-time TLS Handshake assembler.

The common aligned path is zero-copy. A fragmented message is written into
a caller-owned span whose address must remain stable until completion. This
makes lifetime, allocation policy, and maximum certificate size explicit
at the connection layer instead of hiding them in TLS.

<a id="TlsCertificateEntryView"></a>

### TlsCertificateEntryView

Import: `"tls"`.

```vex
export struct TlsCertificateEntryView
```

**Implements:** `Copy`

**Public fields:**

- `certificate`: `TlsWireSlice`
- `extensions`: `TlsWireSlice`
- `extensionCount`: `usize`

<a id="TlsCertificateMessageView"></a>

### TlsCertificateMessageView

Import: `"tls"`.

```vex
export struct TlsCertificateMessageView
```

**Implements:** `Copy`

**Public fields:**

- `certificateList`: `TlsWireSlice`
- `certificateCount`: `usize`

<a id="TlsCertificateVerifyView"></a>

### TlsCertificateVerifyView

Import: `"tls"`.

```vex
export struct TlsCertificateVerifyView
```

**Implements:** `Copy`

**Public fields:**

- `algorithm`: `u16`
- `signature`: `TlsWireSlice`

<a id="TlsTrafficKeyLengths"></a>

### TlsTrafficKeyLengths

Import: `"tls"`.

```vex
export struct TlsTrafficKeyLengths
```

**Implements:** `Copy`

**Public fields:**

- `key`: `usize`
- `iv`: `usize`

<a id="TlsWireSlice"></a>

### TlsWireSlice

Import: `"tls"`.

```vex
export struct TlsWireSlice
```

Offset/length pair into the complete encoded Handshake message. No pointer

escapes the input lifetime; callers resolve the view against the same
encoded span when needed.

**Implements:** `Copy`

**Public fields:**

- `present`: `bool`
- `offset`: `usize`
- `length`: `usize`

<a id="TlsHelloExtensions"></a>

### TlsHelloExtensions

Import: `"tls"`.

```vex
export struct TlsHelloExtensions
```

**Implements:** `Copy`

**Public fields:**

- `count`: `usize`
- `encodedBlock`: `TlsWireSlice`
- `supportedVersions`: `TlsWireSlice`
- `supportedGroups`: `TlsWireSlice`
- `signatureAlgorithms`: `TlsWireSlice`
- `keyShare`: `TlsWireSlice`
- `serverName`: `TlsWireSlice`
- `alpn`: `TlsWireSlice`
- `preSharedKey`: `TlsWireSlice`
- `pskKeyExchangeModes`: `TlsWireSlice`
- `cookie`: `TlsWireSlice`

<a id="TlsExtensionEntry"></a>

### TlsExtensionEntry

Import: `"tls"`.

```vex
export struct TlsExtensionEntry
```

**Implements:** `Copy`

**Public fields:**

- `extensionType`: `u16`
- `data`: `TlsWireSlice`

<a id="TlsKeyShareEntry"></a>

### TlsKeyShareEntry

Import: `"tls"`.

```vex
export struct TlsKeyShareEntry
```

**Implements:** `Copy`

**Public fields:**

- `group`: `u16`
- `keyExchange`: `TlsWireSlice`

<a id="TlsClientHelloView"></a>

### TlsClientHelloView

Import: `"tls"`.

```vex
export struct TlsClientHelloView
```

**Implements:** `Copy`

**Public fields:**

- `encodedLen`: `usize`
- `random`: `[u8; 32]`
- `sessionId`: `TlsWireSlice`
- `cipherSuites`: `TlsWireSlice`
- `cipherSuiteCount`: `usize`
- `extensions`: `TlsHelloExtensions`

<a id="TlsServerHelloView"></a>

### TlsServerHelloView

Import: `"tls"`.

```vex
export struct TlsServerHelloView
```

**Implements:** `Copy`

**Public fields:**

- `encodedLen`: `usize`
- `random`: `[u8; 32]`
- `sessionId`: `TlsWireSlice`
- `cipherSuite`: `u16`
- `helloRetryRequest`: `bool`
- `extensions`: `TlsHelloExtensions`

<a id="TlsDnsIdentityError"></a>

### TlsDnsIdentityError

Import: `"tls"`.

```vex
export struct TlsDnsIdentityError
```

**Implements:** `Copy`

**Public fields:**

- `kind`: `TlsDnsIdentityErrorKind`
- `offset`: `usize`

<a id="TlsDnsIdentity"></a>

### TlsDnsIdentity

Import: `"tls"`.

```vex
export struct TlsDnsIdentity
```

Strict service-identity matcher. This API compares a DNS reference name

only with an X.509 subjectAltName dNSName. It deliberately has no common
name fallback and does not reinterpret IP literals as DNS names.

<a id="TlsSecretSchedule"></a>

### TlsSecretSchedule

Import: `"tls"`.

```vex
export struct TlsSecretSchedule
```

Move-only owner of the current raw secret on the left side of RFC 8446's

key-schedule diagram. Only ordered Early -&gt; Handshake -&gt; Master transitions
are exposed. Working secrets are erased on every transition and on Drop.

**Implements:** `Drop`

<a id="TlsX25519Negotiation"></a>

### TlsX25519Negotiation

Import: `"tls"`.

```vex
export struct TlsX25519Negotiation
```

Move-only owner for the authenticated no-PSK TLS 1.3 client handshake.

Hello negotiation is also usable in server role, while the monotonic server
authentication flight is client-only. Transcript, key schedule, offered
capabilities and Finished traffic secrets have one lifetime and one state
authority; borrowed wire views never escape a call.

**Implements:** `Drop`

<a id="TlsRecordHeader"></a>

### TlsRecordHeader

Import: `"tls"`.

```vex
export struct TlsRecordHeader
```

**Public fields:**

- `contentType`: `u8`
- `version`: `u16`
- `length`: `u16`

<a id="TlsPlaintext"></a>

### TlsPlaintext

Import: `"tls"`.

```vex
export struct TlsPlaintext
```

Metadata recovered from an authenticated TLSInnerPlaintext.

**Implements:** `Copy`

**Public fields:**

- `length`: `u64`
- `contentType`: `u8`

<a id="TlsCipherState"></a>

### TlsCipherState

Import: `"tls"`.

```vex
export struct TlsCipherState
```

Owning, move-only per-direction TLS 1.3 record state.

Key material and the sequence number are deliberately private. Exposing a
writable sequence would let application code reuse a nonce with the same
traffic key, which is catastrophic for every supported AEAD.

**Implements:** `Drop`

<a id="TlsHandshakeHeader"></a>

### TlsHandshakeHeader

Import: `"tls"`.

```vex
export struct TlsHandshakeHeader
```

The exact four-byte TLS Handshake header: one-byte type and uint24 body

length. Record-layer headers are intentionally outside this type.

**Implements:** `Copy`

**Public fields:**

- `messageType`: `u8`
- `bodyLen`: `usize`

<a id="TlsTranscript"></a>

### TlsTranscript

Import: `"tls"`.

```vex
export struct TlsTranscript
```

Streaming, allocation-free TLS 1.3 transcript state.

`acceptedBytes` is a monotonic resource-accounting counter and is never
reduced by HelloRetryRequest rewriting. `hashedBytes` reports the effective
transcript size after the RFC 8446 synthetic `message_hash` replacement.

**Implements:** `Drop`

<a id="TlsTransportEvent"></a>

### TlsTransportEvent

Import: `"tls"`.

```vex
export struct TlsTransportEvent
```

**Public fields:**

- `kind`: `TlsTransportEventKind`
- `length`: `usize`
- `alert`: `Option<TlsAlert>`
- `keyUpdate`: `Option<TlsKeyUpdateRequest>`

<a id="TlsTransportError"></a>

### TlsTransportError

Import: `"tls"`.

```vex
export struct TlsTransportError
```

Typed transport failure with the exact lower-layer cause retained when one

exists. Caller-capacity/overlap mistakes remain retryable; authenticated
wire failures retire both traffic directions.

**Public fields:**

- `kind`: `TlsTransportErrorKind`
- `recordCause`: `Option<TlsRecordError>`
- `alertCause`: `Option<TlsAlertError>`
- `scheduleCause`: `Option<TlsKeyScheduleError>`
- `keyUpdateCause`: `Option<TlsKeyUpdateError>`

<a id="TlsApplicationTraffic"></a>

### TlsApplicationTraffic

Import: `"tls"`.

```vex
export struct TlsApplicationTraffic
```

Owns exactly one protected send direction and one protected receive

direction after generation-0 application traffic secrets exist.
The constructor derives keys directly into bounded stack candidates,
transfers them into move-only cipher states, then erases every candidate.
Callers pass directional secrets explicitly: `sendSecret` is always local
output and `receiveSecret` is always peer output, independent of role.

**Implements:** `Drop`

<a id="X509Error"></a>

### X509Error

Import: `"tls"`.

```vex
export struct X509Error
```

**Implements:** `Copy`

**Public fields:**

- `kind`: `X509ErrorKind`
- `offset`: `usize`

<a id="X509CertificateView"></a>

### X509CertificateView

Import: `"tls"`.

```vex
export struct X509CertificateView
```

Allocation-free certificate view. The caller retains the DER bytes for the

complete lifetime of this value and passes the same span to every method.

**Implements:** `Copy`

<a id="X509TlsServerVerifier"></a>

### X509TlsServerVerifier

Import: `"tls"`.

```vex
export struct X509TlsServerVerifier
```

Bounded TLS server-certificate verifier for the currently supported

Ed25519 profile. Intermediates are presented in leaf-to-anchor order and
the explicit trust anchor is not included in `intermediateInputs`.
Validation is allocation-free and never consults an OS/libc root store.

<a id="TlsAlertLevel"></a>

### TlsAlertLevel

Import: `"tls"`.

```vex
export enum TlsAlertLevel
```

**Variants:**

- `Warning`
- `Fatal`

<a id="TlsAlertDescription"></a>

### TlsAlertDescription

Import: `"tls"`.

```vex
export enum TlsAlertDescription
```

**Variants:**

- `CloseNotify`
- `UnexpectedMessage`
- `BadRecordMac`
- `RecordOverflow`
- `HandshakeFailure`
- `BadCertificate`
- `UnsupportedCertificate`
- `CertificateRevoked`
- `CertificateExpired`
- `CertificateUnknown`
- `IllegalParameter`
- `UnknownCa`
- `AccessDenied`
- `DecodeError`
- `DecryptError`
- `ProtocolVersion`
- `InsufficientSecurity`
- `InternalError`
- `InappropriateFallback`
- `UserCanceled`
- `MissingExtension`
- `UnsupportedExtension`
- `UnrecognizedName`
- `BadCertificateStatusResponse`
- `UnknownPskIdentity`
- `CertificateRequired`
- `NoApplicationProtocol`

<a id="TlsAlertError"></a>

### TlsAlertError

Import: `"tls"`.

```vex
export enum TlsAlertError
```

**Variants:**

- `InvalidBuffer`
- `InvalidLength`
- `InvalidLevel`
- `UnknownDescription`
- `NonCanonicalLevel`

<a id="TlsHandshakeAssemblerError"></a>

### TlsHandshakeAssemblerError

Import: `"tls"`.

```vex
export enum TlsHandshakeAssemblerError
```

Failures produced while turning arbitrarily fragmented record payloads

back into complete TLS Handshake messages. Rejected input never partially
advances the assembler.

**Variants:**

- `InvalidLimit`
- `InvalidInput`
- `InvalidOutput`
- `MessageTooLarge`
- `OutputChanged`
- `InterleavedRecord`
- `KeyChangeWhileFragmented`

<a id="TlsHandshakeFeedKind"></a>

### TlsHandshakeFeedKind

Import: `"tls"`.

```vex
export enum TlsHandshakeFeedKind
```

`CompleteDirect` means the complete message is the first `encodedLen`

bytes of the supplied fragment. `CompleteBuffered` means it is in the
caller-owned output span. `NeedMore` consumes the reported prefix and keeps
bounded state for the next record.

**Variants:**

- `NeedMore`
- `CompleteDirect`
- `CompleteBuffered`

<a id="TlsCertificateError"></a>

### TlsCertificateError

Import: `"tls"`.

```vex
export enum TlsCertificateError
```

**Variants:**

- `InvalidInput`
- `InvalidMessageType`
- `InvalidMessageLength`
- `NonEmptyServerContext`
- `EmptyCertificateList`
- `EmptyCertificate`
- `ResourceLimit`
- `DuplicateExtension`
- `InvalidState`
- `UnsupportedSignatureAlgorithm`
- `InvalidCertificate`
- `InvalidSignature`

<a id="TlsKeyScheduleError"></a>

### TlsKeyScheduleError

Import: `"tls"`.

```vex
export enum TlsKeyScheduleError
```

**Variants:**

- `InvalidSecret`
- `InvalidLabel`
- `InvalidContext`
- `InvalidOutput`
- `BufferOverlap`
- `InvalidState`
- `HashMismatch`
- `AuthenticationFailed`
- `UnsupportedCipher`
- `CryptoFailure`

<a id="TlsHashAlgorithm"></a>

### TlsHashAlgorithm

Import: `"tls"`.

```vex
export enum TlsHashAlgorithm
```

Hash identity is explicit at the HKDF boundary. TLS must never infer a

cryptographic algorithm from an output buffer or silently substitute one.

**Variants:**

- `Sha256`
- `Sha384`

<a id="TlsHelloError"></a>

### TlsHelloError

Import: `"tls"`.

```vex
export enum TlsHelloError
```

**Variants:**

- `InvalidInput`
- `InvalidOutput`
- `InvalidMessageType`
- `InvalidMessageLength`
- `DecodeError`
- `ProtocolVersion`
- `IllegalParameter`
- `MissingExtension`
- `DuplicateExtension`
- `ExtensionOrder`
- `ResourceLimit`
- `BufferOverlap`

<a id="TlsDnsIdentityErrorKind"></a>

### TlsDnsIdentityErrorKind

Import: `"tls"`.

```vex
export enum TlsDnsIdentityErrorKind
```

**Variants:**

- `InvalidReference`
- `InvalidPresentedIdentity`
- `UnsupportedIdna`
- `IpAddressRequiresIpId`

<a id="TlsSecretStage"></a>

### TlsSecretStage

Import: `"tls"`.

```vex
export enum TlsSecretStage
```

The only legal states of the TLS 1.3 main secret schedule.

**Variants:**

- `Early`
- `Handshake`
- `Master`
- `Retired`

<a id="TlsKeyUpdateRequest"></a>

### TlsKeyUpdateRequest

Import: `"tls"`.

```vex
export enum TlsKeyUpdateRequest
```

**Variants:**

- `UpdateNotRequested`
- `UpdateRequested`

<a id="TlsKeyUpdateError"></a>

### TlsKeyUpdateError

Import: `"tls"`.

```vex
export enum TlsKeyUpdateError
```

**Variants:**

- `InvalidBuffer`
- `InvalidLength`
- `InvalidMessageType`
- `InvalidRequest`

<a id="TlsHandshakeRole"></a>

### TlsHandshakeRole

Import: `"tls"`.

```vex
export enum TlsHandshakeRole
```

Local endpoint role used to validate which Hello owns each X25519 share.

**Variants:**

- `Client`
- `Server`

<a id="TlsX25519NegotiationStage"></a>

### TlsX25519NegotiationStage

Import: `"tls"`.

```vex
export enum TlsX25519NegotiationStage
```

Monotonic state of normal no-PSK X25519 Hello negotiation.

**Variants:**

- `Ready`
- `ClientHelloCommitted`
- `HelloRetryRequested`
- `RetryClientHelloCommitted`
- `HandshakeTraffic`
- `EncryptedExtensions`
- `ServerCertificateAuthenticated`
- `ServerCertificateVerifyAuthenticated`
- `ServerFinishedAuthenticated`
- `Complete`
- `Failed`

<a id="TlsX25519NegotiationError"></a>

### TlsX25519NegotiationError

Import: `"tls"`.

```vex
export enum TlsX25519NegotiationError
```

Fail-closed negotiation errors. `HelloRetryRequest` is a typed transition

request, not a successful normal ServerHello.

**Variants:**

- `InvalidState`
- `InvalidRole`
- `InvalidPrivateKey`
- `InvalidHello`
- `InvalidEncryptedExtensions`
- `ExtensionNotOffered`
- `ResourceLimit`
- `UnsupportedMode`
- `UnsupportedCipher`
- `CipherNotOffered`
- `SessionMismatch`
- `MissingKeyShare`
- `KeyShareMismatch`
- `HelloRetryRequest`
- `InvalidOutput`
- `BufferOverlap`
- `NonContributoryKey`
- `SignatureAlgorithmNotOffered`
- `CertificateFailure`
- `CertificateVerifyFailure`
- `FinishedFailure`
- `TranscriptFailure`
- `ScheduleFailure`

<a id="TlsRecordError"></a>

### TlsRecordError

Import: `"tls"`.

```vex
export enum TlsRecordError
```

Allocation-free failures from TLS 1.3 record protection.

**Variants:**

- `InvalidState`
- `InvalidKeyMaterial`
- `InvalidBuffer`
- `InvalidContentType`
- `RecordOverflow`
- `InvalidRecord`
- `AuthenticationFailed`
- `SequenceExhausted`
- `BufferOverlap`
- `CipherFailure`

<a id="TlsTranscriptError"></a>

### TlsTranscriptError

Import: `"tls"`.

```vex
export enum TlsTranscriptError
```

Allocation-free failures produced by the handshake framing and transcript

layer. Every validation error is detected before the hash state or counters
are changed.

**Variants:**

- `InvalidLimit`
- `InvalidInput`
- `InvalidOutput`
- `InvalidMessageLength`
- `MessageTooLarge`
- `TranscriptLimitExceeded`
- `SyntheticMessageForbidden`
- `InvalidState`
- `HashUnavailable`
- `HashFailure`

<a id="TlsTransportState"></a>

### TlsTransportState

Import: `"tls"`.

```vex
export enum TlsTransportState
```

**Variants:**

- `Open`
- `PeerCanceled`
- `LocalCanceled`
- `LocalCloseSent`
- `PeerCloseReceived`
- `Closed`
- `Failed`

<a id="TlsTransportEventKind"></a>

### TlsTransportEventKind

Import: `"tls"`.

```vex
export enum TlsTransportEventKind
```

**Variants:**

- `ApplicationData`
- `PeerCloseNotify`
- `PeerUserCanceled`
- `PeerFatalAlert`
- `PostHandshakeFragment`
- `PeerKeyUpdate`

<a id="TlsTransportErrorKind"></a>

### TlsTransportErrorKind

Import: `"tls"`.

```vex
export enum TlsTransportErrorKind
```

**Variants:**

- `InvalidState`
- `KeyScheduleFailure`
- `RecordFailure`
- `AlertFailure`
- `KeyUpdateFailure`
- `GenerationExhausted`
- `UnexpectedMessage`

<a id="X509ErrorKind"></a>

### X509ErrorKind

Import: `"tls"`.

```vex
export enum X509ErrorKind
```

**Variants:**

- `InvalidDer`
- `InvalidCertificate`
- `UnsupportedAlgorithm`
- `InvalidSignature`
- `MissingSubjectAltName`
- `InvalidSubjectAltName`
- `InvalidValidity`
- `CertificateNotYetValid`
- `CertificateExpired`
- `IssuerMismatch`
- `NotCertificateAuthority`
- `InvalidKeyUsage`
- `InvalidExtendedKeyUsage`
- `UnsupportedCriticalExtension`
- `UnsupportedConstraint`
- `ChainTooLong`
- `HostnameMismatch`
- `IndexOutOfBounds`

<a id="encodeTlsAlert"></a>

### encodeTlsAlert

Import: `"tls"`.

```vex
export fn encodeTlsAlert(alert: TlsAlert, output: &Span<u8>!): Result<usize, TlsAlertError>
```

Encodes one canonical two-byte TLS 1.3 Alert payload. Vex never emits a

warning-level error alert or a fatal close_notify/user_canceled alert.

**Returns:** `Result<usize, TlsAlertError>`

<a id="decodeTlsAlert"></a>

### decodeTlsAlert

Import: `"tls"`.

```vex
export fn decodeTlsAlert(input: Span<u8>): Result<TlsAlert, TlsAlertError>
```

Decodes exactly one Alert payload. Warning-level protocol errors are

retained on the view but `isFatal` still applies TLS 1.3 effective
severity, preventing a peer-controlled downgrade.

**Returns:** `Result<TlsAlert, TlsAlertError>`

<a id="decodeServerCertificate"></a>

### decodeServerCertificate

Import: `"tls"`.

```vex
export fn decodeServerCertificate(encoded: Span<u8>): Result<TlsCertificateMessageView, TlsCertificateError>
```

Decodes one complete server Certificate Handshake message. The server

request context must be empty; the list is bounded to leaf plus eight
intermediates and all entry extension vectors are structurally validated.

**Returns:** `Result<TlsCertificateMessageView, TlsCertificateError>`

<a id="decodeCertificateVerify"></a>

### decodeCertificateVerify

Import: `"tls"`.

```vex
export fn decodeCertificateVerify(encoded: Span<u8>): Result<TlsCertificateVerifyView, TlsCertificateError>
```

**Returns:** `Result<TlsCertificateVerifyView, TlsCertificateError>`

<a id="verifyServerCertificateSignature"></a>

### verifyServerCertificateSignature

Import: `"tls"`.

```vex
export fn verifyServerCertificateSignature(encoded: Span<u8>, transcript: &TlsTranscript, leafDer: Span<u8>): Result<bool, TlsCertificateError>
```

Verifies a server CertificateVerify against the transcript ending at the

complete Certificate message. The CertificateVerify message is not
appended here; the owning handshake state may commit it only after success.

**Returns:** `Result<bool, TlsCertificateError>`

<a id="verifyServerCertificateSignatureWithKey"></a>

### verifyServerCertificateSignatureWithKey

Import: `"tls"`.

```vex
export fn verifyServerCertificateSignatureWithKey(encoded: Span<u8>, transcript: &TlsTranscript, publicKey: Span<u8>): Result<bool, TlsCertificateError>
```

Verifies server CertificateVerify with an exact Ed25519 public key already

authenticated by an owning certificate-path state. This avoids retaining a
borrowed DER span across handshake calls while keeping the RFC 8446 context
construction and signature checks in one source of truth.

**Returns:** `Result<bool, TlsCertificateError>`

<a id="hkdfExpandLabel"></a>

### hkdfExpandLabel

Import: `"tls"`.

```vex
export fn hkdfExpandLabel(hash: TlsHashAlgorithm, secret: Span<u8>, label: str, context: Span<u8>, out: &Span<u8>!): Result<usize, TlsKeyScheduleError>
```

RFC 8446 HKDF-Expand-Label for TLS 1.3 SHA-256 and SHA-384 schedules.

The traffic secret must be exactly one digest of the selected hash. The
output length comes from the mutable span, preventing pointer/length
disagreement. Inputs may not alias output; rejection precedes mutation.

**Returns:** `Result<usize, TlsKeyScheduleError>`

<a id="deriveSecret"></a>

### deriveSecret

Import: `"tls"`.

```vex
export fn deriveSecret(hash: TlsHashAlgorithm, secret: Span<u8>, label: str, transcriptHash: Span<u8>, out: &Span<u8>!): Result<usize, TlsKeyScheduleError>
```

RFC 8446 Derive-Secret over an already snapshotted transcript hash.

Requiring one exact digest for both `secret` and `transcriptHash` prevents
accidental cross-suite derivation. The output prefix is committed only
after every length and alias check succeeds.

**Returns:** `Result<usize, TlsKeyScheduleError>`

<a id="computeFinishedVerifyData"></a>

### computeFinishedVerifyData

Import: `"tls"`.

```vex
export fn computeFinishedVerifyData(hash: TlsHashAlgorithm, baseKey: Span<u8>, transcriptHash: Span<u8>, out: &Span<u8>!): Result<usize, TlsKeyScheduleError>
```

Computes TLS 1.3 Finished.verify_data from a traffic secret and an exact

transcript snapshot. The caller must snapshot before appending Finished.

**Returns:** `Result<usize, TlsKeyScheduleError>`

<a id="verifyFinished"></a>

### verifyFinished

Import: `"tls"`.

```vex
export fn verifyFinished(hash: TlsHashAlgorithm, baseKey: Span<u8>, transcriptHash: Span<u8>, received: Span<u8>): Result<bool, TlsKeyScheduleError>
```

Verifies TLS 1.3 Finished in constant time. A mismatch is an authentication

failure, not a boolean that a caller can accidentally ignore.

**Returns:** `Result<bool, TlsKeyScheduleError>`

<a id="deriveTrafficKeys"></a>

### deriveTrafficKeys

Import: `"tls"`.

```vex
export fn deriveTrafficKeys(secret: Span<u8>, cipherId: u16, outKey: &Span<u8>!, outIv: &Span<u8>!): Result<TlsTrafficKeyLengths, TlsKeyScheduleError>
```

Derive the per-direction TLS 1.3 record key and IV for all implemented

suites. Cipher-suite selection fixes both AEAD key length and HKDF hash.

**Returns:** `Result<TlsTrafficKeyLengths, TlsKeyScheduleError>`

<a id="updateTrafficSecret"></a>

### updateTrafficSecret

Import: `"tls"`.

```vex
export fn updateTrafficSecret(hash: TlsHashAlgorithm, current: Span<u8>, next: &Span<u8>!): Result<usize, TlsKeyScheduleError>
```

Derives RFC 8446 application_traffic_secret_N+1 from generation N.

The current secret remains caller-owned and unchanged. The next secret is
committed only after exact hash-width, capacity and alias validation, so a
transport can stage the complete next key generation before publishing it.

**Returns:** `Result<usize, TlsKeyScheduleError>`

<a id="decodeClientHello"></a>

### decodeClientHello

Import: `"tls"`.

```vex
export fn decodeClientHello(encoded: Span<u8>): Result<TlsClientHelloView, TlsHelloError>
```

Decodes and validates one complete TLS 1.3 ClientHello Handshake message.

**Returns:** `Result<TlsClientHelloView, TlsHelloError>`

<a id="decodeServerHello"></a>

### decodeServerHello

Import: `"tls"`.

```vex
export fn decodeServerHello(encoded: Span<u8>): Result<TlsServerHelloView, TlsHelloError>
```

Decodes and validates one complete TLS 1.3 ServerHello or

HelloRetryRequest Handshake message.

**Returns:** `Result<TlsServerHelloView, TlsHelloError>`

<a id="encodeTlsExtension"></a>

### encodeTlsExtension

Import: `"tls"`.

```vex
export fn encodeTlsExtension(extensionType: u16, data: Span<u8>, output: &Span<u8>!): Result<usize, TlsHelloError>
```

Emits a generic Extension TLV into caller-owned storage.

**Returns:** `Result<usize, TlsHelloError>`

<a id="encodeCookie"></a>

### encodeCookie

Import: `"tls"`.

```vex
export fn encodeCookie(cookie: Span<u8>, output: &Span<u8>!): Result<usize, TlsHelloError>
```

Encodes the TLS 1.3 `cookie` extension into caller-owned storage. The

opaque payload is length-delimited exactly once inside the extension and
is never allocated or truncated.

**Returns:** `Result<usize, TlsHelloError>`

<a id="encodeClientHello"></a>

### encodeClientHello

Import: `"tls"`.

```vex
export fn encodeClientHello(random: &[u8; 32], sessionId: Span<u8>, cipherSuites: Span<u16>, extensionBlock: Span<u8>, output: &Span<u8>!): Result<usize, TlsHelloError>
```

Emits the TLS 1.3 ClientHello body and Handshake header. Randomness and key

material are always supplied by the caller; this codec has no deterministic
or hidden entropy fallback.

**Returns:** `Result<usize, TlsHelloError>`

<a id="encodeServerHello"></a>

### encodeServerHello

Import: `"tls"`.

```vex
export fn encodeServerHello(random: &[u8; 32], sessionId: Span<u8>, cipherSuite: u16, extensionBlock: Span<u8>, output: &Span<u8>!): Result<usize, TlsHelloError>
```

Emits one TLS 1.3 ServerHello or HelloRetryRequest from an already

validated extension block.

**Returns:** `Result<usize, TlsHelloError>`

<a id="encodeClientSupportedVersions"></a>

### encodeClientSupportedVersions

Import: `"tls"`.

```vex
export fn encodeClientSupportedVersions(versions: Span<u16>, output: &Span<u8>!): Result<usize, TlsHelloError>
```

Encodes `supported_versions` for a TLS 1.3 ClientHello.

**Returns:** `Result<usize, TlsHelloError>`

<a id="encodeServerSupportedVersion"></a>

### encodeServerSupportedVersion

Import: `"tls"`.

```vex
export fn encodeServerSupportedVersion(output: &Span<u8>!): Result<usize, TlsHelloError>
```

**Returns:** `Result<usize, TlsHelloError>`

<a id="encodeSupportedGroups"></a>

### encodeSupportedGroups

Import: `"tls"`.

```vex
export fn encodeSupportedGroups(groups: Span<u16>, output: &Span<u8>!): Result<usize, TlsHelloError>
```

**Returns:** `Result<usize, TlsHelloError>`

<a id="encodeSignatureAlgorithms"></a>

### encodeSignatureAlgorithms

Import: `"tls"`.

```vex
export fn encodeSignatureAlgorithms(schemes: Span<u16>, output: &Span<u8>!): Result<usize, TlsHelloError>
```

**Returns:** `Result<usize, TlsHelloError>`

<a id="encodeClientKeyShare"></a>

### encodeClientKeyShare

Import: `"tls"`.

```vex
export fn encodeClientKeyShare(group: u16, keyExchange: Span<u8>, output: &Span<u8>!): Result<usize, TlsHelloError>
```

**Returns:** `Result<usize, TlsHelloError>`

<a id="encodeServerKeyShare"></a>

### encodeServerKeyShare

Import: `"tls"`.

```vex
export fn encodeServerKeyShare(group: u16, keyExchange: Span<u8>, output: &Span<u8>!): Result<usize, TlsHelloError>
```

**Returns:** `Result<usize, TlsHelloError>`

<a id="encodeHelloRetryKeyShare"></a>

### encodeHelloRetryKeyShare

Import: `"tls"`.

```vex
export fn encodeHelloRetryKeyShare(group: u16, output: &Span<u8>!): Result<usize, TlsHelloError>
```

Encodes the selected-group-only `key_share` form used exclusively by

HelloRetryRequest. A normal ServerHello must use `encodeServerKeyShare`.

**Returns:** `Result<usize, TlsHelloError>`

<a id="computeFinishedFromTranscript"></a>

### computeFinishedFromTranscript

Import: `"tls"`.

```vex
export fn computeFinishedFromTranscript(baseKey: Span<u8>, transcript: &TlsTranscript, out: &Span<u8>!): Result<usize, TlsKeyScheduleError>
```

Transcript-coupled Finished generation. The selected transcript hash is

authoritative; caller-provided hash identity cannot drift from it.

**Returns:** `Result<usize, TlsKeyScheduleError>`

<a id="verifyFinishedFromTranscript"></a>

### verifyFinishedFromTranscript

Import: `"tls"`.

```vex
export fn verifyFinishedFromTranscript(baseKey: Span<u8>, transcript: &TlsTranscript, received: Span<u8>): Result<bool, TlsKeyScheduleError>
```

Transcript-coupled constant-time Finished verification. Verify before

appending the peer Finished message to the transcript.

**Returns:** `Result<bool, TlsKeyScheduleError>`

<a id="encodeTlsKeyUpdate"></a>

### encodeTlsKeyUpdate

Import: `"tls"`.

```vex
export fn encodeTlsKeyUpdate(request: TlsKeyUpdateRequest, output: &Span<u8>!): Result<usize, TlsKeyUpdateError>
```

Encodes one complete Handshake-framed TLS 1.3 KeyUpdate message.

**Returns:** `Result<usize, TlsKeyUpdateError>`

<a id="decodeTlsKeyUpdate"></a>

### decodeTlsKeyUpdate

Import: `"tls"`.

```vex
export fn decodeTlsKeyUpdate(encoded: Span<u8>): Result<TlsKeyUpdateRequest, TlsKeyUpdateError>
```

Decodes exactly one complete Handshake-framed TLS 1.3 KeyUpdate message.

Values other than 0 and 1 are retained as a typed `InvalidRequest` so the
connection owner can select the required `illegal_parameter` alert.

**Returns:** `Result<TlsKeyUpdateRequest, TlsKeyUpdateError>`

<a id="encodeRecordHeader"></a>

### encodeRecordHeader

Import: `"tls"`.

```vex
export fn encodeRecordHeader(contentType: u8, version: u16, length: u16, out: &Span<u8>!): Result<usize, TlsRecordError>
```

**Returns:** `Result<usize, TlsRecordError>`

<a id="decodeRecordHeader"></a>

### decodeRecordHeader

Import: `"tls"`.

```vex
export fn decodeRecordHeader(inBuf: Span<u8>): Result<TlsRecordHeader, TlsRecordError>
```

**Returns:** `Result<TlsRecordHeader, TlsRecordError>`

<a id="decodeHandshakeHeader"></a>

### decodeHandshakeHeader

Import: `"tls"`.

```vex
export fn decodeHandshakeHeader(input: Span<u8>): Result<TlsHandshakeHeader, TlsTranscriptError>
```

Decodes a TLS Handshake header from the first four bytes of `input`.

**Returns:** `Result<TlsHandshakeHeader, TlsTranscriptError>`

<a id="encodeHandshakeHeader"></a>

### encodeHandshakeHeader

Import: `"tls"`.

```vex
export fn encodeHandshakeHeader(header: TlsHandshakeHeader, output: &Span<u8>!): Result<usize, TlsTranscriptError>
```

Encodes a TLS Handshake header without allocating.

**Returns:** `Result<usize, TlsTranscriptError>`

<a id="TlsAlertError-isKind"></a>

### TlsAlertError.isKind

```vex
export fn (self: &TlsAlertError) isKind(kind: TlsAlertError): bool
```

**Returns:** `bool`

<a id="TlsAlert-closeNotify"></a>

### TlsAlert.closeNotify

```vex
export fn TlsAlert.closeNotify(): TlsAlert
```

**Returns:** `TlsAlert`

<a id="TlsAlert-userCanceled"></a>

### TlsAlert.userCanceled

```vex
export fn TlsAlert.userCanceled(): TlsAlert
```

**Returns:** `TlsAlert`

<a id="TlsAlert-fatal"></a>

### TlsAlert.fatal

```vex
export fn TlsAlert.fatal(description: TlsAlertDescription): Result<TlsAlert, TlsAlertError>
```

**Returns:** `Result<TlsAlert, TlsAlertError>`

<a id="TlsAlert-isCloseNotify"></a>

### TlsAlert.isCloseNotify

```vex
export fn (self: &TlsAlert) isCloseNotify(): bool
```

**Returns:** `bool`

<a id="TlsAlert-isUserCanceled"></a>

### TlsAlert.isUserCanceled

```vex
export fn (self: &TlsAlert) isUserCanceled(): bool
```

**Returns:** `bool`

<a id="TlsAlert-isFatal"></a>

### TlsAlert.isFatal

```vex
export fn (self: &TlsAlert) isFatal(): bool
```

Effective TLS 1.3 severity. A peer that incorrectly labels an error alert

as warning cannot downgrade it; only close_notify and user_canceled remain
non-fatal.

**Returns:** `bool`

<a id="TlsHandshakeAssemblerError-isKind"></a>

### TlsHandshakeAssemblerError.isKind

```vex
export fn (self: &TlsHandshakeAssemblerError) isKind(kind: TlsHandshakeAssemblerError): bool
```

**Returns:** `bool`

<a id="TlsHandshakeFeedResult-isComplete"></a>

### TlsHandshakeFeedResult.isComplete

```vex
export fn (self: &TlsHandshakeFeedResult) isComplete(): bool
```

**Returns:** `bool`

<a id="TlsHandshakeFeedResult-isDirect"></a>

### TlsHandshakeFeedResult.isDirect

```vex
export fn (self: &TlsHandshakeFeedResult) isDirect(): bool
```

**Returns:** `bool`

<a id="TlsHandshakeAssembler-new"></a>

### TlsHandshakeAssembler.new

```vex
export fn TlsHandshakeAssembler.new(maxBodyLen: usize): Result<TlsHandshakeAssembler, TlsHandshakeAssemblerError>
```

**Returns:** `Result<TlsHandshakeAssembler, TlsHandshakeAssemblerError>`

<a id="TlsHandshakeAssembler-withProtocolLimit"></a>

### TlsHandshakeAssembler.withProtocolLimit

```vex
export fn TlsHandshakeAssembler.withProtocolLimit(): TlsHandshakeAssembler
```

**Returns:** `TlsHandshakeAssembler`

<a id="TlsHandshakeAssembler-isIdle"></a>

### TlsHandshakeAssembler.isIdle

```vex
export fn (self: &TlsHandshakeAssembler) isIdle(): bool
```

**Returns:** `bool`

<a id="TlsHandshakeAssembler-maxMessageBodyLen"></a>

### TlsHandshakeAssembler.maxMessageBodyLen

```vex
export fn (self: &TlsHandshakeAssembler) maxMessageBodyLen(): usize
```

**Returns:** `usize`

<a id="TlsHandshakeAssembler-pendingLen"></a>

### TlsHandshakeAssembler.pendingLen

```vex
export fn (self: &TlsHandshakeAssembler) pendingLen(): usize
```

Returns bytes already retained for the fragmented message. A partial

header reports its retained byte count; a known message reports the full
encoded prefix written to the caller buffer.

**Returns:** `usize`

<a id="TlsHandshakeAssembler-abort"></a>

### TlsHandshakeAssembler.abort

```vex
export fn (self: &TlsHandshakeAssembler!) abort()
```

Explicitly abandons a partial message after the connection has entered a

fatal state. Normal parse errors do not call this automatically.

**Receiver:** `self: &TlsHandshakeAssembler!` *(mutable reference)*

<a id="TlsHandshakeAssembler-requireNonHandshakeBoundary"></a>

### TlsHandshakeAssembler.requireNonHandshakeBoundary

```vex
export fn (self: &TlsHandshakeAssembler) requireNonHandshakeBoundary(): Result<bool, TlsHandshakeAssemblerError>
```

RFC 8446 forbids interleaving another record content type through a

fragmented Handshake message.

**Returns:** `Result<bool, TlsHandshakeAssemblerError>`

<a id="TlsHandshakeAssembler-requireKeyChangeBoundary"></a>

### TlsHandshakeAssembler.requireKeyChangeBoundary

```vex
export fn (self: &TlsHandshakeAssembler) requireKeyChangeBoundary(): Result<bool, TlsHandshakeAssemblerError>
```

Handshake messages may not cross a record-protection key change.

**Returns:** `Result<bool, TlsHandshakeAssemblerError>`

<a id="TlsHandshakeAssembler-feed"></a>

### TlsHandshakeAssembler.feed

```vex
export fn (self: &TlsHandshakeAssembler!) feed(fragment: Span<u8>, output: &Span<u8>!): Result<TlsHandshakeFeedResult, TlsHandshakeAssemblerError>
```

Consumes at most one complete Handshake message from `fragment`.

Callers loop over `fragment.skip(result.consumed)` to handle coalesced
messages. For `CompleteDirect`, consume `fragment.take(result.encodedLen)`.
For `CompleteBuffered`, consume `output.take(result.encodedLen)` before the
next feed. The same output base address is required across a fragmented
message, but its reported capacity may grow.

**Returns:** `Result<TlsHandshakeFeedResult, TlsHandshakeAssemblerError>`

<a id="TlsCertificateError-isKind"></a>

### TlsCertificateError.isKind

```vex
export fn (self: &TlsCertificateError) isKind(kind: TlsCertificateError): bool
```

**Returns:** `bool`

<a id="TlsCertificateMessageView-entryAt"></a>

### TlsCertificateMessageView.entryAt

```vex
export fn (self: &TlsCertificateMessageView) entryAt(encoded: Span<u8>, index: usize): Result<TlsCertificateEntryView, TlsCertificateError>
```

**Returns:** `Result<TlsCertificateEntryView, TlsCertificateError>`

<a id="TlsHashAlgorithm-digestLen"></a>

### TlsHashAlgorithm.digestLen

```vex
export fn (self: &TlsHashAlgorithm) digestLen(): usize
```

**Returns:** `usize`

<a id="TlsKeyScheduleError-isKind"></a>

### TlsKeyScheduleError.isKind

```vex
export fn (self: &TlsKeyScheduleError) isKind(kind: TlsKeyScheduleError): bool
```

**Returns:** `bool`

<a id="TlsHelloError-isKind"></a>

### TlsHelloError.isKind

```vex
export fn (self: &TlsHelloError) isKind(kind: TlsHelloError): bool
```

**Returns:** `bool`

<a id="TlsWireSlice-resolve"></a>

### TlsWireSlice.resolve

```vex
export fn (self: &TlsWireSlice) resolve(encoded: Span<u8>): Result<Span<u8>, TlsHelloError>
```

**Returns:** `Result<Span<u8>, TlsHelloError>`

<a id="TlsHelloExtensions-entryAt"></a>

### TlsHelloExtensions.entryAt

```vex
export fn (self: &TlsHelloExtensions) entryAt(encoded: Span<u8>, index: usize): Result<TlsExtensionEntry, TlsHelloError>
```

Resolves an extension by stable wire order. Unknown extension identities

remain available without weakening the typed views for core TLS 1.3 fields.

**Returns:** `Result<TlsExtensionEntry, TlsHelloError>`

<a id="TlsHelloExtensions-find"></a>

### TlsHelloExtensions.find

```vex
export fn (self: &TlsHelloExtensions) find(encoded: Span<u8>, extensionType: u16): Result<Option<TlsWireSlice>, TlsHelloError>
```

**Returns:** `Result<Option<TlsWireSlice>, TlsHelloError>`

<a id="TlsClientHelloView-cipherSuiteAt"></a>

### TlsClientHelloView.cipherSuiteAt

```vex
export fn (self: &TlsClientHelloView) cipherSuiteAt(encoded: Span<u8>, index: usize): Result<u16, TlsHelloError>
```

**Returns:** `Result<u16, TlsHelloError>`

<a id="TlsClientHelloView-signatureSchemeCount"></a>

### TlsClientHelloView.signatureSchemeCount

```vex
export fn (self: &TlsClientHelloView) signatureSchemeCount(): usize
```

Returns the number of structurally validated signature schemes advertised

by this ClientHello. The no-PSK decoder requires this extension, so a
successfully decoded view always reports at least one entry.

**Returns:** `usize`

<a id="TlsClientHelloView-signatureSchemeAt"></a>

### TlsClientHelloView.signatureSchemeAt

```vex
export fn (self: &TlsClientHelloView) signatureSchemeAt(encoded: Span<u8>, index: usize): Result<u16, TlsHelloError>
```

Resolves one advertised signature scheme by wire order. Bounds and backing

are revalidated so a view cannot be paired with unrelated storage.

**Returns:** `Result<u16, TlsHelloError>`

<a id="TlsClientHelloView-supportsGroup"></a>

### TlsClientHelloView.supportsGroup

```vex
export fn (self: &TlsClientHelloView) supportsGroup(encoded: Span<u8>, group: u16): Result<bool, TlsHelloError>
```

Reports whether the structurally validated `supported_groups` vector

contains `group`. The result is resolved against the exact encoded Hello,
so a detached view cannot be paired with unrelated storage.

**Returns:** `Result<bool, TlsHelloError>`

<a id="TlsClientHelloView-keyShareAt"></a>

### TlsClientHelloView.keyShareAt

```vex
export fn (self: &TlsClientHelloView) keyShareAt(encoded: Span<u8>, index: usize): Result<TlsKeyShareEntry, TlsHelloError>
```

Resolves one validated ClientHello KeyShareEntry by wire order.

**Returns:** `Result<TlsKeyShareEntry, TlsHelloError>`

<a id="TlsClientHelloView-findKeyShare"></a>

### TlsClientHelloView.findKeyShare

```vex
export fn (self: &TlsClientHelloView) findKeyShare(encoded: Span<u8>, group: u16): Result<Option<TlsWireSlice>, TlsHelloError>
```

**Returns:** `Result<Option<TlsWireSlice>, TlsHelloError>`

<a id="TlsServerHelloView-selectedKeyShare"></a>

### TlsServerHelloView.selectedKeyShare

```vex
export fn (self: &TlsServerHelloView) selectedKeyShare(encoded: Span<u8>): Result<TlsKeyShareEntry, TlsHelloError>
```

Resolves the sole normal ServerHello KeyShareEntry. HelloRetryRequest has

only a selected group and therefore returns a non-present key payload.

**Returns:** `Result<TlsKeyShareEntry, TlsHelloError>`

<a id="TlsDnsIdentityError-isKind"></a>

### TlsDnsIdentityError.isKind

```vex
export fn (self: &TlsDnsIdentityError) isKind(kind: TlsDnsIdentityErrorKind): bool
```

**Returns:** `bool`

<a id="TlsDnsIdentity-matches"></a>

### TlsDnsIdentity.matches

```vex
export fn TlsDnsIdentity.matches(reference: str, presentedDnsId: Span<u8>): Result<bool, TlsDnsIdentityError>
```

Matches a caller reference hostname against the raw bytes of one dNSName

SAN entry. A wildcard is accepted only as the complete left-most label and
consumes exactly one non-empty reference label. Both forms may contain one
trailing root dot, which is ignored for comparison.

**Returns:** `Result<bool, TlsDnsIdentityError>`

<a id="TlsSecretSchedule-new"></a>

### TlsSecretSchedule.new

```vex
export fn TlsSecretSchedule.new(hash: TlsHashAlgorithm, psk: Span<u8>): Result<TlsSecretSchedule, TlsKeyScheduleError>
```

Starts the schedule at Early Secret. An empty PSK means the RFC 8446

no-PSK value: one digest-length block of zero octets.

**Returns:** `Result<TlsSecretSchedule, TlsKeyScheduleError>`

<a id="TlsSecretSchedule-stage"></a>

### TlsSecretSchedule.stage

```vex
export fn (self: &TlsSecretSchedule) stage(): TlsSecretStage
```

**Returns:** `TlsSecretStage`

<a id="TlsSecretSchedule-hashAlgorithm"></a>

### TlsSecretSchedule.hashAlgorithm

```vex
export fn (self: &TlsSecretSchedule) hashAlgorithm(): TlsHashAlgorithm
```

**Returns:** `TlsHashAlgorithm`

<a id="TlsSecretSchedule-drop"></a>

### TlsSecretSchedule.drop

```vex
export fn (self: &TlsSecretSchedule!) drop()
```

**Receiver:** `self: &TlsSecretSchedule!` *(mutable reference)*

<a id="TlsSecretSchedule-retire"></a>

### TlsSecretSchedule.retire

```vex
export fn (self: &TlsSecretSchedule!) retire()
```

Irreversibly erases a candidate schedule that negotiation did not select.

All subsequent transitions fail with `InvalidState`.

**Receiver:** `self: &TlsSecretSchedule!` *(mutable reference)*

<a id="TlsSecretSchedule-deriveHandshakeTraffic"></a>

### TlsSecretSchedule.deriveHandshakeTraffic

```vex
export fn (self: &TlsSecretSchedule!) deriveHandshakeTraffic(sharedSecret: Span<u8>, transcript: &TlsTranscript, clientOut: &Span<u8>!, serverOut: &Span<u8>!): Result<usize, TlsKeyScheduleError>
```

Commits Early -&gt; Handshake and writes client/server handshake traffic

secrets for the transcript through ServerHello. Empty `sharedSecret`
selects the TLS PSK-only zero input.

**Returns:** `Result<usize, TlsKeyScheduleError>`

<a id="TlsSecretSchedule-deriveApplicationTraffic"></a>

### TlsSecretSchedule.deriveApplicationTraffic

```vex
export fn (self: &TlsSecretSchedule!) deriveApplicationTraffic(transcript: &TlsTranscript, clientOut: &Span<u8>!, serverOut: &Span<u8>!): Result<usize, TlsKeyScheduleError>
```

Commits Handshake -&gt; Master and writes generation-0 application traffic

secrets for the transcript through the server Finished message.

**Returns:** `Result<usize, TlsKeyScheduleError>`

<a id="TlsKeyUpdateError-isKind"></a>

### TlsKeyUpdateError.isKind

```vex
export fn (self: &TlsKeyUpdateError) isKind(kind: TlsKeyUpdateError): bool
```

**Returns:** `bool`

<a id="TlsX25519NegotiationError-isKind"></a>

### TlsX25519NegotiationError.isKind

```vex
export fn (self: &TlsX25519NegotiationError) isKind(kind: TlsX25519NegotiationError): bool
```

**Returns:** `bool`

<a id="TlsX25519Negotiation-new"></a>

### TlsX25519Negotiation.new

```vex
export fn TlsX25519Negotiation.new(role: TlsHandshakeRole, privateKey: Span<u8>, transcriptLimit: usize): Result<TlsX25519Negotiation, TlsX25519NegotiationError>
```

Creates a role-bound no-PSK negotiation owner, copies the exact 32-byte

scalar, derives its public key without allocation and starts a dual-hash
transcript with the requested hard byte limit.

**Returns:** `Result<TlsX25519Negotiation, TlsX25519NegotiationError>`

<a id="TlsX25519Negotiation-withDefaultLimit"></a>

### TlsX25519Negotiation.withDefaultLimit

```vex
export fn TlsX25519Negotiation.withDefaultLimit(role: TlsHandshakeRole, privateKey: Span<u8>): Result<TlsX25519Negotiation, TlsX25519NegotiationError>
```

Creates a negotiation owner with `TLS_DEFAULT_TRANSCRIPT_LIMIT`.

**Returns:** `Result<TlsX25519Negotiation, TlsX25519NegotiationError>`

<a id="TlsX25519Negotiation-role"></a>

### TlsX25519Negotiation.role

```vex
export fn (self: &TlsX25519Negotiation) role(): TlsHandshakeRole
```

Returns the immutable endpoint role.

**Returns:** `TlsHandshakeRole`

<a id="TlsX25519Negotiation-stage"></a>

### TlsX25519Negotiation.stage

```vex
export fn (self: &TlsX25519Negotiation) stage(): TlsX25519NegotiationStage
```

Returns the monotonic negotiation stage.

**Returns:** `TlsX25519NegotiationStage`

<a id="TlsX25519Negotiation-transcript"></a>

### TlsX25519Negotiation.transcript

```vex
export fn (self: &TlsX25519Negotiation) transcript(): &TlsTranscript
```

Borrows the transcript for read-only accounting or digest snapshots.

**Returns:** `&TlsTranscript`

<a id="TlsX25519Negotiation-selectedCipher"></a>

### TlsX25519Negotiation.selectedCipher

```vex
export fn (self: &TlsX25519Negotiation) selectedCipher(): Option<u16>
```

Returns the selected suite after successful normal ServerHello processing.

**Returns:** `Option<u16>`

<a id="TlsX25519Negotiation-selectedHash"></a>

### TlsX25519Negotiation.selectedHash

```vex
export fn (self: &TlsX25519Negotiation) selectedHash(): Option<TlsHashAlgorithm>
```

Returns the suite-authoritative hash after successful negotiation.

**Returns:** `Option<TlsHashAlgorithm>`

<a id="TlsX25519Negotiation-publicKeyTo"></a>

### TlsX25519Negotiation.publicKeyTo

```vex
export fn (self: &TlsX25519Negotiation) publicKeyTo(output: &Span<u8>!): Result<usize, TlsX25519NegotiationError>
```

Copies the non-secret local public key into an exact 32-byte destination.

**Returns:** `Result<usize, TlsX25519NegotiationError>`

<a id="TlsX25519Negotiation-commitClientHello"></a>

### TlsX25519Negotiation.commitClientHello

```vex
export fn (self: &TlsX25519Negotiation!) commitClientHello(encoded: Span<u8>): Result<usize, TlsX25519NegotiationError>
```

Validates and commits the exact ClientHello that entered the transcript.

Client role requires its encoded X25519 share to equal this owner's public
key; server role captures the contributory peer candidate for ServerHello.

**Returns:** `Result<usize, TlsX25519NegotiationError>`

<a id="TlsX25519Negotiation-commitRetryClientHello"></a>

### TlsX25519Negotiation.commitRetryClientHello

```vex
export fn (self: &TlsX25519Negotiation!) commitRetryClientHello(encoded: Span<u8>, retryPrivateKey: Span<u8>): Result<usize, TlsX25519NegotiationError>
```

Validates and commits ClientHello2 after one authenticated

HelloRetryRequest transition.
The caller supplies a fresh 32-byte private scalar only when HRR selected
X25519. Client role derives the corresponding public share and commits the
new scalar only after every wire, cookie, invariant and transcript check
succeeds. Server role passes an empty span and captures the validated peer
share. Cookie-only retries reuse the original key share byte-for-byte.

**Returns:** `Result<usize, TlsX25519NegotiationError>`

<a id="TlsX25519Negotiation-acceptServerHello"></a>

### TlsX25519Negotiation.acceptServerHello

```vex
export fn (self: &TlsX25519Negotiation!) acceptServerHello(encoded: Span<u8>, clientTrafficOut: &Span<u8>!, serverTrafficOut: &Span<u8>!): Result<usize, TlsX25519NegotiationError>
```

Validates normal ServerHello, computes the contributory X25519 secret, and

commits transcript/hash/schedule selection exactly once.
A valid HelloRetryRequest commits the selected transcript rewrite and locks
`HelloRetryRequested`; it is never mistaken for a traffic-secret-bearing
ServerHello and never touches caller traffic outputs.

**Returns:** `Result<usize, TlsX25519NegotiationError>`

<a id="TlsX25519Negotiation-acceptEncryptedExtensions"></a>

### TlsX25519Negotiation.acceptEncryptedExtensions

```vex
export fn (self: &TlsX25519Negotiation!) acceptEncryptedExtensions(encoded: Span<u8>): Result<usize, TlsX25519NegotiationError>
```

Validates and commits the server EncryptedExtensions flight. The current

no-PSK profile supports empty extensions, SNI acknowledgement,
supported_groups and one ALPN selection that exactly appeared in the
committed ClientHello. All other semantics fail closed.

**Returns:** `Result<usize, TlsX25519NegotiationError>`

<a id="TlsX25519Negotiation-selectedAlpnLen"></a>

### TlsX25519Negotiation.selectedAlpnLen

```vex
export fn (self: &TlsX25519Negotiation) selectedAlpnLen(): usize
```

Returns the authenticated server ALPN selection length after server

Finished. Zero means the client did not negotiate ALPN.

**Returns:** `usize`

<a id="TlsX25519Negotiation-selectedAlpnTo"></a>

### TlsX25519Negotiation.selectedAlpnTo

```vex
export fn (self: &TlsX25519Negotiation) selectedAlpnTo(output: &Span<u8>!): Result<usize, TlsX25519NegotiationError>
```

Copies the authenticated ALPN selection to caller storage.

**Returns:** `Result<usize, TlsX25519NegotiationError>`

<a id="TlsX25519Negotiation-acceptServerCertificate"></a>

### TlsX25519Negotiation.acceptServerCertificate

```vex
export fn (self: &TlsX25519Negotiation!) acceptServerCertificate(encoded: Span<u8>, trustAnchor: Span<u8>, referenceDnsName: str, unixSeconds: i64): Result<usize, TlsX25519NegotiationError>
```

Validates the server Certificate list against an explicit trust anchor,

DNS identity and time, then retains only the authenticated 32-byte Ed25519
key. Borrowed DER spans never survive the call.

**Returns:** `Result<usize, TlsX25519NegotiationError>`

<a id="TlsX25519Negotiation-acceptServerCertificateVerify"></a>

### TlsX25519Negotiation.acceptServerCertificateVerify

```vex
export fn (self: &TlsX25519Negotiation!) acceptServerCertificateVerify(encoded: Span<u8>): Result<usize, TlsX25519NegotiationError>
```

Verifies and commits server CertificateVerify only when Ed25519 was offered

by the exact committed ClientHello and the certificate path supplied the
authenticated key.

**Returns:** `Result<usize, TlsX25519NegotiationError>`

<a id="TlsX25519Negotiation-acceptServerFinished"></a>

### TlsX25519Negotiation.acceptServerFinished

```vex
export fn (self: &TlsX25519Negotiation!) acceptServerFinished(encoded: Span<u8>, clientApplicationOut: &Span<u8>!, serverApplicationOut: &Span<u8>!): Result<usize, TlsX25519NegotiationError>
```

Constant-time verifies and commits the peer Finished, then derives

generation-0 application traffic secrets from the transcript through that
message. Caller outputs are written only after the schedule transition has
fully succeeded.

**Returns:** `Result<usize, TlsX25519NegotiationError>`

<a id="TlsX25519Negotiation-writeClientFinished"></a>

### TlsX25519Negotiation.writeClientFinished

```vex
export fn (self: &TlsX25519Negotiation!) writeClientFinished(output: &Span<u8>!): Result<usize, TlsX25519NegotiationError>
```

Emits and commits the client's Finished message. Application traffic was

already derived at the RFC 8446 server-Finished boundary; this final gate
retires both handshake traffic secrets and marks the owner complete.

**Returns:** `Result<usize, TlsX25519NegotiationError>`

<a id="TlsX25519Negotiation-drop"></a>

### TlsX25519Negotiation.drop

```vex
export fn (self: &TlsX25519Negotiation!) drop()
```

**Receiver:** `self: &TlsX25519Negotiation!` *(mutable reference)*

<a id="TlsRecordError-isKind"></a>

### TlsRecordError.isKind

```vex
export fn (self: &TlsRecordError) isKind(kind: TlsRecordError): bool
```

**Returns:** `bool`

<a id="TlsCipherState-new"></a>

### TlsCipherState.new

```vex
export fn TlsCipherState.new(cipherId: u16, key: Span<u8>, iv: Span<u8>): Result<TlsCipherState, TlsRecordError>
```

**Usage contract:** Copies key/IV into a move-only sequence-zero owner and erases them on drop. Do not reconstruct this owner with an old traffic key/IV to reset the nonce sequence. This constructor does not perform a handshake.

**Returns:** `Result<TlsCipherState, TlsRecordError>`

<a id="TlsCipherState-sequence"></a>

### TlsCipherState.sequence

```vex
export fn (self: &TlsCipherState) sequence(): u64
```

**Returns:** `u64`

<a id="TlsCipherState-rekey"></a>

### TlsCipherState.rekey

```vex
export fn (self: &TlsCipherState!) rekey(key: Span<u8>, iv: Span<u8>): Result<bool, TlsRecordError>
```

**Returns:** `Result<bool, TlsRecordError>`

<a id="TlsCipherState-retire"></a>

### TlsCipherState.retire

```vex
export fn (self: &TlsCipherState!) retire()
```

Irreversibly erases this direction's traffic key and IV. Transport owners

call this immediately when a half-close or fatal failure makes the
direction unusable; Drop remains an idempotent final backstop.

**Receiver:** `self: &TlsCipherState!` *(mutable reference)*

<a id="TlsCipherState-drop"></a>

### TlsCipherState.drop

```vex
export fn (self: &TlsCipherState!) drop()
```

**Receiver:** `self: &TlsCipherState!` *(mutable reference)*

<a id="TlsCipherState-encryptRecord"></a>

### TlsCipherState.encryptRecord

```vex
export fn (self: &TlsCipherState!) encryptRecord(contentType: u8, plaintext: Span<u8>, outRecord: &Span<u8>!): Result<usize, TlsRecordError>
```

**Usage contract:** Returns the complete encoded record length. Capacity/overlap/sequence checks occur before encryption; sequence advances only after successful record emission into the buffer. The caller must still send that exact prefix in order.

**Returns:** `Result<usize, TlsRecordError>`

<a id="TlsCipherState-encryptRecordThenRekey"></a>

### TlsCipherState.encryptRecordThenRekey

```vex
export fn (self: &TlsCipherState!) encryptRecordThenRekey(contentType: u8, plaintext: Span<u8>, outRecord: &Span<u8>!, nextKey: Span<u8>, nextIv: Span<u8>): Result<usize, TlsRecordError>
```

Encrypts one record under the current generation and atomically installs

the staged next-generation key/IV after ciphertext commit.
Replacement material is fully validated before record encryption. If any
capacity, overlap or cipher operation fails, neither sequence nor key
generation changes. After successful encryption, the fixed-size rekey
commit is infallible and resets the sequence to zero for the next record.

**Returns:** `Result<usize, TlsRecordError>`

<a id="TlsCipherState-decryptRecord"></a>

### TlsCipherState.decryptRecord

```vex
export fn (self: &TlsCipherState!) decryptRecord(record: Span<u8>, outPlain: &Span<u8>!): Result<TlsPlaintext, TlsRecordError>
```

**Usage contract:** Only Ok exposes authenticated contentType/length; consume that prefix, not the whole scratch span. Authentication or inner-content failure clears candidate plaintext and does not advance the receive sequence. This low-level owner does not drive connection teardown; TlsApplicationTraffic owns transport-failure policy.

**Returns:** `Result<TlsPlaintext, TlsRecordError>`

<a id="TlsTranscriptError-isKind"></a>

### TlsTranscriptError.isKind

```vex
export fn (self: &TlsTranscriptError) isKind(kind: TlsTranscriptError): bool
```

**Returns:** `bool`

<a id="TlsTranscript-new"></a>

### TlsTranscript.new

```vex
export fn TlsTranscript.new(byteLimit: usize): Result<TlsTranscript, TlsTranscriptError>
```

Constructs a dual SHA-256/SHA-384 transcript with an explicit resource

limit. Both states receive pre-negotiation messages; `selectHash` retires
the unused state once the cipher suite is known.
The hard ceiling prevents a caller-controlled configuration from disabling
boundedness.

**Returns:** `Result<TlsTranscript, TlsTranscriptError>`

<a id="TlsTranscript-newForHash"></a>

### TlsTranscript.newForHash

```vex
export fn TlsTranscript.newForHash(hash: TlsHashAlgorithm, byteLimit: usize): Result<TlsTranscript, TlsTranscriptError>
```

Constructs a transcript whose cipher-suite hash is already known.

**Returns:** `Result<TlsTranscript, TlsTranscriptError>`

<a id="TlsTranscript-withDefaultLimit"></a>

### TlsTranscript.withDefaultLimit

```vex
export fn TlsTranscript.withDefaultLimit(): TlsTranscript
```

Constructs a dual transcript with the 16 MiB default input budget.

**Returns:** `TlsTranscript`

<a id="TlsTranscript-withDefaultHash"></a>

### TlsTranscript.withDefaultHash

```vex
export fn TlsTranscript.withDefaultHash(hash: TlsHashAlgorithm): TlsTranscript
```

Constructs a selected-hash transcript with the 16 MiB default budget.

**Returns:** `TlsTranscript`

<a id="TlsTranscript-selectedHash"></a>

### TlsTranscript.selectedHash

```vex
export fn (self: &TlsTranscript) selectedHash(): Option<TlsHashAlgorithm>
```

Returns the committed suite hash, or `None` while both candidates are live.

**Returns:** `Option<TlsHashAlgorithm>`

<a id="TlsTranscript-limit"></a>

### TlsTranscript.limit

```vex
export fn (self: &TlsTranscript) limit(): usize
```

Returns the immutable accepted-input byte budget.

**Returns:** `usize`

<a id="TlsTranscript-acceptedLen"></a>

### TlsTranscript.acceptedLen

```vex
export fn (self: &TlsTranscript) acceptedLen(): usize
```

Returns bytes accepted from complete peer/local Handshake messages.

**Returns:** `usize`

<a id="TlsTranscript-hashedLen"></a>

### TlsTranscript.hashedLen

```vex
export fn (self: &TlsTranscript) hashedLen(): usize
```

Returns the effective bytes represented by the running hash state.

**Returns:** `usize`

<a id="TlsTranscript-messages"></a>

### TlsTranscript.messages

```vex
export fn (self: &TlsTranscript) messages(): usize
```

Returns the number of effective messages in the running transcript.

**Returns:** `usize`

<a id="TlsTranscript-lastMessage"></a>

### TlsTranscript.lastMessage

```vex
export fn (self: &TlsTranscript) lastMessage(): Option<u8>
```

Returns the most recently committed Handshake type. An empty transcript

has no last message, so callers cannot confuse the numeric zero with state.

**Returns:** `Option<u8>`

<a id="TlsTranscript-didRewriteHelloRetry"></a>

### TlsTranscript.didRewriteHelloRetry

```vex
export fn (self: &TlsTranscript) didRewriteHelloRetry(): bool
```

Reports whether the ClientHello1 synthetic-hash rewrite was committed.

**Returns:** `bool`

<a id="TlsTranscript-drop"></a>

### TlsTranscript.drop

```vex
export fn (self: &TlsTranscript!) drop()
```

**Receiver:** `self: &TlsTranscript!` *(mutable reference)*

<a id="TlsTranscript-selectHash"></a>

### TlsTranscript.selectHash

```vex
export fn (self: &TlsTranscript!) selectHash(hash: TlsHashAlgorithm): Result<bool, TlsTranscriptError>
```

Commits the cipher-suite hash. Re-selecting the same hash is idempotent;

changing it after commitment is rejected. The unused state is erased.

**Returns:** `Result<bool, TlsTranscriptError>`

<a id="TlsTranscript-appendEncoded"></a>

### TlsTranscript.appendEncoded

```vex
export fn (self: &TlsTranscript!) appendEncoded(encoded: Span<u8>): Result<usize, TlsTranscriptError>
```

Validates and appends one complete encoded TLS Handshake message. The

uint24 length must exactly match the supplied span; record headers must not
be included.

**Returns:** `Result<usize, TlsTranscriptError>`

<a id="TlsTranscript-appendMessage"></a>

### TlsTranscript.appendMessage

```vex
export fn (self: &TlsTranscript!) appendMessage(messageType: u8, body: Span<u8>): Result<usize, TlsTranscriptError>
```

Appends a body while generating the authenticated handshake header. This

is the preferred construction path and performs no temporary allocation.

**Returns:** `Result<usize, TlsTranscriptError>`

<a id="TlsTranscript-digestTo"></a>

### TlsTranscript.digestTo

```vex
export fn (self: &TlsTranscript) digestTo(output: &Span<u8>!): Result<usize, TlsTranscriptError>
```

Writes the current transcript hash without finalizing the running state.

A later message can therefore be appended after any number of snapshots.

**Returns:** `Result<usize, TlsTranscriptError>`

<a id="TlsTranscript-digestFor"></a>

### TlsTranscript.digestFor

```vex
export fn (self: &TlsTranscript) digestFor(hash: TlsHashAlgorithm, output: &Span<u8>!): Result<usize, TlsTranscriptError>
```

Snapshots either candidate hash before cipher-suite selection. After

selection, only the committed hash remains available.

**Returns:** `Result<usize, TlsTranscriptError>`

<a id="TlsTranscript-rewriteForHelloRetryRequest"></a>

### TlsTranscript.rewriteForHelloRetryRequest

```vex
export fn (self: &TlsTranscript!) rewriteForHelloRetryRequest(): Result<usize, TlsTranscriptError>
```

Applies RFC 8446 section 4.4.1's HelloRetryRequest rewrite.

This operation is legal exactly once and only while the transcript contains
one complete ClientHello. The accepted-byte budget remains monotonic while
the effective hash state becomes `message_hash || Hash(ClientHello1)`.

**Returns:** `Result<usize, TlsTranscriptError>`

<a id="TlsTransportError-isKind"></a>

### TlsTransportError.isKind

```vex
export fn (self: &TlsTransportError) isKind(kind: TlsTransportErrorKind): bool
```

**Returns:** `bool`

<a id="TlsApplicationTraffic-new"></a>

### TlsApplicationTraffic.new

```vex
export fn TlsApplicationTraffic.new(cipherId: u16, sendSecret: Span<u8>, receiveSecret: Span<u8>): Result<TlsApplicationTraffic, TlsTransportError>
```

**Returns:** `Result<TlsApplicationTraffic, TlsTransportError>`

<a id="TlsApplicationTraffic-state"></a>

### TlsApplicationTraffic.state

```vex
export fn (self: &TlsApplicationTraffic) state(): TlsTransportState
```

**Returns:** `TlsTransportState`

<a id="TlsApplicationTraffic-sendSequence"></a>

### TlsApplicationTraffic.sendSequence

```vex
export fn (self: &TlsApplicationTraffic) sendSequence(): u64
```

**Returns:** `u64`

<a id="TlsApplicationTraffic-receiveSequence"></a>

### TlsApplicationTraffic.receiveSequence

```vex
export fn (self: &TlsApplicationTraffic) receiveSequence(): u64
```

**Returns:** `u64`

<a id="TlsApplicationTraffic-sendGeneration"></a>

### TlsApplicationTraffic.sendGeneration

```vex
export fn (self: &TlsApplicationTraffic) sendGeneration(): u64
```

**Returns:** `u64`

<a id="TlsApplicationTraffic-receiveGeneration"></a>

### TlsApplicationTraffic.receiveGeneration

```vex
export fn (self: &TlsApplicationTraffic) receiveGeneration(): u64
```

**Returns:** `u64`

<a id="TlsApplicationTraffic-keyUpdateResponseRequired"></a>

### TlsApplicationTraffic.keyUpdateResponseRequired

```vex
export fn (self: &TlsApplicationTraffic) keyUpdateResponseRequired(): bool
```

**Returns:** `bool`

<a id="TlsApplicationTraffic-encryptApplicationData"></a>

### TlsApplicationTraffic.encryptApplicationData

```vex
export fn (self: &TlsApplicationTraffic!) encryptApplicationData(plaintext: Span<u8>, output: &Span<u8>!): Result<usize, TlsTransportError>
```

**Returns:** `Result<usize, TlsTransportError>`

<a id="TlsApplicationTraffic-writeKeyUpdate"></a>

### TlsApplicationTraffic.writeKeyUpdate

```vex
export fn (self: &TlsApplicationTraffic!) writeKeyUpdate(request: TlsKeyUpdateRequest, output: &Span<u8>!): Result<usize, TlsTransportError>
```

Sends a complete KeyUpdate under the current send generation and commits

generation N+1 only after the old-key ciphertext is available to transmit.
A requested peer update creates a response obligation; application data is
blocked until an UpdateNotRequested response has crossed this boundary.

**Returns:** `Result<usize, TlsTransportError>`

<a id="TlsApplicationTraffic-writeUserCanceled"></a>

### TlsApplicationTraffic.writeUserCanceled

```vex
export fn (self: &TlsApplicationTraffic!) writeUserCanceled(output: &Span<u8>!): Result<usize, TlsTransportError>
```

Sends the TLS 1.3 user_canceled warning once without retiring the send key.

Application data is forbidden afterward; the only orderly continuation is
close_notify, while a newly discovered fatal error may still be reported.

**Returns:** `Result<usize, TlsTransportError>`

<a id="TlsApplicationTraffic-writeCloseNotify"></a>

### TlsApplicationTraffic.writeCloseNotify

```vex
export fn (self: &TlsApplicationTraffic!) writeCloseNotify(output: &Span<u8>!): Result<usize, TlsTransportError>
```

Encrypts close_notify exactly once, then erases the send-direction key.

A failed capacity/overlap check leaves the direction open so the caller can
retry with valid storage; a cryptographic failure retires both directions.

**Returns:** `Result<usize, TlsTransportError>`

<a id="TlsApplicationTraffic-writeFatalAlert"></a>

### TlsApplicationTraffic.writeFatalAlert

```vex
export fn (self: &TlsApplicationTraffic!) writeFatalAlert(description: TlsAlertDescription, output: &Span<u8>!): Result<usize, TlsTransportError>
```

Emits one fatal alert and immediately retires both directions after the

ciphertext is committed. close_notify/user_canceled cannot be mislabeled
as fatal through this API.

**Returns:** `Result<usize, TlsTransportError>`

<a id="TlsApplicationTraffic-readRecord"></a>

### TlsApplicationTraffic.readRecord

```vex
export fn (self: &TlsApplicationTraffic!) readRecord(record: Span<u8>, plaintext: &Span<u8>!): Result<TlsTransportEvent, TlsTransportError>
```

Authenticates and classifies one protected application-phase record.

Unknown/malformed alerts, malformed KeyUpdate flights, and application data
after peer close/cancel retire the connection.

**Returns:** `Result<TlsTransportEvent, TlsTransportError>`

<a id="TlsApplicationTraffic-drop"></a>

### TlsApplicationTraffic.drop

```vex
export fn (self: &TlsApplicationTraffic!) drop()
```

**Receiver:** `self: &TlsApplicationTraffic!` *(mutable reference)*

<a id="X509Error-isKind"></a>

### X509Error.isKind

```vex
export fn (self: &X509Error) isKind(kind: X509ErrorKind): bool
```

**Returns:** `bool`

<a id="X509CertificateView-parse"></a>

### X509CertificateView.parse

```vex
export fn X509CertificateView.parse(input: Span<u8>): Result<X509CertificateView, X509Error>
```

Parses the structural certificate envelope and admits only RFC 8410

Ed25519 signature/SPKI identities. Other algorithms fail explicitly.

**Returns:** `Result<X509CertificateView, X509Error>`

<a id="X509CertificateView-publicKeyBytes"></a>

### X509CertificateView.publicKeyBytes

```vex
export fn (self: &X509CertificateView) publicKeyBytes(input: Span<u8>): Result<Span<u8>, X509Error>
```

**Returns:** `Result<Span<u8>, X509Error>`

<a id="X509CertificateView-verifySignatureWith"></a>

### X509CertificateView.verifySignatureWith

```vex
export fn (self: &X509CertificateView) verifySignatureWith(input: Span<u8>, issuerInput: Span<u8>, issuer: &X509CertificateView): Result<bool, X509Error>
```

Verifies this certificate signature with the issuer's Ed25519 SPKI. Chain

policy (name chaining, CA constraints, time and trust anchor) is separate.

**Returns:** `Result<bool, X509Error>`

<a id="X509CertificateView-validityRange"></a>

### X509CertificateView.validityRange

```vex
export fn (self: &X509CertificateView) validityRange(input: Span<u8>): Result<(i64, i64), X509Error>
```

**Returns:** `Result<(i64, i64), X509Error>`

<a id="X509CertificateView-validateAt"></a>

### X509CertificateView.validateAt

```vex
export fn (self: &X509CertificateView) validateAt(input: Span<u8>, unixSeconds: i64): Result<bool, X509Error>
```

**Returns:** `Result<bool, X509Error>`

<a id="X509TlsServerVerifier-verifyChain"></a>

### X509TlsServerVerifier.verifyChain

```vex
export fn X509TlsServerVerifier.verifyChain(leafInput: Span<u8>, intermediateInputs: Span<Span<u8>>, trustAnchorInput: Span<u8>, referenceDnsName: str, unixSeconds: i64): Result<bool, X509Error>
```

**Usage contract:** Returns Ok(true) only when the bounded Ed25519 path and DNS policy succeed; errors reject the chain. It does not provide general PKIX, revocation, RSA or P-256 validation. See [certificate substrate](tls.md#certificate-substrate).

**Returns:** `Result<bool, X509Error>`

<a id="X509TlsServerVerifier-verifyDirect"></a>

### X509TlsServerVerifier.verifyDirect

```vex
export fn X509TlsServerVerifier.verifyDirect(leafInput: Span<u8>, trustAnchorInput: Span<u8>, referenceDnsName: str, unixSeconds: i64): Result<bool, X509Error>
```

Convenience path for a leaf signed directly by the explicit trust anchor.

**Returns:** `Result<bool, X509Error>`

<a id="X509CertificateView-dnsNameCount"></a>

### X509CertificateView.dnsNameCount

```vex
export fn (self: &X509CertificateView) dnsNameCount(input: Span<u8>): Result<usize, X509Error>
```

**Returns:** `Result<usize, X509Error>`

<a id="X509CertificateView-dnsNameAt"></a>

### X509CertificateView.dnsNameAt

```vex
export fn (self: &X509CertificateView) dnsNameAt(input: Span<u8>, wanted: usize): Result<Span<u8>, X509Error>
```

**Returns:** `Result<Span<u8>, X509Error>`

<a id="X509CertificateView-matchesDnsName"></a>

### X509CertificateView.matchesDnsName

```vex
export fn (self: &X509CertificateView) matchesDnsName(input: Span<u8>, reference: str): Result<bool, X509Error>
```

Checks every SAN dNSName. Invalid presented identities fail closed instead

of being silently skipped. Absence never falls back to subject CN.

---

---

*Generated by vex-doc v2.0 • 2026-10-28*
