Changelog
Unreleased
Added
ServerHandshake.negotiatedGroup(): the key-exchange group the handshake settled on, so an application that must not serve classical key exchange can check it and close the connection.tls.capabilities.HybridPolicy.recommendedandcapabilities.recommended_server_groups: the shipped RFC 10024 policy, one hybrid group on a client and every implemented group on a server. Both resolve to the classical behaviour on an approved-only build, which has no hybrid group.tls.ticket(src/ticket.zig): allocation-free stateless session ticket sealing, opening, and rotatingKeyRingoverstd.cryptoAES-256-GCM. Binds SNI and ALPN in AAD, enforces expiry and optional age-window policy, clamps re-issued tickets to the originalauth_not_after_ms, and keeps 0-RTT disabled (max_early_data_size = null) (#244).ClientHandshake.isResumed(),SessionTicket.isExpired(),SessionTicket.matchesServerName(), andServerHandshake.canIssueTicket().SessionTicketrecordsserver_nameand raisesmax_identity_lento 512 bytes for interop with foreign servers (#244).tls_nonblocking.Client:Options.resumption(ticket+age_ms) andisResumed(). Expired or mismatched-host tickets fall back silently to a full handshake (#244).tls_nonblocking.Server: opt-inOptions.issue_ticketsyieldingEvent.issue_ticketbefore extraction,sendSessionTicket(),skipSessionTicket(), andisResumed(). Unanswered ticket events discard and wipe the preparedTicketPskon the nextnext(), and small RFC 8449 record limits skip oversized tickets without failing the handshake (#244).
Changed
- Breaking: post-quantum key exchange is on by default.
ClientHandshakeadvertises and shares X25519MLKEM768, andServerConfig.hybrid_groupsdefaults to every hybrid group the backend implements. The client hello now carries a 1216-byte ML-KEM share, so an out buffer sized for a classical first flight fails witherror.BufferTooShort. Sethybrid = .emptyorhybrid_groups = &.{}for classical key exchange only.tls-stdclient and server options follow the same defaults. - Hybrid groups lead
supported_groupsandkey_sharein the client hello, so a server that breaks ties by client order reaches the post-quantum group first. A classical hello is byte-identical to before. - Breaking:
ServerHandshake.PskLookup.lookupnow takes(context, *const PskQuery, *PskEntry) boolwithPskQuerycarryingidentity,obfuscated_ticket_age,server_name, andselected_alpn.PskEntryowns its PSK bytes inline, wipes them after ServerHello key derivation, and drops them from post-ServerHello phases. Non-HRR ClientHellos callPskLookuponce per matching identity instead of twice (#244). - Breaking:
ClientHandshake.PskStart.Resumptionnow requiresage_ms: u32(encoded asage_ms +% ticket.ticket_age_add, RFC 8446 §4.2.11.1) and rejects cross-host ticket offers witherror.TicketServerNameMismatch(#244). ServerHandshake.isResumed()andClientHandshake.isResumed()return false for external PSK handshakes (kind == .external).extractEstablished()zeroes the unusableresumption_master_secreton the extracted session (#244).
0.5.0 - 2026-12-03
Added
- Client and server
record_size_limitconfiguration negotiates and enforces RFC 8449 inbound and outbound record limits, including fragmented server flights and KeyUpdate epochs. Connected engines exposemaxOutboundPlaintext()andmaxInboundPlaintext()for wrapper fragmentation and receive-side policy.ServerHandshake.max_fragmented_flight_out_lenbounds worst-case flight output at the minimum legal limit (#238). RecordBuffer.initLimiteddetects legal records that exceed sub-16 KiB caller storage.tls_nonblocking.Serversupports 8 KiB RX/TX buffers, per-writewriteWithScratch, idledetachBuffers/attachBuffers, and a caller-ownedOverflowPoolfor legal records larger than the receive ring. Handshake flight output moved into pooledHandshakeScratch(#238).signature.PrivateKeyloads Ed25519 PKCS#8 PEM/DER and RFC 8410 seeds withfromPemAuto,fromDerAuto, andfromEd25519Seed. Ed25519 CertificateVerify signing and verification work on native, OpenSSL, AWS-LC, and BoringSSL in non-approved profiles (#237).ServerHandshake.TicketParams.max_early_data_sizeadvertises an optional RFC 8446 §4.2.10 early-data limit in NewSessionTicket; its default remains disabled (#243).ServerHandshake.Credentials.initvalidates a certificate chain once and retains its required-signature bitset.ConfiguredCredentials.by_server_nameselects pre-validated credentials by SNI with a fallback, andsetServerCredentialssupports imperative selection before the server flight (#236).
Fixed
Certificate.parsenow enforces constructed DERSEQUENCEtags on the outer Certificate,tbsCertificate,signatureAlgorithm, andSubjectAltName(GeneralNames) wrappers unconditionally, closing false-accepts whenhost_nameis null (such as mTLS client certificates) (RFC 5280 §4.1, §4.2.1.6; #239).- ClientHello2 preserves the configured SNI when the caller reuses the ClientHello1 output buffer for a HelloRetryRequest response (#243). Servers retain SNI independently of reused ClientHello record storage and match DNS hostnames without ASCII case sensitivity (#236).
handshake_core.Clientderives application secrets through the server Finished, excluding EndOfEarlyData, and wipes handshake-scoped secrets after application-key derivation. The record adapter's RFC and OpenSSL early-data handshakes pin both behaviors (#242).- A P-384 keypair draw zeroes the CSPRNG scalar before returning, as the
P-256 draw already did. Both NIST curves are now one implementation in
src/ec_kex.zig, so a fix to one curve cannot miss the other (#125). - Builds on aarch64 Linux target the host CPU again instead of pinning
apple_m1. The pin dropped host features such as SVE2 and could emit instructions an older core does not implement. A default build now fails if its target is not native; pass-Dtargetor-Dcputo cross-compile (#229). - Servers reject a known PSK identity with an invalid binder using
error.InvalidPskBinder, which maps todecrypt_error. Unknown identities still fall through to certificate authentication (#227). - External PSK encoding rejects a ClientHello over 2^14 bytes with
error.ClientHelloTooLargeand an oversized extension vector witherror.ExtensionTooLong(#227).
Changed
-
Breaking:
tls_nonblocking.Server.initnow takes a caller-ownedServer.HandshakeScratchand pre-validatedoptions.handshake.credentialsinstead ofOptions.cert_chainandOptions.signer. Athandshake_completethe server releases the scratch and continues withEstablishedSession, so retired credential DER and private keys can be destroyed while application traffic and KeyUpdates continue (#236). -
Breaking:
ServerHandshake.ServerConfignow carriescredentials, including single and candidate-chain configurations, andConfigplus one post-placementbindStoragecall replace the suite, ALPN, credential, and buffer setters.sendServerFlightandsendServerFlightBufferedreplace the seven previous flight entry points. The record adapter delegates negotiation, transcript, PSK, early-data, client-authentication, and key-schedule state tohandshake_core.Server; failed records and flight emission roll back the whole attempted transition so a valid retry starts from the prior epoch (#242). -
Breaking:
ClientHandshake.Confignow carriescredentials,peer_cert_buffer, ALPN, reassembly, and traffic-secret storage directly. The post-initofferAlpn,useHandshakeBuffer,useTrafficSecretStorage,usePeerCertificateBuffer,setCredentials, andsetCertificateChainmethods are gone. Pinned wrappers that cannot address their storage duringinitcallbindStorageonce after placement.startWithPsk(out, offer)takesPskStart.resumptionorPskStart.external; resumption early data usesEarlyDataOfferinstead of a boolean, andstartWithExternalPskis gone. The record engine now delegates protocol, transcript, and key-schedule state tohandshake_core.Client, whose phase union also backs the record adapter (#242). -
Breaking: Client handshake error aliases include the core protocol error set.
errors.classifyandalert.alertForHandshakeErrorcover the added level, queue, key-retention, and ticket-encoding failures explicitly. -
Client
processServerHello,processHelloRetryRequest,processFlight, andhandleRecordare transactional. In particular, a client Finished encoding failure rolls back the entire inbound server flight so the caller can retry with a larger output buffer (#242). -
Breaking:
ClientHandshake.Event,ReceiveEvent,KeyUpdateEvent, andAlertErrorare aliases of the shared definitions intls.handshake, so the client, the server, andEstablishedSessionpublish one event shape. A switch overServerHandshake.EventorServerHandshake.ReceiveEventmust now carry a.new_session_ticketarm — tickets are server-issued, so a server never produces one — andClientHandshake.AlertErrorgainederror.BufferTooShort. -
Breaking:
tls.client_helloexposes four encoders and one parser instead of a telescopic ladder.encode(out, params),encodedLen(params),encodeWithPsk(out, params, psk),encodeRetry(out, retry_params), andparse(msg, opts)replaceencodeWithP256,encodeWithP256P384,encodeWithKem,encodeWithHybridGroups,encodeWithHybridGroupsAndExtensions,encodeWithPskAndHybridGroups,encodeRetryAfterHrr,encodeRetryAfterHrrWithHybrid,encodeRetryAfterHrrWithHybridAndPsk,encodedLenWithP256,encodedLenWithP256P384, andparseWithExtensions. Capabilities travel inEncodeParams,PskParams, andRetryParams, so a new knob no longer adds a function.parsenow takesParseOptions, which was already available asparseWithExtensions; callers pass.{}for the previousparse.encodeWithPsktakesEarlyDataOffer(none/offer) instead of anoffer_early_data: bool, andencodeRetryreturnsPskEncodeResultso a retry binder can be patched. -
Breaking:
tls.certificatehas one Certificate encoder and one CertificateVerify verifier.encode(out, request_context, certs_der)andencodedLen(request_context, certs_der)replaceencode,encodeWithRequestContext,encodedLen, andencodedLenWithRequestContext; a server Certificate passes&.{}because its request_context is empty.verifyCertificateVerify(role, msg, pub_key, transcript_hash, offered_schemes)replacesverifyServerSignature,verifyServerSignatureWithSchemes,verifyClientSignature, andverifyClientSignatureWithSchemes;roleistls.certificate.Role(.clientor.server) and selects the RFC 8446 §4.4.3 context string, while a nulloffered_schemesskips the offered-scheme filter. Thetls.certificate_chainencoder takes the samerequest_contextand no longer has a separateencodeWithRequestContext. -
Breaking:
tls.capabilitiesnow publishes oneProfilerow per backend instead of a dozen namedboolconstants.supportsServerX25519,supportsServerP256,supportsServerP384,supportsClientP384,supportsServerX25519Mlkem768,supportsClientHybridGroup, andsupportsServerHybridGroupare gone; callsupportsGroup(role, group)andsupportsHybridGroup(role, group)instead. -
The crypto provider backends moved to
baskingspot/crypto, whichtlsdepends on.zig fetch --saveresolves it automatically; an existingpkg-configsetup needs no change. -
Breaking: A known PSK identity whose binder does not verify now aborts the handshake with
error.InvalidPskBinder(decrypt_error) instead of falling through to certificates, andServerHandshake.selectPskreturns that error instead ofnull. RFC 8446 §4.2.11.2 requires the abort, and it applies to resumption tickets as well as external PSKs. A bad first known binder also aborts rather than trying a later identity (#227). -
Breaking: The default
-Dcryptovalue isnative. Default builds need no libcrypto headers or library. Native is for development and iteration, not production. No performance measurement against libcrypto or independent security review exists for native. Production builds must select-Dcrypto=opensslor-Dcrypto=aws-lc.-Dcrypto=autoremains available for libcrypto header detection. Native does not support RSA signing, encrypted PEM, or ML-KEM-1024. A native server needs an ECDSA P-256/P-384 or Ed25519 credential. Native loads Ed25519 keys, verifies Ed25519 chain signatures, and signs and verifies Ed25519 CertificateVerify (#199, #237). -
Certificates issued by an RSASSA-PSS SubjectPublicKeyInfo key now fail with
error.CertificateSignatureAlgorithmUnsupported. Thersa_pss_pss_*schemes and RFC 4055 §3.3 parameter validation remain unsupported instead of using thersa_pss_rsae_*mapping (#219).
Added
tls.handshakeis exported: the event types, error sets, and connected record-path helpers the client, the server, andEstablishedSessionshare.tls.handshake.NewSessionTicketnames the type thenew_session_ticketevent arm carries;ClientHandshake.NewSessionTicketstays as an alias.tls.p384.KeyPair.fromSecretbuilds a P-384 keypair from a caller-supplied scalar, matchingtls.p256.KeyPair.fromSecret(#125).- Native builds register
zig build bench, including AES-256-GCM seal/open rows at 4 KiB and 16 KiB, without linking libcrypto. - Clients advertise and accept
rsa_pss_rsae_sha256/384/512insignature_algorithms_certon libcrypto and native backends. PSS-signed certificate chains can now complete handshakes (#219). - Servers that request client certificates now accept PSS-signed chains through the default certificate policy (#219).
Removed
tls.x25519.toProvider,tls.p256.toProvider, andtls.p384.toProvider. Nothing in the tree called them; a negotiated group is already anEcCurvevalue, and a keypair is built from the curve type.
Fixed
- AEAD decryption securely zeroes the whole output slice on authentication failure
on every backend. Exact in-place decryption remains supported. Partial input/output
overlap returns
error.InputAliasesOutputwithout modifying either slice.
0.4.6 - 2026-11-23
Added
cryptoLibs(b)inbuild.zigreports the libcrypto-family pkg-config modules this build resolved:libcrypto/libssl,libcrypto-awslc/libssl-awslc, or the bare library name. A consumer that compiles its own C API against the same library reaches it withb.lazyImport(@This(), "tls")and passes.crypto/.ssltolinkSystemLibrary, so both builds name one library (#223).
0.4.5 - 2026-11-23
Added
-Dcrypto=nativeselects an opt-in, primitive-only backend overstd.crypto. X25519, P-256/P-384 ECDH, all three TLS AEAD suites, SHA-256/SHA-384, HMAC, HKDF, and raw-seed Ed25519 operations work without libcrypto. ECDSA P-256 and P-384 support CertificateVerify signatures and certificate chains. Chains also support Ed25519 signatures and RSA PKCS#1 v1.5 chain signatures with SHA-256/384/512, and verify RSA-PSS CertificateVerify with those hashes. Native loads unencrypted P-256/P-384 PKCS#8 and SEC1 keys from PEM and DER, and Ed25519 seeds from PKCS#8. These keys can pair with their leaf certificates. The backend supports RFC 10024x25519_mlkem768andsecp256r1_mlkem768key exchange in both roles.- Native RSA signing and encrypted PEM remain unsupported, with named errors.
Use
-Dcrypto=opensslor-Dcrypto=aws-lcfor those capabilities. ML-KEM-1024 andsecp384r1_mlkem1024remain unsupported (#199, #215, #216). - Native client and server handshakes exchange application data in memory, over
TCP, and against OpenSSL in both roles. Conformance cases that require absent
RSA signing or ML-KEM-1024 capabilities report
UNSUPPORTEDwith the backend and capability names (#199). - The
hkdf.Hkdftype constructor is public for backends that select their own runtime and comptime hash pair. ServerHandshake.setCredentialCandidatesandhandshake_core.Server.selectCredentialsselect the first configured certificate chain and signer whose CertificateVerify scheme and certificate-chain signature algorithms satisfy the client's offers.ServerHandshake.setCredentials,setCertificateChain, andsetCredentialCandidatesnow returnCredentialError!voidso empty, malformed, or unsupported certificate chains fail at configuration time instead of on every handshake (#209).
Changed
- Native key loading reads every block in a PEM file and returns the first key
block, so
openssl ecparam -genkeyoutput and a combined certificate-then-key file load as they do on libcrypto (#218). - Native decompresses a compressed SEC1 public key before it compares the point,
and returns
error.UnsupportedPointFormatfor a hybrid point. - Native returns
error.InvalidPrivateKeyfor a scalar of zero or at least the curve order when it loads a key or constructs one from a scalar, instead oferror.LibcryptoFailed. PrivateKey.fromDerandfromPemreturn the backend's key-load error set, andfromP256Scalarreturns the backend's scalar-key set.error.DeterministicNonceUnsupportedleft all three, anderror.UnsupportedKeySchemestays onfromPemAuto, which is the only loader that infers a scheme. Native addserror.InvalidPrivateKeyto its set.- X.509 RSA SubjectPublicKeyInfo parsing is stricter on every backend.
rsaEncryptionrequires exactly NULL parameters. RSASSA-PSS parameters are optional and absent means unrestricted.PubKeyAlgo.rsassa_pssnow carries?PssParametersinstead of no payload. RSAPublicKey INTEGERs must be positive and minimally encoded. The verification-only RSA module removedPSSSignature.fromBytesandPKCS1v1_5Signature.fromBytes; useverifyDerfor slice-based verification (#215). - Backend EC key handles can hold inline native bytes. Their cleanup functions take a pointer to the handle, so native erases caller-owned key material (#199).
-Dcrypto-fipsis now-Dcrypto-approved-only,capabilities.is_fipsiscapabilities.approved_only, and the backend identities areopenssl-approved/aws-lc-approved. The option selects an approved-algorithm policy: AES-GCM suites, P-256/P-384 groups, and the corresponding signature schemes. It never made tls a FIPS 140-3 validated module and no longer implies it, because the key schedule, all randomness, signature verification, and on OpenSSL the transcript hash and EC key construction run outside the linked module.PRODUCTION_READINESS.mdlists the split.capabilities.cipher_suites,supportsCipherSuite(suite),supportsGroup(role, group),supportsCertificateVerifyScheme(scheme), andsupportsCertificateSignatureScheme(scheme)are new.- An approved-only build no longer advertises X25519, which the FIPS 140-3 implementation guidance excludes from key agreement, and a client in that build sends a P-256 first flight instead. Certificate-chain signature schemes in the approved table now include RSASSA-PKCS1-v1_5 and Ed25519, which FIPS 186-5 approves.
- A ClientHello with no backend-supported handshake signature scheme returns
error.NoCommonSignatureSchemeinstead of the removedclient_hello.ParseError.UnsupportedSignatureSchememember. The peer alert is nowhandshake_failure(40) instead ofillegal_parameter(47).errors.classifyreturns.protocolinstead of.certificate, andtls-stdreturnsHandshakeProtocolErrorinstead ofCertificateVerificationFailed(#208). - ECDSA P-256/P-384 signing now runs in-tree on OpenSSL, AWS-LC, and
BoringSSL.
PrivateKey.nonce_mode = .deterministicno longer depends on an OpenSSL 3 provider and produces the same RFC 6979 signatures on each backend. The default.randommode keeps randomized nonces by adding fresh OS entropy under RFC 6979 §3.6. RSA-PSS signing still uses libcrypto (#82, #183).
Changed
tlsrequires Zig 0.17. The 0.16 lane is gone:build.zig.zonasks for 0.17.0 in the root, integrations, and conformance, the.#zig-oldshell and the 0.16 CI lane are removed, and the 0.16-only code paths and shims are deleted.tls_nonblocking.SocketClientdeadlines always useIo.Operation.net_read, the cancel hook polls every 100 ms, anderror.DeadlineUnsupportedis removed; an Io implementation that cannot wait concurrently reportserror.ConcurrencyUnavailable.
Fixed
- The build resolves the libcrypto family through pkg-config, so an aws-lc
package that installs
libcrypto-awslc/libssl-awslcwith headers underinclude/aws-lclinks and translates instead of failing withunable to find dynamic system library "crypto". Unprefixed packagings keep linking-lcrypto/-lssl. A prefixed aws-lc build (symbolPrefixset) remains unsupported: translate-c cannot evaluate the prefix header's token-pasting aliases, so build the package withsymbolPrefix = null(#223). - Both server engines (
ServerHandshakeandhandshake_core.Server) enforcesignature_algorithms_cert, falling back tosignature_algorithmswhen omitted, during certificate selection, including RSASSA-PSS-signed certificates (rsa_pss_rsae_sha256/384/512). An incompatible chain returnserror.NoCommonSignatureSchemeand maps to fatalhandshake_failurebefore any Certificate message is sent.ClientHandshakeandhandshake_core.Clientapply the same effective offer to server chain verification (#209). - A certificate-authenticated server selects CertificateVerify only from the
client's offered schemes. No match for the configured credential fails with
fatal
handshake_failurebefore signature generation (#208). handshake_core.Clientselects client CertificateVerify only from the CertificateRequest offer. An empty intersection returnserror.NoCommonSignatureSchemebefore authentication output and maps to fatalhandshake_failure.handshake_core.Serverpreserves the same parse-time error instead of mapping it tounexpected_message(#212).- A native server with no signature scheme in common with a ClientHello now
sends
handshake_failureinstead ofillegal_parameter. ECDSA verification classifies a point-at-infinity public key as an invalid encoding (#199). tls_stdfills every eligibleIo.Reader.readVecdestination slice from the pending TLS record. A small first slice no longer makes std buffer that record and return zero to the caller. Direct single-slice reads and theread_buffercapacity are unchanged (#189).
0.4.4 - 2026-11-16
Added
tls_nonblocking.SocketClient.Options.trustis one decision:.pemfor PEM blocks the adapter parses and owns,.bundlefor a trust store the caller loaded and keeps,.nonefor no anchors. A borrowed store must outlive theSocketClientand must not be mutated or deinitialized while it is borrowed. This replacesOptions.ca_pem; usetrust = .{ .pem = pem }.
Changed
tls_std.Server.accepttakes a*Scratch, one per worker, and the finished connection holds the established session instead of the handshake engine and its ClientHello reassembly buffer. With default buffers atls.Serveris 83,768 bytes rather than 135,184: 51,416 fewer per connection, about 514 MB across 10,000 idle connections. Declarevar scratch: tls_std.Server.Scratch = .init;beside the accept loop and pass&scratch.Config.reassembly_storagenow sizes that scratch on a server. The client is unchanged (#169).- CertificateVerify verification runs in-tree for every scheme tls accepts:
ECDSA on
std.cryptoand RSA-PSS on the in-tree RSA module. A peer can no longer reach the libcrypto backend through a signature, andcertificate.VerifyErrorno longer carriesLibcryptoFailed. Two limits move with it: an RSA leaf key must have a 128, 256, 384, or 512-octet modulus (1024, 2048, 3072, or 4096 bits; before, any key from 1024 to 8192 bits was accepted), and an RSAPublicKey with trailing bytes is rejected by the shared parser.
Fixed
- RSA-PSS verification now derives EM per RFC 8017 §8.1.2 step 2c and checks
the whole padding run per §9.1.2 step 10. The in-tree verifier checked one
octet of that run, which weakens the encoding check, and it aborted a Debug
or ReleaseSafe build when a modulus has a leading octet of 0x01 (its bit
length is one more than a multiple of eight). No handshake in an earlier tag
reached this verifier, because CertificateVerify
used the backend and chain verification only ever used PKCS#1 v1.5. Direct
callers of the public
tls.Certificate.rsa.PSSSignature.verifyin v0.4.2 were exposed (#183).
0.4.3 - 2026-11-16
Changed
tls_nonblocking.SocketClient.Options.cancelnow covers the connection, not only the handshake: the hook is consulted between application-data reads and a pending read ends witherror.Canceledwithin the 100 ms poll interval. This reverses 0.4.2, where the hook was cleared when the handshake ended. Thecontextpointer must now outlive theSocketClient; a hook scoped to the connect call is a use-after-free. With a hook set, every application read takes the batch read path with a 100 ms cap instead of one plain read.
0.4.2 - 2026-11-15
Added
handshake_core.Server.selectedGroup()returns the key-share group to answer with: the first ofServer.group_preference(x25519, secp256r1, then secp384r1 when a P-384 keypair is set) that the ClientHello carried a share for. Null means no usable share, so the caller sends HelloRetryRequest.tls_nonblocking.SocketClient.Options.cancelruns a caller hook at the top of each handshake step and at least every 100 ms while a handshake read waits. Returning true endsinitwitherror.Canceled, so a dialer can abandon a black-holed handshake instead of waiting for the read deadline. The hook is cleared when the handshake ends, so a live connection never slices a read it cannot cancel. A poll timeout retries the read and does not setexpired(); only a real deadline does. On Zig 0.16 the runtime cannot bound a socket read, so the hook runs between steps only anddeadline_nskeeps its meaning. The socket stays caller-owned, and a failedinitis still safe todeinit.- A verified certificate's identity is readable without a second X.509 parser.
Parsed.subjectAttributes()andissuerAttributes()walk the distinguished name asNameEntryvalues (modeled attribute or raw OID, plus the string with its ASN.1 encoding),Parsed.subjectAltNames()walks the SANs asGeneralNamevalues, andDirectoryString.writerenders one value into anIo.Writer. Nothing allocates and nothing is decoded until it is rendered.writetranscodes BMPString and UniversalString, and escapes C0 controls, DEL, and invalid UTF-8, because the text came from the peer (#172). tls.der.validCertificatechecks the DER envelope of a certificate without decoding its fields: one SEQUENCE that fills the buffer, three children, and a tbsCertificate with its mandatory fields. It exists so a caller can refuse malformed DER before std's uncheckedder.Element.parsewalks it.tls_std.trust_storeloads trust anchors from PEM bytes, a file, or the OS store, and rejects a block whose DER envelope is malformed.handshake_corecarries QUIC transport parameters (RFC 9001 §8.2) in both directions.Client.receiveExtensions(allowed, slots)andServer.receiveExtensions(allowed, slots)name the extension types to keep and the caller-owned slots to keep them in, andpeerExtensions()returns what the peer sent, in wire order. The bytes borrow the peer's message, so copy them before the next call into the core.Server.sendExtensions(extras)adds the server's own to EncryptedExtensions, andflightBufferLencounts them. A client that allows nothing still refuses an unexpected extension witherror.UnsupportedExtension; a server ignores an unlisted one. A listed type with no free slot iserror.ExtensionSinkFull.tls.KeyPairsis exported.handshake_core.Client.useKeypairs,startEncoded, andServer.useKeypairstake it, and before this it had no public name, so a consumer could not call them.handshake_core.Server.applicationSecrets()returns the application traffic secrets oncesendFlighthas derived them, and null before. A QUIC server needs them to protect 1-RTT packets (RFC 9001 §4.1.1).client_hello.parseWithExtensions(msg, ParseOptions)keeps the extensions the caller allows inParsed.extensions.parseis unchanged.extension_type.ExtensionSinkis the sink type;encrypted_extensions.ExtensionSinkstays as an alias.
Changed
alert.alertForErroranswers every engine error with the alert RFC 8446 §6.2 defines for it, andalert.alertForHandshakeErrorreplaces the old fall-through with a switch that is exhaustive over the engine's error set: a new error does not compile until someone decides what the peer is told. 27 errors that reachedinternal_errornow say what actually happened —unexpected_messagefor a HelloRetryRequest, a record with the wrong content type, or a post-handshake flood;decode_errorfor a malformed ALPN entry;bad_certificatefor an oversized chain or a repeated extension;decrypt_errorfor a certificate signature that did not verify. The rest are ours by fault (buffer sizing, caller options, missing backend capability) and stayinternal_errordeliberately, each with a reason at its arm (#171).- An address-literal
host_namesends no SNI.host_nameis both the SNI value and the certificate reference identity, and RFC 6066 §3 forbids a literal IPv4 or IPv6 address in theserver_nameextension. The extension is now omitted for an address, the way every other TLS stack does it; theiPAddressSAN check still runs against the samehost_name(#178). tls_stdreports why a certificate was refused instead of one opaqueCertificateVerificationFailed:CertificateExpired,CertificateNotYetValid,CertificateHostMismatch,CertificateIssuerNotFound, andCertificateSignatureInvalid, on bothConnectErrorandAcceptError(AcceptErrorhas no hostname cause). A cause with no distinct corrective action staysCertificateVerificationFailed(#173).- Hostname verification accepts an address literal.
Policy.host_namewith an IPv4 or IPv6 address is compared againstiPAddresssubjectAltName entries instead ofdNSName(RFC 9525 §6.2.1), in the four-octet and sixteen-octet forms, with an IPv4-mapped address treated as its IPv4 address. A DNS reference still matchesdNSNameonly, and a wildcard still matches no address. Before this, an address literal could only connect withhost_name = null, which disables the check (#176). tls_stdwithVerify.system_bundlereads the Linux trust store itself instead of callingBundle.rescan. A truncated certificate in/etc/ssl/certsis nowerror.CertificateVerificationFailed; before this it panicked a Debug or ReleaseSafe build and read out of bounds in ReleaseFast (#177). macOS still rescans the keychain, whose binary store format std owns.
Fixed
handshake_core.Server.provideClientHellono longer fails witherror.HybridServerUnsupportedwhen the ClientHello carries an RFC 10024 hybrid share such as Go 1.24's default X25519MLKEM768. The share is skipped and a classical one is selected, as RFC 8446 §4.2.8 requires.handshake_core.Clientderives its application traffic secrets over the transcript through the server Finished, as RFC 8446 §7.1 requires. A client that sent a Certificate and CertificateVerify hashed those in as well, and so disagreed with its server on every 1-RTT key.handshake_core.Client.applicationSecrets()returns null untilsendClientFinishedhas derived them. Before this it copied uninitialized bytes, and a caller could install 1-RTT keys from them.
0.4.1 - 2026-11-12
Changed
- The
stdxpin is v0.4.0, so one stdx instance serves every graph that also holds stdx directly. Additive over 0.3.0: no API change for tls.
0.4.0 - 2026-11-11
Removed
tls_xev, the.xevdependency option, and the root package's libxev dependency. A consumer that importstls_xevmust drive the engine from its own libxev completions, usetls_nonblocking, or stay on v0.3.0. The module is no longer exported, and.xev = trueinb.dependency("tls", ...)now fails witherror: invalid option: "xev".
0.3.0 - 2026-11-10
Added
Certificateexposes the bounds-checked X.509 parser. PEM anchor validation uses it before the standard-library bundle parser.handshake_core.Serverderives the shared secret too, so no public entry in either role accepts one. The server retains the client's classical key shares from the ClientHello in caller-owned storage (usePeerShareStorage, sized bypeer_share_storage_len) and derives inprovideServerHellofrom its own keypairs (useKeypairs). A short buffer iserror.PeerShareStorageTooSmall, never a truncated share, and a ClientHello offering RFC 10024 hybrid iserror.HybridServerUnsupportedbecause the core has no server-side KEM path yet. The retained shares are public material and are not zeroized; the keypairs are, indeinit.handshake_core.Clientderives the shared secret itself.providetakes the ServerHello and nothing else: the client retains the keypairs fromstartEncoded/startEncodedWithPsk(oruseKeypairsfor a caller-encoded ClientHello) and derives classical ECDHE and RFC 10024 hybrid alike. Both the ephemeral keypairs and the retained KEM key are secret state, zeroized indeinit.offerHybridsets the hybrid policy and optional initial share;capabilities.HybridPolicyis the one policy type, andClientHandshake.HybridPolicyaliases it. A caller can no longer hand the core a shared secret, so it cannot hand it the wrong one.tls_nonblocking.Client: a caller-driven TLS 1.3 client with the same shape asServer— caller-owned buffers, one outbound record at a time, no thread and no blocking call. Events areneed_input,need_output,progress,handshake_complete,application_data,key_update,new_session_ticket,close_notify, andclosed;close_notifystays distinct fromclosedbecause RX can end while TX stays open (RFC 8446 §6.1). ALPN is reported, not enforced: a caller that requiresh2checksselectedAlpn()afterhandshake_complete. Trust anchors come fromOptions.ca(Baskingspot issue #167).tls_nonblocking.SocketClientis a blocking TLS client over a caller-ownedstd.Io.net.Stream. It exposes plaintext byte interfaces and preserves TLS errors through diagnostic methods. Read deadlines include handshake waits and exclude writes. Future deadlines require Zig 0.17. Zig 0.16 reportsDeadlineUnsupportedfor future waits. The caller owns the socket.tls_nonblocking.anchors.buildparses PEM trust anchors into an owned bundle. A parse failure discards the incomplete bundle.ClientHandshake.NewSessionTicketis public, so a caller can name the type itsnew_session_ticketevent carries.tls_nonblocking.anchors.addCertsFromPemBytesloads trust anchors from PEM bytes into a caller-ownedCertificate.Bundle, so a client handed a CA in memory no longer needs a file on disk. It returns the number of anchors added, because std drops an expired or unrecognized one silently (#175).
Changed
- The tree builds and tests on Zig 0.16 and 0.17 from one source.
nix developis 0.17;nix develop .#zig-oldis 0.16.just checkruns the Debug and release-mode suites on whichever compiler the shell carries, and CI runs the full gate on 0.17 plusjust checkon 0.16 (#174). The minimum supported Zig is still 0.16. tls_std,tls_nonblocking, andtls_ktlsbuild and test on Zig 0.17 as well as 0.16.tls_xevstays 0.16 because its pinned libxev commit does not implement the 0.17std.Iovtable.alert.alertForErrorreturns?Descriptionand mapserror.PeerAlertto null. The peer already sent its own alert, so answering it with another alert — previouslyinternal_error— blamed the wrong side (RFC 8446 §6.2). Integrations drop theirPeerAlertspecial case.
Added
- Caller-supplied TLS extensions:
extension_type.ExtraExtensionridesClientHelloorEncryptedExtensionsas opaque bytes, andConfig.required_extensionsmakes an absent one fail the handshake witherror.MissingRequiredExtensionandmissingExtension()naming the type. The peer seesmissing_extension(RFC 8446 §6.2). Every existing encoder signature is unchanged; the extensions-aware forms are new functions. QUIC transport parameters need nothing more from tls than this. ClientHandshake.clientFinishedMessageandServerHandshake.processClientFinishedMessageexchange the Finished as bare handshake messages, for a caller that owns its own record layer (QUIC CRYPTO frames). Both enter the same state machine as the record paths:clientFinishedandprocessClientFinishedare now thin wrappers around the shared assembly and verification code, and the record output is unchanged. The bare client path rejects a 0-RTT handshake witherror.EarlyDataUnsupported, because EndOfEarlyData is not part of that flight; it classifies as an internal limitation, not a peer protocol error.ClientHandshakeandServerHandshakecan retain the TLS 1.3 traffic secrets when the caller asks: setConfig.traffic_secretsor calluseTrafficSecretStorage, andtrafficSecrets()returns them. Without it the engine derives and wipes exactly as before, and the accessor returnserror.NotRetainedrather than zeros.traffic_secrets.TrafficSecrets.expandapplies HKDF-Expand-Label to a held secret for callers that derive their own keys, such as QUIC (RFC 8446 §7.1, RFC 9001 §5.1).
Fixed
tls_nonblocking.anchorsreturnsInvalidCertificateDerfor certificates with excessive fields instead of an integer-overflow panic.SocketClient.initrejects out-of-order handshake application data withUnexpectedRecordinstead of a loop without progress.
0.2.1 - 2026-11-05
Fixed
- The source archive no longer carries
docs/, sozig fetchpulls 826 KB instead of 10.3 MB. The release workflow refuses an archive over 2 MiB, so research cannot creep back in (#170).
0.2.0 - 2026-11-05
Added
tls_nonblocking.Server: a caller-driven TLS 1.3 server with caller-owned buffers, incremental handshake progress, and explicit backpressure (#167).
Changed
ServerHandshake.initnow takes reusableServerConfigpolicy separately from per-connectionConfigkeys, random, and buffers.tls_nonblocking.Server.inittakes the same split, so listenerOptionscannot hold ephemeral connection state (#168).
0.1.1 - 2026-10-31
Changed
ClientHandshake.ConfigandServerHandshake.Configare options bags again: build them as a struct literal with the required fields named, and dropConfig.init. The client'sbundle,insecure_no_chain_anchor,alpn_protocols,hybrid, andreassembly, and the server's optional fields, carry their defaults again.ClientHandshake.init(.{ ... })reads as one value instead of an argument order plus post-construction writes.
0.1.0 - 2026-10-30
Added
ServerHandshake.PskEntry.alpn: optional ALPN of the connection that issued the ticket, required for 0-RTT acceptance (#161).ClientHandshake.SessionTicket.alpn_protocol: ALPN of the session that issued the ticket;deriveSessionTicketrecords it so a resumption can check it against accepted early data (#162).
Changed
- Public structs no longer accept a bare
.{}or a partial literal; start from the named constructor and assign any fields you override. Construction changed forClientHandshake(init(Config.init(...))),ClientHandshake.Config.init,ClientHandshake.HybridPolicy.empty,ClientHandshake.SessionTicket.init,ServerHandshake(init(Config.init(...))),ServerHandshake.Config.init,ServerHandshake.PskEntry.init,ServerHandshake.TicketPsk.init,EstablishedSession.init,Outbox.init,RecordBuffer.init,RecordLayer.init/KtlsInfo.init,encrypted_extensions.Options.init/Parsed.empty,client_hello.Parsed.init/SupportedGroups.empty,certificate.Policy.init,certificate_parser.Parsed.init,signature.PrivateKeyloaders,handshake_key_pairs.KeyPairsconstructors, andframe.Header.init. - C ABI names are
baskingspot_tls_*, withinclude/baskingspot_tls.handlibbaskingspot_tls.a. Rename everyztls_*call,ZTLS_*enumerator, and#include "ztls.h", and link-lbaskingspot_tls. The C surface has never been released, so there is no compatibility alias (#149).
Fixed
- Client
wait_shhandlers are transactional: a rejected ServerHello or HelloRetryRequest (e.g.BufferTooShortfrom a large HRR cookie) no longer leaves the transcript union collapsed, so retrying with a larger buffer or processing the next record no longer reads an inactive union field (#158). - Client now aborts with
error.IllegalParameter(illegal_parameter alert) when a server accepts 0-RTT under a cipher suite or ALPN that differs from the ticket's, per RFC 8446 §4.2.10 (#162). - C ABI:
baskingspot_tls_client_init_insecurenow copieshost_nameinto handle-owned storage (caller may free/overwrite it after init), treats an empty string as no SNI, and rejects names over 253 bytes withBASKINGSPOT_TLS_ERR_HANDSHAKE_FAILURE(#159). ServerHandshakeClientHello processing is now transactional: a ClientHello that fails after PSK selection no longer leaves its PSK, 0-RTT key, or other negotiation state for the next ClientHello, and a failed HelloRetryRequest no longer leaves half-armed retry state (#160).ServerHandshakenow accepts early data only when the RFC 8446 §4.2.10 preconditions hold: first offered identity, exact ticket/negotiated cipher suite equality, and ticket/selected ALPN equality; otherwise the offer is declined and in-flight 0-RTT records are skipped (#161).- The CertificateVerify RSA key loader (
rsaPublicKeyFromDer) now rejects degenerate peer keys — trailing bytes after the RSAPublicKey, an even or 1-valued or wider-than-32-bit public exponent, and an even or out-of-range (below 1024 or above 8192 bits) modulus fail witherror.InvalidEncodingbefore any signature verification. An exponent-1 key previously made the RSA public operation the identity, so any well-formed PSS encoding verified as a CertificateVerify signature (#157). - Name constraints: a zero-length dNSName constraint now matches every DNS name per RFC 5280 §4.2.1.10, so an excluded empty dNSName rejects any leaf DNS SAN or Common Name fallback beneath that CA (#154).
- Name constraints: an excluded dNSName now rejects a wildcard SAN whose
single-label expansion set intersects the exclusion (e.g. SAN
*.example.comunder excludedsecret.example.com); this deliberately diverges from OpenSSL 3.6, which still compares the wildcard label literally (#156). - Chain verification:
certificate.parseandcertificate.parseClientChainnow apply the leaf's role EKU to every in-chain issuer and to the trust anchor — an issuer carrying an ExtendedKeyUsage extension must include the role OID or id-kp-anyExtendedKeyUsage, otherwise the chain fails witherror.CertificateExtendedKeyUsageRejected(#155). certificate_policy.verifyIssuerUsage,findVerifiedIssuerInBundle, andverifyAgainstBundletake a newrole: LeafUsageparameter (#155).