
Implementazione in Zig di TLS 1.3 per QUIC, conforme a RFC 8446/9001 con zero dipendenze esterne, dotata di protezione AEAD, validazione X.509 e oltre 1000 test.
Un'implementazione TLS 1.3 per QUIC scritta in Zig, che aderisce rigorosamente a RFC 8446 (TLS 1.3) e RFC 9001 (QUIC-TLS).
| Aspetto | Info |
|---|---|
| Stabilità API | Production |
| Versione Zig | 0.16.0 |
| Piattaforme | Linux, macOS, Windows |
L'obiettivo di handshake <2 ms è validato su configurazioni di certificati Ed25519 e RSA-2048. I carichi di lavoro secp256r1 (P-256) attualmente richiedono 2–3 ms per handshake a causa di una limitazione a monte della stdlib di Zig (PERF-229). Consulta ADR-0002 per il record decisionale completo.
✅ Conforme RFC - Implementa TLS 1.3 (RFC 8446) e QUIC-TLS (RFC 9001) ✅ Zero Dipendenze - Utilizza solo la libreria standard di Zig ✅ Testato per Interoperabilità - Test di conformità contro BoringSSL e OpenSSL ✅ Nativo per QUIC - Progettato per l'integrazione QUIC, nessun livello record tradizionale ✅ Ben Testato - 551 test unitari + vettori di test RFC + 449 test di conformità
# Build and test everything
make
# Or manually
zig build
zig build test
Il progetto utilizza sia un Makefile che build.zig per flessibilità:
# Build and run all tests (default)
make
# Build only
make build
# Run specific test suites
make test-unit # Unit tests
make test-vectors # RFC 8446/9001 test vectors
make test-conformance # BoringSSL/OpenSSL conformance (requires libssl-dev)
# Development workflow
make dev # Format + check + unit tests
make clean # Clean build artifacts
make help # Show all available targets
# Build the library
zig build
# Run all tests
zig build test
# Run specific test suites
zig build test-vectors
zig build test-conformance # Requires OpenSSL dev libraries
# With optimizations
zig build -Doptimize=ReleaseFast
Build Summary: All steps succeeded; 1000 tests passed ✅
Copertura completa dei test:
Totale: 1000 test che garantiscono conformità RFC, parità crittografica e prontezza per la produzione
src/
├── lib.zig # Main library entry point
├── tls13/ # TLS 1.3 handshake state machine (modularized)
├── tls13_full.zig # Full TLS 1.3 message parsing
├── key_schedule.zig # HKDF-based key derivation
├── record.zig # Record layer & AEAD operations
├── x509.zig # Certificate parsing & validation
├── sig.zig # Signature verification
├── asn1.zig # ASN.1 DER decoder
├── alert.zig # TLS alert protocol
├── entropy.zig # Fail-closed RNG helper (SEC-074)
├── zero_rtt.zig # 0-RTT support
└── quic_*.zig # QUIC integration interfaces
tests/
├── rfc8446_vectors.zig # RFC test vectors
├── boringssl_conformance.zig # BoringSSL parity tests
└── openssl_conformance.zig # OpenSSL conformance tests
const std = @import("std");
const tls = @import("ztls");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
// Configure TLS context
const config = tls.Config{
.allocator = gpa.allocator(),
.role = .client,
.supported_cipher_suites = &.{.TLS_AES_128_GCM_SHA256},
.supported_groups = &.{.x25519},
.alpn_protocols = &.{"h3"},
};
// Set up callbacks
const callbacks = tls.Callbacks{
.on_secret_available = mySecretCallback,
.on_handshake_complete = myHandshakeCallback,
};
// Initialize TLS context
var ctx = try tls.Context.init(config, callbacks);
defer ctx.deinit();
// Process incoming CRYPTO frames from QUIC
try ctx.processCrypto(crypto_data);
}
std.crypto.kdf.hkdfIl progetto include test di conformità completi per garantire la compatibilità con le implementazioni TLS standard del settore:
Per eseguire i test di conformità:
# Install OpenSSL development libraries first
make install-deps # Auto-detects your OS
# Run conformance tests
make test-conformance
ztls è dotato di un punto di osservabilità OpenTelemetry opzionale. Quando il flag di build -Dwith_otel=true è impostato, la libreria emette esattamente uno span per handshake TLS (nome span: "TLS handshake") con i seguenti attributi di convenzione semantica allegati al completamento:
tls.role -- "client" o "server"tls.protocol.version -- "1.3" (sempre per ztls)tls.cipher_suite -- il cifrario negoziato (es. TLS_AES_128_GCM_SHA256)network.protocol.name -- "tls"# Default build: no otel symbols, zero overhead.
zig build test
# Enabled build: one span per handshake, exported via the OTLP
# defaults (http://localhost:4318) or whatever OTEL_* env vars
# specify.
zig build test -Dwith_otel=true
Il punto di osservabilità è controllato da una dipendenza lazy, quindi il pacchetto otel viene recuperato solo quando il flag è attivo. Il codice di entry-point dell'applicazione che vuole installare un TracerProvider deve chiamare ztls.observability_init.Otel.init e poi installGlobals(); consulta la ricetta di integrazione otel a monte (otel/docs/integration/RECIPE.md) per il bootstrap completo dell'applicazione host.
# Quick development iteration
make dev
# Format code
make fmt
# or
zig fmt src/ tests/
# Check syntax
make check
# Clean build
make clean build
Quando si aggiungono funzionalità:
Licenza Apache-2.0 - consulta LICENSE per i dettagli.
Realizzato con Zig 0.16.0 | TLS 1.3 | QUIC-Native | Conforme RFC