wycheproof
它能做什么
这项技能用一组公开的测试向量检验加密代码,其中包括已知攻击和棘手的输入。适合想确认库能正确处理这些情况的开发者和审计人员。
适用场景
- ✓你想用 AES、RSA、ECDSA 或 ECDH 的标准测试用例检验代码时。
- ✓你需要用已知攻击和边界情况检验某个库时。
- ✓某个 Wycheproof 测试失败,你需要理解原因时。
技能链接
https://github.com/trailofbits/skills/blob/main/plugins/testing-handbook-skills/skills/wycheproof/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我想用 Wycheproof 测试向量检验我们的 ECDSA 实现,看看哪些情况失败。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会加载测试向量,按密钥长度等属性分组,并把每个结果与其预期的通过或失败标记进行比对。失败项会连同导致失败的输入一起列出。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Wycheproof
Wycheproof is an extensive collection of test vectors designed to verify the correctness of cryptographic implementations and test against known attacks. Originally developed by Google, it is now a community-managed project where contributors can add test vectors for specific cryptographic constructions.
Background
Key Concepts
| Concept | Description |
|---|---|
| Test vector | Input/output pair for validating crypto implementation correctness |
| Test group | Collection of test vectors sharing attributes (key size, IV size, curve) |
| Result flag | Indicates if test should pass (valid), fail (invalid), or is acceptable |
| Edge case testing | Testing for known vulnerabilities and attack patterns |
Why This Matters
Cryptographic implementations are notoriously difficult to get right. Even small bugs can:
- Expose private keys
- Allow signature forgery
- Enable message decryption
- Create consensus problems when different implementations accept/reject the same inputs
Wycheproof has found vulnerabilities in major libraries including OpenJDK's SHA1withDSA, Bouncy Castle's ECDHC, and the elliptic npm package.
When to Use
Apply Wycheproof when:
- Testing cryptographic implementations (AES-GCM, ECDSA, ECDH, RSA, etc.)
- Validating that crypto code handles edge cases correctly
- Verifying implementations against known attack vectors
- Setting up CI/CD for cryptographic libraries
- Auditing third-party crypto code for correctness
Consider alternatives when:
- Testing for timing side-channels (use constant-time testing tools instead)
- Finding new unknown bugs (use fuzzing instead)
- Testing custom/experimental cryptographic algorithms (Wycheproof only covers established algorithms)
Quick Reference
| Scenario | Recommended Approach | Notes |
|---|---|---|
| AES-GCM implementation | Use aes_gcm_test.json |
316 test vectors across 44 test groups |
| ECDSA verification | Use ecdsa_*_test.json for specific curves |
Tests signature malleability, DER encoding |
| ECDH key exchange | Use ecdh_*_test.json |
Tests invalid curve attacks |
| RSA signatures | Use rsa_*_test.json |
Tests padding oracle attacks |
| ChaCha20-Poly1305 | Use chacha20_poly1305_test.json |
Tests AEAD implementation |
Testing Workflow
Phase 1: Setup Phase 2: Parse Test Vectors
┌─────────────────┐ ┌─────────────────┐
│ Add Wycheproof │ → │ Load JSON file │
│ as submodule │ │ Filter by params│
└─────────────────┘ └─────────────────┘
↓ ↓
Phase 4: CI Integration Phase 3: Write Harness
┌─────────────────┐ ┌─────────────────┐
│ Auto-update │ ← │ Test valid & │
│ test vectors │ │ invalid cases │
└─────────────────┘ └─────────────────┘
Repository Structure
The Wycheproof repository is organized as follows:
┣ 📜 README.md : Project overview
┣ 📂 doc : Documentation
┣ 📂 java : Java JCE interface testing harness
┣ 📂 javascript : JavaScript testing harness
┣ 📂 schemas : Test vector schemas
┣ 📂 testvectors : Test vectors
┗ 📂 testvectors_v1 : Updated test vectors (more detailed)
The essential folders are testvectors and testvectors_v1. While both contain similar files, testvectors_v1 includes more detailed information and is recommended for new integrations.
Supported Algorithms
Wycheproof provides test vectors for a wide range of cryptographic algorithms:
| Category | Algorithms |
|---|---|
| Symmetric Encryption | AES-GCM, AES-EAX, ChaCha20-Poly1305 |
| Signatures | ECDSA, EdDSA, RSA-PSS, RSA-PKCS1 |
| Key Exchange | ECDH, X25519, X448 |
| Hashing | HMAC, HKDF |
| Curves | secp256k1, secp256r1, secp384r1, secp521r1, ed25519, ed448 |
Test File Structure
Each JSON test file tests a specific cryptographic construction. All test files share common attributes:
"algorithm" : The name of the algorithm tested
"schema" : The JSON schema (found in schemas folder)
"generatorVersion" : The version number
"numberOfTests" : The total number of test vectors in this file
"header" : Detailed description of test vectors
"notes" : In-depth explanation of flags in test vectors
"testGroups" : Array of one or multiple test groups
Test Groups
Te
常见问题
什么是测试向量?
它是一组输入和输出值,正确的实现必须以已知的方式处理它们。
涵盖哪些算法?
该技能提到了 AES、RSA、ECDSA、ECDH 等。
我该如何读懂失败结果?
该技能讲解了如何解读失败结果,以便你弄清出了什么问题。
详情
作者的原始描述
Validates cryptographic implementations against Project Wycheproof's test vectors, which encode known attacks and edge cases across AES, RSA, ECDSA, ECDH, and more. Covers loading test vectors, mapping result flags onto pass and fail expectations, and reading a failure. Use when testing a crypto implementation against known attacks, checking a library against standard test vectors, or investigating why two implementations disagree on the same input.
repo: trailofbits/skills
热度
- GitHub 星标
- 8.0k
- 排名
- #12724
- 许可证
- CC-BY-SA-4.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
audit-context-building
8.0k帮你的智能体在安全审查之前熟悉一个陌生的代码库,梳理每个函数的假设、保证和依赖关系。
algorand-vulnerability-scanner
8.0k帮你的智能体扫描 TEAL 或 PyTeal 编写的 Algorand 智能合约,检查 11 类常见安全问题,如重新密钥攻击和未校验费用。
audit-prep-assistant
8.0k帮你的智能体为外部安全审查做好代码准备,包括静态分析、测试覆盖、死代码清理和清晰的文档。
cairo-vulnerability-scanner
8.0k帮你的智能体扫描 StarkNet 上的 Cairo 智能合约,检查 6 类严重问题,包括算术溢出、有风险的跨层消息和签名重放。