示例
quinn-proto 0.11.16
已验证示例 — cargo quinn-proto 0.11.16. contract 在 rust 1 · linux alpine/x64 · docker 上运行并通过: VarInt::from_u64 and VarInt::try_from enforce the 2^62 bound with…
sha256:8196b589ca281d71d8ed3bde4c54f18b327c74a0544b880b5de8555636c127e2
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux x64 rust cargo 1
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-11-23 |
案例
HOW- 目标
- verify pkg:cargo/quinn-proto@0.11.16
- 创建时间
- 2026-11-23T19:11:40Z
契约
- VarInt::from_u64 and VarInt::try_from enforce the 2^62 bound with VarIntBoundsExceeded while exposing MAX_SIZE = 8, and StreamId encodes and round-trips Side, Dir, and index through VarInt
- EndpointConfig::max_udp_payload_size rejects values below 1200 with ConfigError::OutOfBounds and accepts 1452, and ClientConfig::with_root_certificates rejects an empty RootCertStore with VerifierBuilderError::NoRootAnchors
- Endpoint::connect rejects port 0 with ConnectError::InvalidRemoteAddress, empty server name with ConnectError::InvalidServerName, and unknown QUIC version with ConnectError::UnsupportedVersion while keeping open_connections at 0
- Endpoint::connect with QuicClientConfig initiates a handshaking client Connection whose poll_transmit emits an initial QUIC datagram of at least 1200 bytes with CRYPTO frame stats, and advancing poll_timeout/handle_timeout emits ConnectionError::TimedOut and a drained EndpointEvent returning open_connections to 0
- HashedConnectionIdGenerator validates generated 8-byte CIDs and rejects tampered CIDs, RandomConnectionIdGenerator generates fixed-length CIDs with configured lifetime, and BloomTokenLog rejects replayed nonces and zero lifetimes with TokenReuseError
文件
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- tests/contract.rs
源代码
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "bumpalo"
version = "3.20.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db"
[[package]]
name = "bytes"
version = "1.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "776dfebd015e2d8732c684a2c71003674ccb49457b539b9e82151ba38e96dd7c"
[[package]]
name = "cc"
version = "1.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02f0e023adb368345ce0ca6cdfc0f24a06554468d0e8503e14a0841de79bfa69"
dependencies = [
"find-msvc-tools",
"shlex",
]
[[package]]
name = "cfg-if"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
[[package]]
name = "chacha20"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
dependencies = [
"cfg-if",
"cpufeatures",
"rand_core",
]
[[package]]
name = "cpufeatures"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"
dependencies = [
"libc",
]
[[package]]
name = "fastbloom"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef975e30683b2d965054bb0a836f8973857c4ebf6acf274fe46617cd285060d8"
dependencies = [
"foldhash",
"libm",
"portable-atomic",
"siphasher",
]
[[package]]
name = "find-msvc-tools"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
[[package]]
name = "foldhash"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
[[package]]
name = "futures-core"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
[[package]]
name = "futures-task"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
[[package]]
name = "futures-util"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
dependencies = [
"futures-core",
"futures-task",
"pin-project-lite",
"slab",
]
[[package]]
name = "getrandom"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"wasi",
"wasm-bindgen",
]
[[package]]
name = "getrandom"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"r-efi",
"rand_core",
"wasm-bindgen",
]
[[package]]
name = "js-sys"
version = "0.3.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a"
dependencies = [
"cfg-if",
"futures-util",
"wasm-bindgen",
]
[[package]]
name = "libc"
version = "0.2.191"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
[[package]]
name = "libm"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
[[package]]
name = "log"
version = "0.4.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
[[package]]
name = "lru-slab"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f"
[[package]]
name = "once_cell"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "pin-project-lite"
version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c938015719552d665fd0553b90d96cd7ff58e83e4c061ca99e6bb78865a72752"
[[package]]
name = "portable-atomic"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quinn-proto"
version = "0.11.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f4bfc015262b9df63c8845072ce59068853ff5872180c2ce2f13038b970e560"
dependencies = [
"bytes",
"fastbloom",
"getrandom 0.4.3",
"lru-slab",
"rand",
"rand_pcg",
"ring",
"rustc-hash",
"rustls",
"rustls-pki-types",
"slab",
"thiserror",
"tinyvec",
"tracing",
"web-time",
]
[[package]]
name = "quinn-proto-contract"
version = "0.1.0"
dependencies = [
"quinn-proto",
]
[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
"proc-macro2",
]
[[package]]
name = "r-efi"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
[[package]]
name = "rand"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11"
dependencies = [
"chacha20",
"getrandom 0.4.3",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
[[package]]
name = "rand_pcg"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb95882a1e14462c69aea9984bb261293ccfe6022ef8de0eda18bd5afb0052df"
dependencies = [
"rand_core",
]
[[package]]
name = "ring"
version = "0.17.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
dependencies = [
"cc",
"cfg-if",
"getrandom 0.2.17",
"libc",
"untrusted",
"windows-sys",
]
[[package]]
name = "rustc-hash"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
[[package]]
name = "rustls"
version = "0.23.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf"
dependencies = [
"once_cell",
"ring",
"rustls-pki-types",
"rustls-webpki",
"subtle",
"zeroize",
]
[[package]]
name = "rustls-pki-types"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb"
dependencies = [
"web-time",
"zeroize",
]
[[package]]
name = "rustls-webpki"
version = "0.103.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5"
dependencies = [
"ring",
"rustls-pki-types",
"untrusted",
]
[[package]]
name = "rustversion"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
[[package]]
name = "shlex"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
[[package]]
name = "siphasher"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256"
[[package]]
name = "slab"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
[[package]]
name = "subtle"
version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "syn"
version = "3.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "thiserror"
version = "2.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tinyvec"
version = "1.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee"
[[package]]
name = "tracing"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
dependencies = [
"log",
"pin-project-lite",
"tracing-core",
]
[[package]]
name = "tracing-core"
version = "0.1.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
dependencies = [
"once_cell",
]
[[package]]
name = "unicode-ident"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
[[package]]
name = "untrusted"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "wasi"
version = "0.11.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]]
name = "wasm-bindgen"
version = "0.2.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c"
dependencies = [
"cfg-if",
"rustversion",
"wasm-bindgen-macro",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a"
dependencies = [
"bumpalo",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.130"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e"
dependencies = [
"unicode-ident",
]
[[package]]
name = "web-time"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "zeroize"
version = "1.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85ccff8a4805aba1eaa4cd4afcd49f7557dd2cf5fd79ffc37f8959466effc5aa"
[package]
name = "quinn-proto-contract"
version = "0.1.0"
edition = "2021"
[dependencies]
quinn-proto = { version = "=0.11.16", features = ["rustls"] }
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:cargo/quinn-proto@0.11.16
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/quinn-proto@0.11.16
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:ba22017fb743e047da546ab5852c4a41bd7c29ee56692b0d83f44f2b6227914d","contract":["VarInt::from_u64 and VarInt::try_from enforce the 2^62 bound with VarIntBoundsExceeded while exposing MAX_SIZE = 8, and StreamId encodes and round-trips Side, Dir, and index through VarInt","EndpointConfig::max_udp_payload_size rejects values below 1200 with ConfigError::OutOfBounds and accepts 1452, and ClientConfig::with_root_certificates rejects an empty RootCertStore with VerifierBuilderError::NoRootAnchors","Endpoint::connect rejects port 0 with ConnectError::InvalidRemoteAddress, empty server name with ConnectError::InvalidServerName, and unknown QUIC version with ConnectError::UnsupportedVersion while keeping open_connections at 0","Endpoint::connect with QuicClientConfig initiates a handshaking client Connection whose poll_transmit emits an initial QUIC datagram of at least 1200 bytes with CRYPTO frame stats, and advancing poll_timeout/handle_timeout emits ConnectionError::TimedOut and a drained EndpointEvent returning open_connections to 0","HashedConnectionIdGenerator validates generated 8-byte CIDs and rejects tampered CIDs, RandomConnectionIdGenerator generates fixed-length CIDs with configured lifetime, and BloomTokenLog rejects replayed nonces and zero lifetimes with TokenReuseError"],"goal":"verify pkg:cargo/quinn-proto@0.11.16","kind":"HOW","packages":["pkg:cargo/quinn-proto@0.11.16"],"schemaVersion":1},"contractCommand":["cargo","test","--offline"],"environment":{"arch":"x64","compiler":"rustc","compilerVersion":"1.97.1","ecosystem":"cargo","language":"rust","os":"linux","packageManager":"cargo","packageManagerVersion":"1.97.1","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/quinn-proto@0.11.16"],"schemaVersion":1,"subject":"pkg:cargo/quinn-proto@0.11.16","verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/quinn-proto@0.11.16",
"kind": "HOW",
"packages": [
"pkg:cargo/quinn-proto@0.11.16"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
use std::sync::Arc;
use std::time::Duration;
use quinn_proto::crypto::rustls::QuicClientConfig;
use quinn_proto::rustls::client::danger::{
HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier,
};
use quinn_proto::rustls::pki_types::{CertificateDer, ServerName, UnixTime};
use quinn_proto::rustls::{DigitallySignedStruct, Error as TlsError, SignatureScheme};
use quinn_proto::{
ClientConfig, Connection, ConnectionError, Endpoint, EndpointEvent, Event, IdleTimeout,
TransportConfig, VarInt,
};
#[derive(Debug)]
struct AcceptAnyCertVerifier;
impl ServerCertVerifier for AcceptAnyCertVerifier {
fn verify_server_cert(
&self,
_end_entity: &CertificateDer<'_>,
_intermediates: &[CertificateDer<'_>],
_server_name: &ServerName<'_>,
_ocsp_response: &[u8],
_now: UnixTime,
) -> Result<ServerCertVerified, TlsError> {
Ok(ServerCertVerified::assertion())
}
fn verify_tls12_signature(
&self,
_message: &[u8],
_cert: &CertificateDer<'_>,
_dss: &DigitallySignedStruct,
) -> Result<HandshakeSignatureValid, TlsError> {
Ok(HandshakeSignatureValid::assertion())
}
fn verify_tls13_signature(
&self,
_message: &[u8],
_cert: &CertificateDer<'_>,
_dss: &DigitallySignedStruct,
) -> Result<HandshakeSignatureValid, TlsError> {
Ok(HandshakeSignatureValid::assertion())
}
fn supported_verify_schemes(&self) -> Vec<SignatureScheme> {
vec![
SignatureScheme::ECDSA_NISTP256_SHA256,
SignatureScheme::ED25519,
SignatureScheme::RSA_PSS_SHA256,
]
}
}
pub fn make_client_config(idle_timeout: Duration) -> ClientConfig {
let provider = Arc::new(quinn_proto::rustls::crypto::ring::default_provider());
let tls = quinn_proto::rustls::ClientConfig::builder_with_provider(provider)
.with_protocol_versions(&[&quinn_proto::rustls::version::TLS13])
.expect("TLS 1.3 protocol version must be supported")
.dangerous()
.with_custom_certificate_verifier(Arc::new(AcceptAnyCertVerifier))
.with_no_client_auth();
let quic_crypto = QuicClientConfig::try_from(tls).expect("valid QUIC client TLS config");
let mut transport = TransportConfig::default();
let idle = IdleTimeout::try_from(idle_timeout).expect("valid idle timeout");
transport
.max_idle_timeout(Some(idle))
.max_concurrent_bidi_streams(VarInt::from_u32(8))
.max_concurrent_uni_streams(VarInt::from_u32(4))
.initial_mtu(1200);
let mut cfg = ClientConfig::new(Arc::new(quic_crypto));
cfg.transport_config(Arc::new(transport));
cfg
}
pub fn advance_until_timeout(
endpoint: &mut Endpoint,
handle: quinn_proto::ConnectionHandle,
conn: &mut Connection,
) -> (Option<ConnectionError>, Option<EndpointEvent>) {
let mut lost_reason = None;
let mut drained = None;
let mut transmit_buf = Vec::new();
for _ in 0..64 {
let Some(deadline) = conn.poll_timeout() else {
break;
};
conn.handle_timeout(deadline);
transmit_buf.clear();
let _ = conn.poll_transmit(deadline, 1, &mut transmit_buf);
while let Some(ev) = conn.poll() {
if let Event::ConnectionLost { reason } = ev {
lost_reason = Some(reason);
}
}
while let Some(ep_ev) = conn.poll_endpoint_events() {
if ep_ev.is_drained() {
drained = Some(ep_ev);
} else if let Some(conn_ev) = endpoint.handle_event(handle, ep_ev) {
conn.handle_event(conn_ev);
}
}
if lost_reason.is_some() && drained.is_some() {
break;
}
}
(lost_reason, drained)
}
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::sync::Arc;
use std::time::{Duration, Instant, SystemTime};
use quinn_proto::rustls::client::VerifierBuilderError;
use quinn_proto::rustls::RootCertStore;
use quinn_proto::{
BloomTokenLog, ClientConfig, ConfigError, ConnectError, ConnectionError, ConnectionId,
ConnectionIdGenerator, Dir, Endpoint, EndpointConfig, HashedConnectionIdGenerator,
RandomConnectionIdGenerator, Side, StreamId, TokenLog, TokenReuseError, VarInt,
VarIntBoundsExceeded,
};
use quinn_proto_contract::{advance_until_timeout, make_client_config};
#[test]
fn varint_and_stream_id_encoding() {
assert_eq!(VarInt::MAX_SIZE, 8);
assert_eq!(VarInt::from_u32(42).into_inner(), 42);
assert_eq!(VarInt::from(63u8).into_inner(), 63);
assert_eq!(VarInt::from_u64(VarInt::MAX.into_inner()), Ok(VarInt::MAX));
assert_eq!(VarInt::from_u64(1u64 << 62), Err(VarIntBoundsExceeded));
assert_eq!(VarInt::try_from(u128::MAX), Err(VarIntBoundsExceeded));
let client_uni = StreamId::new(Side::Client, Dir::Uni, 5);
assert_eq!(client_uni.initiator(), Side::Client);
assert_eq!(client_uni.dir(), Dir::Uni);
assert_eq!(client_uni.index(), 5);
assert_eq!(u64::from(client_uni), 22);
assert_eq!(StreamId::from(VarInt::from(client_uni)), client_uni);
let server_bi = StreamId::new(Side::Server, Dir::Bi, 2);
assert_eq!(server_bi.initiator(), Side::Server);
assert_eq!(server_bi.dir(), Dir::Bi);
assert_eq!(server_bi.index(), 2);
assert_eq!(u64::from(server_bi), 9);
}
#[test]
fn config_validation_and_connect_errors() {
let mut ep_cfg = EndpointConfig::default();
assert_eq!(
ep_cfg.max_udp_payload_size(1199).unwrap_err(),
ConfigError::OutOfBounds
);
ep_cfg.max_udp_payload_size(1452).unwrap();
assert_eq!(ep_cfg.get_max_udp_payload_size(), 1452);
ep_cfg.rng_seed(Some([7u8; 32]));
assert!(matches!(
ClientConfig::with_root_certificates(Arc::new(RootCertStore::empty())),
Err(VerifierBuilderError::NoRootAnchors)
));
let client_cfg = make_client_config(Duration::from_secs(3));
let mut endpoint = Endpoint::new(Arc::new(ep_cfg), None, false, None);
let now = Instant::now();
let port_zero = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 0);
assert!(matches!(
endpoint.connect(now, client_cfg.clone(), port_zero, "localhost"),
Err(ConnectError::InvalidRemoteAddress(_))
));
let valid_remote = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 4433);
assert!(matches!(
endpoint.connect(now, client_cfg.clone(), valid_remote, ""),
Err(ConnectError::InvalidServerName(_))
));
let mut bad_ver = client_cfg;
bad_ver.version(0xdead_beef);
assert!(matches!(
endpoint.connect(now, bad_ver, valid_remote, "localhost"),
Err(ConnectError::UnsupportedVersion)
));
assert_eq!(endpoint.open_connections(), 0);
}
#[test]
fn client_initial_transmit_and_timeout_drain() {
let mut ep_cfg = EndpointConfig::default();
ep_cfg.rng_seed(Some([9u8; 32]));
let mut endpoint = Endpoint::new(Arc::new(ep_cfg), None, false, None);
let client_cfg = make_client_config(Duration::from_secs(4));
let remote = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 4433);
let now = Instant::now();
let (ch, mut conn) = endpoint
.connect(now, client_cfg, remote, "localhost")
.expect("client handshake initiation");
assert_eq!(endpoint.open_connections(), 1);
assert_eq!(conn.side(), Side::Client);
assert_eq!(conn.remote_address(), remote);
assert!(conn.is_handshaking());
assert!(!conn.is_closed());
let mut packet = Vec::new();
let transmit = conn
.poll_transmit(now, 1, &mut packet)
.expect("initial QUIC datagram");
assert_eq!(transmit.destination, remote);
assert_eq!(transmit.size, packet.len());
assert!(transmit.size >= 1200);
let stats = conn.stats();
assert_eq!(stats.udp_tx.datagrams, 1);
assert!(stats.udp_tx.bytes >= 1200);
assert!(stats.frame_tx.crypto >= 1);
let (lost_reason, drained_ev) = advance_until_timeout(&mut endpoint, ch, &mut conn);
assert_eq!(lost_reason, Some(ConnectionError::TimedOut));
assert!(conn.is_closed());
assert!(conn.is_drained());
let drained = drained_ev.expect("drained endpoint event");
assert!(endpoint.handle_event(ch, drained).is_none());
assert_eq!(endpoint.open_connections(), 0);
}
#[test]
fn cid_generators_and_bloom_token_log() {
let mut hashed = HashedConnectionIdGenerator::from_key(0xfeed_face_cafe_beef);
assert_eq!(hashed.cid_len(), 8);
let cid = hashed.generate_cid();
assert_eq!(cid.len(), 8);
assert!(hashed.validate(&cid).is_ok());
let mut tampered = [0u8; 8];
tampered.copy_from_slice(&cid);
tampered[0] ^= 0x55;
assert!(hashed.validate(&ConnectionId::new(&tampered)).is_err());
let mut rng_gen = RandomConnectionIdGenerator::new(16);
rng_gen.set_lifetime(Duration::from_secs(120));
assert_eq!(rng_gen.cid_len(), 16);
assert_eq!(rng_gen.cid_lifetime(), Some(Duration::from_secs(120)));
assert_eq!(rng_gen.generate_cid().len(), 16);
let token_log = BloomTokenLog::new_expected_items(2048, 64);
let issued = SystemTime::UNIX_EPOCH + Duration::from_secs(1_750_000_000);
let ttl = Duration::from_secs(300);
assert!(token_log.check_and_insert(7, issued, ttl).is_ok());
assert!(matches!(
token_log.check_and_insert(7, issued, ttl),
Err(TokenReuseError)
));
assert!(token_log.check_and_insert(8, issued, ttl).is_ok());
assert!(matches!(
token_log.check_and_insert(9, issued, Duration::ZERO),
Err(TokenReuseError)
));
}
原始种子者
匿名