abla/tls/pure/server
Generated from source.
Import with import "abla/tls/pure/server".
Source: abla/tls/pure/server/entry.ab
TLS_SERVER_WAIT_CLIENT_HELLO (val)
val TLS_SERVER_WAIT_CLIENT_HELLO
Server state awaiting the client's initial hello.
TLS_SERVER_WAIT_SECOND_HELLO (val)
val TLS_SERVER_WAIT_SECOND_HELLO
Server state awaiting a second client hello after a retry.
TLS_SERVER_WAIT_CERTIFICATE (val)
val TLS_SERVER_WAIT_CERTIFICATE
Server state awaiting the client's certificate chain.
TLS_SERVER_WAIT_CERTIFICATE_VERIFY (val)
val TLS_SERVER_WAIT_CERTIFICATE_VERIFY
Server state awaiting the client's certificate signature.
TLS_SERVER_WAIT_FINISHED (val)
val TLS_SERVER_WAIT_FINISHED
Server state awaiting the client's Finished authenticator.
TLS_EARLY_SKIP_LIMIT (val)
val TLS_EARLY_SKIP_LIMIT
The most ciphertext a server that does not accept early data skips before the client's Finished (RFC 8446 section 4.2.10: a configured maximum).
TLS_SERVER_CONNECTED (val)
val TLS_SERVER_CONNECTED
Server state after completion of the TLS handshake.
TLS_SERVER_CLOSED (val)
val TLS_SERVER_CLOSED
Server state after the TLS connection closes.
TLS_SERVER_FAILED (val)
val TLS_SERVER_FAILED
Terminal server state after a TLS error.
TLS_ALERT_NO_APPLICATION_PROTOCOL (val)
val TLS_ALERT_NO_APPLICATION_PROTOCOL
Alert for a handshake without a mutually supported application protocol.
TLS_ALERT_CERTIFICATE_REQUIRED (val)
val TLS_ALERT_CERTIFICATE_REQUIRED
Alert for a client that does not present a required certificate.
TlsServerConfig (class)
class TlsServerConfig(
val identity: TlsIdentity,
val suites: array<int>,
val groups: array<int>,
val alpn: array<string>,
val random: (int) -> string,
val requestClientCertificate: bool,
val requireClientCertificate: bool,
val clientVerifier: (array<string>, int, string, string) -> TlsVerdict,
/** The TLS 1.2 suites (the modern subset) the server accepts, in its order: [] makes a TLS 1.3-only server. The
* suites whose key type does not match the identity are skipped. */
val suites12: array<int> = [TLS12_ECDHE_ECDSA_AES_128_GCM_SHA256, TLS12_ECDHE_RSA_AES_128_GCM_SHA256,
TLS12_ECDHE_ECDSA_AES_256_GCM_SHA384, TLS12_ECDHE_RSA_AES_256_GCM_SHA384,
TLS12_ECDHE_ECDSA_CHACHA20_POLY1305_SHA256, TLS12_ECDHE_RSA_CHACHA20_POLY1305_SHA256],
/** Ticket keys: with them the server sends NewSessionTicket after a handshake and accepts tickets (TLS 1.3, psk_dhe_ke, no 0-RTT), keeping no state of its
* own. null: no resumption. A server that asks for client certificates sends no tickets (a resumption would skip the client's authentication). */
val tickets: TlsTicketKeys? = null,
/** The names `identity` is for (`TlsServerIdentity.names`); [] is any name. */
val identityNames: array<string> = [],
/** More certificates, each for names of its own: with any, the server picks one per ClientHello by the client's server_name (SNI) and
* signature_algorithms (see `tlsServerConfigWithIdentities`). [] is a server with the one `identity`, exactly as before. */
val identities: array<TlsServerIdentity> = []
)
The server's configuration: the identity (certificate chain and signing function), the cipher suites and groups in the server's order, the ALPN protocols in the server's order ([] for none), a random source, and whether to ask the client for a certificate (requestClientCertificate; requireClientCertificate refuses one that sends none) with clientVerifier(chain, scheme, signed content, signature) returning "" for a client it trusts, else the reason.
TlsServerIdentity (class)
class TlsServerIdentity(val identity: TlsIdentity, val names: array<string>)
One of a server's certificates: the identity (chain and signer) and the names it serves, each an exact host name or a wildcard *.example.com (one label, as RFC 6125 reads it); [] serves any name.
TlsServer (class)
class TlsServer(
val config: TlsServerConfig,
var state: int,
var error: string,
var inbox: string,
var handshakeBuffer: TlsHandshakeBuffer,
var outbox: string,
var applicationData: string,
val transcript: TlsTranscript,
var hash: int,
var suite: int,
var keyLength: int,
var aead: int,
var clientRandom: string,
var sessionId: string,
var retried: bool,
var retryGroup: int,
var retrySuite: int,
var readEncrypted: bool,
var writeEncrypted: bool,
var read: TlsRecordProtection,
var write: TlsRecordProtection,
var handshakeSecret: string,
var clientHandshakeSecret: string,
var serverHandshakeSecret: string,
var clientApplicationSecret: string,
var serverApplicationSecret: string,
var clientChain: array<string>,
var negotiatedAlpn: string,
var serverName: string,
var sentCompatibilityChangeCipherSpec: bool,
var peerClosed: bool,
var sentClose: bool,
var clientAuthenticated: bool,
/** TLS 1.2: set when the ClientHello chose it; the suite, protections, keys, the server's ECDHE pair, the master secret. */
var v12: bool,
var v12Suite: int,
var v12Read: Tls12Protection,
var v12Write: Tls12Protection,
var v12Keys: Tls12Keys,
var v12Pair: TlsKeyPair,
var serverRandom: string,
var master: string,
/** Records in a row that carried nothing (empty application data, ChangeCipherSpec), KeyUpdates in a row, and a
* KeyUpdate the peer asked for that is still to be answered (once per batch of input). */
var emptyRun: int = 0,
var keyUpdateRun: int = 0,
var keyUpdateOwed: bool = false,
/** Warning alerts in a row (ignored up to four, as BoringSSL does). */
var warningRun: int = 0,
/** The key exchange group that was negotiated (0 until the ServerHello is processed): the group of the key share, or of the
* TLS 1.2 ServerKeyExchange. */
var negotiatedGroup: int = 0,
/** Whether this handshake resumed a session (a ticket was accepted: no certificate was sent), and the master secret kept until the client's Finished to make
* the resumption master secret and the tickets (a buffer of its own; "" when no tickets are sent). */
var didResume: bool = false,
var ticketMaster: string = "",
/** The first ClientHello offered a PSK (after a HelloRetryRequest the second must too), and the client allowed tickets (psk_key_exchange_modes lists psk_dhe_ke). */
var firstOfferedPsk: bool = false,
var firstPskUsable: bool = false,
var wantTickets: bool = false,
/** The tls-exporter channel binding (RFC 9266), made when the TLS 1.3 handshake completes; "" before, and on TLS 1.2. */
var channelExporter: string = "",
/** The identity picked for this connection from `config.identities` by its ClientHello (null: `config.identity`). */
var chosenIdentity: TlsIdentity? = null,
/** The ClientHello offered early_data, which this server does not accept: the records the client sends under the early traffic key are skipped (RFC 8446
* section 4.2.10), up to `TLS_EARLY_SKIP_LIMIT` bytes of them, until the first record that deprotects under the handshake key (the start of the client's second
* flight: the flag is cleared there, and a record that fails after it is a bad_record_mac). */
var earlyOffered: bool = false,
var earlySkipped: int = 0
)
Holds the TLS server's handshake state, transcript, record buffers, and key material.
tlsServerNew (fun)
fun tlsServerNew(config: TlsServerConfig): TlsServer
A TLS 1.3 server connection waiting for its ClientHello.
tlsServerConfigWithAlpn (fun)
fun tlsServerConfigWithAlpn(config: TlsServerConfig, alpn: array<string>): TlsServerConfig
config that offers the application protocols alpn (in the server's order, for example ["h2", "http/1.1"]); a client that offers protocols and none of them is refused with no_application_protocol, one that offers none is still accepted (see docs/tls.md). The chosen one is TlsServer.alpn().
tlsServerConfigWithIdentities (fun)
fun tlsServerConfigWithIdentities(config: TlsServerConfig, identityNames: array<string>, identities: array<TlsServerIdentity>): TlsServerConfig
config with more certificates (identities, each for its names) next to its own identity (for the names in identityNames, which tlsServerConfig leaves empty: any). One ClientHello gets one certificate: among the ones whose names match the client's server_name (exact, case-insensitive, or a wildcard *.example.com for exactly one label), the first (this configuration's own, then identities in order) that can sign with a scheme the client accepts. Put the ECDSA certificate of a name before its RSA one to prefer it for the clients that take both. A name nothing matches, or no server_name, gets the first certificate that the client's signature algorithms allow, in the same order (so the first is the default); and when no certificate suits the client, the handshake fails as a single certificate's does (handshake_failure). No certificate is chosen differently for a resumed session: a ticket is bound to its server name.
tlsServerNameMatches (fun)
fun tlsServerNameMatches(pattern: string, name: string): bool
Whether pattern (a name, or *.example.com) serves name: names compare without case or a final dot; a wildcard stands for exactly one label.
TlsServer.identity (extension fun)
fun TlsServer.identity(): TlsIdentity
The certificate this connection presents (the one chooseIdentity picked when the ClientHello came; the configuration's own before).
tlsServerConfig (fun)
fun tlsServerConfig(identity: TlsIdentity, random: (int) -> string): TlsServerConfig
The usual configuration: the given identity, AES-GCM and ChaCha20 suites, X25519MLKEM768, X25519, P-256 then P-384, no ALPN, no client certificate.
tlsServerConfigWithClientCertificates (fun)
fun tlsServerConfigWithClientCertificates(identity: TlsIdentity, random: (int) -> string, required: bool,
verifier: (array<string>, int, string, string) -> TlsVerdict): TlsServerConfig
As tlsServerConfig, and asks the client for a certificate that verifier (chain, signature scheme, signed content, signature: "" to accept, else the reason) accepts; required refuses a client that sends none.
tlsServerRefuseClients (fun)
fun tlsServerRefuseClients(chain: array<string>, scheme: int, content: string, signature: string): TlsVerdict
The client verifier of a server that asks for no certificate: it trusts none.
TlsServer.failed (extension fun)
fun TlsServer.failed(): bool
Returns true when the server has entered its failure state.
TlsServer.connected (extension fun)
fun TlsServer.connected(): bool
Returns true when the server has completed the handshake.
TlsServer.closed (extension fun)
fun TlsServer.closed(): bool
Returns true if the peer has closed the TLS stream.
TlsServer.takeOutput (extension fun)
fun TlsServer.takeOutput(): string
The bytes to send to the peer; empties the queue.
TlsServer.takeApplicationData (extension fun)
fun TlsServer.takeApplicationData(): string
The application data received so far; empties the buffer.
TlsServer.alpn (extension fun)
fun TlsServer.alpn(): string
The ALPN protocol chosen ("" for none) and the server name the client asked for ("" for none).
TlsServer.serverNameIndication (extension fun)
fun TlsServer.serverNameIndication(): string
Returns the server name requested by the client or empty text when it supplied none.
TlsServer.feed (extension fun)
fun TlsServer.feed(data: string): void
Feeds bytes received from the peer: every complete record in them is processed.
TlsServer.send (extension fun)
fun TlsServer.send(data: string): bool
Queues application data (any length) as records. False when the connection is not open. The server may write as soon as its own Finished is out; the client has not authenticated itself until connected().
TlsServer.close (extension fun)
fun TlsServer.close(): void
Queues close_notify; the connection takes no more application data.
TlsServer.clientCertificateVerified (extension fun)
fun TlsServer.clientCertificateVerified(): bool
True when the client presented a certificate that the configured verifier accepted.
TLS_SERVER12_WAIT_CERTIFICATE (val)
val TLS_SERVER12_WAIT_CERTIFICATE
---- TLS 1.2 (the modern subset) ---- ClientHello without TLS 1.3 -> ServerHello, Certificate, ServerKeyExchange (ECDHE, signed with the identity), [CertificateRequest], ServerHelloDone; then the client's [Certificate], ClientKeyExchange, [CertificateVerify], ChangeCipherSpec, Finished; then the server's ChangeCipherSpec and Finished. The extended master secret is required.
TLS_SERVER12_WAIT_KEY_EXCHANGE (val)
val TLS_SERVER12_WAIT_KEY_EXCHANGE
TLS 1.2 server state awaiting the client's key exchange.
TLS_SERVER12_WAIT_CERTIFICATE_VERIFY (val)
val TLS_SERVER12_WAIT_CERTIFICATE_VERIFY
TLS 1.2 server state awaiting the client's transcript signature.
TLS_SERVER12_WAIT_CHANGE_CIPHER_SPEC (val)
val TLS_SERVER12_WAIT_CHANGE_CIPHER_SPEC
TLS 1.2 server state awaiting the switch to negotiated record protection.
TLS_SERVER12_WAIT_FINISHED (val)
val TLS_SERVER12_WAIT_FINISHED
TLS 1.2 server state awaiting the client's Finished authenticator.
TlsServer.resumed (extension fun)
fun TlsServer.resumed(): bool
Whether this handshake resumed a session: the client's ticket was accepted (no certificate was sent).
TlsServer.channelBinding (extension fun)
fun TlsServer.channelBinding(kind: string): string
The channel binding of kind ("tls-exporter" or "tls-server-end-point", abla/tls/pure/binding), raw bytes, "" when it is not available (see there). Valid once connected.
Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.