Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
tls — Zig 实现的 TLS 1.3,用于 QUIC,符合 RFC 8446/9001 标准,零外部依赖,具备 AEAD 保护、X.509 验证以及 1000+ 项测试。 | Kitploit
工具/GitLabGitLab/devnw/zig/tls
网络安全密码学
GitLabdevnw/zig/tls

tls

Zig 实现的 TLS 1.3,用于 QUIC,符合 RFC 8446/9001 标准,零外部依赖,具备 AEAD 保护、X.509 验证以及 1000+ 项测试。

查看仓库
1个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

ztls

用 Zig 编写的 QUIC TLS 1.3 实现,严格遵守 RFC 8446 (TLS 1.3) 和 RFC 9001 (QUIC-TLS)。

状态

方面信息
API 稳定性生产就绪
Zig 版本0.16.0
平台Linux、macOS、Windows

性能说明

在 Ed25519 和 RSA-2048 证书配置上已验证了小于 2 毫秒的握手目标。secp256r1 (P-256) 工作负载当前每次握手运行 2–3 毫秒,原因是上游 Zig stdlib 的限制(PERF-229)。完整决策记录见 ADR-0002。

特性

✅ 符合 RFC - 实现 TLS 1.3 (RFC 8446) 和 QUIC-TLS (RFC 9001) ✅ 零依赖 - 仅使用 Zig 标准库 ✅ 互操作性测试 - 与 BoringSSL 和 OpenSSL 的一致性测试 ✅ QUIC 原生 - 专为 QUIC 集成设计,无传统记录层 ✅ 测试充分 - 551 个单元测试 + RFC 测试向量 + 449 个一致性测试

快速开始

root@kitploit:~
# Build and test everything
make

# Or manually
zig build
zig build test

要求

  • Zig 0.16.0 或兼容版本
  • OpenSSL 开发库(可选,用于一致性测试)

构建

该项目同时使用 Makefile 和 build.zig 以提供灵活性:

使用 Make(推荐)

root@kitploit:~
# 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

使用 zig build

root@kitploit:~
# 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

测试结果

root@kitploit:~
Build Summary: All steps succeeded; 1000 tests passed ✅

全面的测试覆盖:

  • 551 个单元测试 - 包含 RFC 子节引用的模块级测试(共 553 个,跳过 2 个)
  • 449 个一致性测试 - BoringSSL 和 OpenSSL 等价性测试
    • 密码学操作(HKDF、AEAD、签名)
    • X.509 证书验证和链构建
    • 高级 X.509 扩展(OCSP、CRL、AIA、名称约束、策略)
    • TLS 1.3 协议合规性(扩展、握手流程)
    • 性能基准(延迟 <2ms,内存 <100KB)
    • 安全测试(模糊测试、输入验证)
    • 后量子算法就绪(仅解析)

总计:1000 个测试,确保 RFC 合规性、密码学等价性和生产就绪性

项目结构

root@kitploit:~
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

使用示例

root@kitploit:~
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);
}

架构

设计原则

  1. 互操作性优先 - 自动检测并支持标准 TLS 1.3 格式,以便与真实世界的 QUIC 实现(quic-go、quinn、msquic)兼容
  2. RFC 驱动开发 - 每个实现块都引用了相关 RFC 章节
  3. 零外部依赖 - 仅使用 Zig stdlib 原语

关键组件

  • 密钥调度 - 使用 std.crypto.kdf.hkdf 的 HKDF 密钥派生
  • AEAD 保护 - AES-128-GCM、AES-256-GCM、ChaCha20-Poly1305
  • 证书验证 - 包含 SNI 匹配和有效性检查的 X.509 解析
  • 签名验证 - ECDSA(P-256、P-384)、RSA-PSS、Ed25519

一致性测试

该项目包含全面的一致性测试,以确保与行业标准 TLS 实现的兼容性:

BoringSSL 一致性

  • HKDF-Extract 和 HKDF-Expand 等价性
  • QUIC 初始秘密派生(RFC 9001)
  • AEAD 密码兼容性
  • 告警代码映射

OpenSSL 3.x 一致性

  • EVP API 兼容性
  • 密码套件可用性
  • 哈希函数等价性
  • 密钥更新流程

运行一致性测试:

root@kitploit:~
# Install OpenSSL development libraries first
make install-deps  # Auto-detects your OS

# Run conformance tests
make test-conformance

可观测性

ztls 附带一个可选的 OpenTelemetry 接口。当设置 -Dwith_otel=true 构建标志时,库会在每次 TLS 握手时精确发出一个跨度(跨度名称:"TLS handshake"),并在完成时附加以下语义约定属性:

  • tls.role -- "client" 或 "server"
  • tls.protocol.version -- "1.3"(一直为 ztls)
  • tls.cipher_suite -- 协商的密码(例如 TLS_AES_128_GCM_SHA256)
  • network.protocol.name -- "tls"
root@kitploit:~
# 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

该接口通过惰性依赖进行门控,因此只有在启用该标志时才会拉取 otel 包。想要安装 TracerProvider 的应用程序入口代码应调用 ztls.observability_init.Otel.init 然后调用 installGlobals();完整的宿主应用程序引导请参阅上游 otel 集成配方(otel/docs/integration/RECIPE.md)。

文档

  • BUILD_SYSTEM.md - 详细构建系统文档
  • CONFORMANCE_TESTS.md - BoringSSL/OpenSSL 兼容性测试文档
  • CLAUDE.md - 项目概览与 AI 辅助上下文
  • RFC 引用 - 所有代码均包含 RFC 章节引用

开发

root@kitploit:~
# Quick development iteration
make dev

# Format code
make fmt
# or
zig fmt src/ tests/

# Check syntax
make check

# Clean build
make clean build

实现状态

✅ 已完成

  • TLS 1.3 握手状态机
  • HKDF 密钥调度(RFC 8446 §7,RFC 9001 §5.1)
  • AEAD 记录保护(AES-GCM、ChaCha20-Poly1305)
  • X.509 证书解析与验证
  • 签名验证(ECDSA、RSA-PSS、Ed25519)
  • 告警协议
  • 0-RTT 防重放
  • QUIC 集成接口

🚧 未来工作

  • HKDF-Expand-Label 包装器(在测试向量中跟踪)
  • OCSP 回应与 SCT 支持
  • 完整证书链验证
  • 额外密码套件(AES-256-GCM-SHA384、AES-CCM)
  • 握手后认证
  • 当 stdlib X.509 稳定后迁移至其实现

贡献

添加特性时:

  1. 在源文件中包含单元测试
  2. 为所有协议逻辑添加 RFC 章节引用
  3. 如果 RFC 合规性受到影响,更新集成测试
  4. 为密码学操作添加一致性测试
  5. 更新文档

许可证

Apache-2.0 许可证 - 详见 LICENSE。

参考文献

  • RFC 8446 - TLS 1.3
  • RFC 9001 - QUIC 传输层 TLS
  • RFC 9369 - QUIC 版本 2
  • RFC 5280 - X.509 证书
  • RFC 7301 - ALPN

使用 Zig 0.16.0 构建 | TLS 1.3 | QUIC 原生 | 符合 RFC

下载工具