|
1 | | -## CipherScope |
| 1 | +# CipherScope |
2 | 2 |
|
3 | 3 | <div align="center"> |
4 | 4 | <img src="cipherscope.png" alt="CipherScope Logo" width="350" height="350"> |
5 | 5 | </div> |
6 | 6 |
|
7 | | -**Cryptographic Bill of Materials (MV-CBOM) Generator** for Post-Quantum Cryptography (PQC) readiness assessment. |
| 7 | +Fast cryptographic inventory generator. Scans codebases to identify cryptographic algorithms and assess quantum resistance. |
8 | 8 |
|
9 | | -Analyzes codebases across 11 programming languages (Go, Java, C, C++, Rust, Python, PHP, Swift, Objective-C, Kotlin, Erlang) and generates machine-readable JSON inventories of cryptographic assets with NIST quantum security levels. |
10 | | - |
11 | | -### Install & Run |
| 9 | +## Quick Start |
12 | 10 |
|
13 | 11 | ```bash |
14 | 12 | cargo build --release |
15 | | - |
16 | | -# Generate MV-CBOM for current directory |
17 | | -./target/release/cipherscope . |
18 | | - |
19 | | -# Generate MV-CBOMs recursively for all discovered projects |
20 | | -./target/release/cipherscope . --recursive |
| 13 | +./target/release/cipherscope /path/to/scan |
21 | 14 | ``` |
22 | 15 |
|
23 | | -Key flags: |
24 | | -- `--recursive`: generate MV-CBOMs recursively for all discovered projects |
25 | | -- `--threads N`: set thread pool size |
26 | | -- `--max-file-size MB`: skip large files (default 2) |
27 | | -- `--patterns PATH`: specify patterns file (default: `patterns.toml`) |
28 | | -- `--progress`: show progress bar during scanning |
29 | | -- `--print-config`: print loaded `patterns.toml` |
30 | | - |
31 | | -### Output |
32 | | - |
33 | | -**MV-CBOM JSON files** written to each project directory for comprehensive Post-Quantum Cryptography (PQC) readiness assessment. |
34 | | - |
35 | | -#### MV-CBOM (Minimal Viable Cryptographic Bill of Materials) |
36 | | - |
37 | | -CipherScope generates a comprehensive cryptographic inventory in JSON format that follows the MV-CBOM specification. This enables: |
| 16 | +## What It Does |
38 | 17 |
|
39 | | -- **Post-Quantum Cryptography (PQC) Risk Assessment**: Identifies algorithms vulnerable to quantum attacks (NIST Quantum Security Level 0) |
40 | | -- **Crypto-Agility Planning**: Provides detailed algorithm parameters and usage patterns |
41 | | -- **Supply Chain Security**: Maps dependencies between components and cryptographic assets |
| 18 | +- **Detects** cryptographic usage across 11 languages |
| 19 | +- **Identifies** many cryptographic algorithms (AES, SHA, RSA, ECDSA, ChaCha20, etc.) |
| 20 | +- **Outputs** JSON inventory with NIST quantum security levels |
| 21 | +- **Runs fast** - GiB/s throughput with parallel scanning |
42 | 22 |
|
43 | | -The MV-CBOM includes: |
44 | | -- **Cryptographic Assets**: Algorithms, certificates, and related crypto material with NIST security levels |
45 | | -- **Dependency Relationships**: Distinguishes between "uses" (actively called) vs "implements" (available but unused) |
46 | | -- **Parameter Extraction**: Key sizes, curves, and other algorithm-specific parameters |
47 | | -- **Recursive Project Discovery**: Automatically discovers and analyzes nested projects (BUCK, Bazel, Maven modules, etc.) |
| 23 | +## Example Output |
48 | 24 |
|
49 | | -Example MV-CBOM snippet: |
50 | 25 | ```json |
51 | 26 | { |
52 | 27 | "bomFormat": "MV-CBOM", |
53 | 28 | "specVersion": "1.0", |
54 | | - "cryptoAssets": [ |
55 | | - { |
56 | | - "bom-ref": "uuid-1234", |
57 | | - "assetType": "algorithm", |
58 | | - "name": "RSA", |
59 | | - "assetProperties": { |
60 | | - "primitive": "signature", |
61 | | - "parameterSet": {"keySize": 2048}, |
62 | | - "nistQuantumSecurityLevel": 0 |
63 | | - } |
| 29 | + "cryptoAssets": [{ |
| 30 | + "name": "RSA", |
| 31 | + "assetProperties": { |
| 32 | + "primitive": "signature", |
| 33 | + "parameterSet": {"keySize": 2048}, |
| 34 | + "nistQuantumSecurityLevel": 0 |
64 | 35 | } |
65 | | - ], |
66 | | - "dependencies": [ |
67 | | - { |
68 | | - "ref": "main-component", |
69 | | - "dependsOn": ["uuid-1234"], |
70 | | - "dependencyType": "uses" |
71 | | - } |
72 | | - ] |
| 36 | + }] |
73 | 37 | } |
74 | 38 | ``` |
75 | 39 |
|
76 | | -### Configuration |
77 | | - |
78 | | -Algorithm and library detection patterns are defined in `patterns.toml`. The schema supports: |
79 | | -- **Library Detection**: `include`/`import`/`namespace`/`apis` patterns per language |
80 | | -- **Algorithm Definitions**: Each library defines supported algorithms with NIST quantum security levels |
81 | | -- **Parameter Extraction**: Patterns for extracting key sizes, curves, and algorithm parameters |
82 | | - |
83 | | -**Supported Languages**: C, C++, Java, Go, Rust, Python, PHP, Swift, Objective-C, Kotlin, Erlang |
84 | | - |
85 | | -#### High-Performance Architecture |
86 | | - |
87 | | -- **Parallel Processing**: Producer-consumer model with `rayon` thread pools |
88 | | -- **Smart Filtering**: Respects `.gitignore`, early language detection, Aho-Corasick prefiltering |
89 | | -- **Scalable**: 4+ GiB/s throughput, linear scaling with CPU cores |
90 | | - |
91 | | -### Architecture |
92 | | - |
93 | | -**Modular MV-CBOM Generation Pipeline**: |
94 | | -1. **Project Discovery**: Recursive scanning for project files (BUILD, pom.xml, Cargo.toml, etc.) |
95 | | -2. **Static Analysis**: Pattern-driven cryptographic library detection |
96 | | -3. **Algorithm Detection**: Extract algorithms and parameters using `patterns.toml` definitions |
97 | | -4. **Certificate Parsing**: X.509 certificate analysis with signature algorithms |
98 | | -5. **Dependency Analysis**: "Uses" vs "implements" relationship detection |
99 | | -6. **CBOM Generation**: Standards-compliant JSON with NIST quantum security levels |
100 | | - |
101 | | -**Key Innovation**: Algorithm detection moved from hardcoded Rust to configurable `patterns.toml` - new algorithms added by editing patterns, not code. |
102 | | - |
103 | | -### Tests & Benchmarks |
104 | | - |
105 | | -Run unit tests and integration tests (fixtures): |
106 | | - |
107 | | -```bash |
108 | | -cargo test |
109 | | -``` |
110 | | - |
111 | | -#### Comprehensive Fixtures for MV-CBOM Testing |
112 | | - |
113 | | -The `fixtures/` directory contains rich, realistic examples for testing MV-CBOM generation across multiple languages and build systems: |
| 40 | +## Options |
114 | 41 |
|
115 | | -**Rust Fixtures:** |
116 | | -- **`rust/rsa-vulnerable`**: RSA 2048-bit usage (PQC vulnerable, "uses" relationship) |
117 | | -- **`rust/aes-gcm-safe`**: Quantum-safe algorithms (AES-256-GCM, ChaCha20Poly1305, SHA-3, BLAKE3) |
118 | | -- **`rust/implements-vs-uses`**: SHA2 "uses" vs P256 "implements" distinction |
119 | | -- **`rust/mixed-crypto`**: Complex multi-algorithm project (RSA, AES, SHA2, Ed25519, Ring) |
| 42 | +- `--patterns PATH` - Custom patterns file (default: `patterns.toml`) |
| 43 | +- `--progress` - Show progress bar |
| 44 | +- `--deterministic` - Reproducible output for testing |
120 | 45 |
|
121 | | -**Java Fixtures:** |
122 | | -- **`java/maven-bouncycastle`**: Maven project with BouncyCastle RSA/ECDSA |
123 | | -- **`java/bazel-tink`**: Bazel project with Google Tink and BouncyCastle |
124 | | -- **`java/jca-standard`**: Standard JCA/JCE without external dependencies |
| 46 | +## Languages Supported |
125 | 47 |
|
126 | | -**C/C++ Fixtures:** |
127 | | -- **`c/openssl-mixed`**: OpenSSL + libsodium with RSA, ChaCha20Poly1305, AES |
128 | | -- **`c/libsodium-modern`**: Modern libsodium with quantum-safe and vulnerable algorithms |
129 | | -- **`c/makefile-crypto`**: Basic OpenSSL usage with Makefile dependency detection |
130 | | -- **`cpp/botan-modern`**: Botan library with RSA, AES-GCM, SHA-3, BLAKE2b |
131 | | -- **`cpp/cryptopp-legacy`**: Crypto++ library with RSA, AES-GCM, SHA-256/512 |
| 48 | +C, C++, Go, Java, Kotlin, Python, Rust, Swift, Objective-C, PHP, Erlang |
132 | 49 |
|
133 | | -**Go Fixtures:** |
134 | | -- **`go/stdlib-crypto`**: Standard library crypto (RSA, ECDSA, AES-GCM, SHA-256/512) |
135 | | -- **`go/x-crypto-extended`**: Extended crypto with golang.org/x/crypto dependencies |
| 50 | +## Configuration |
136 | 51 |
|
137 | | -**Python Fixtures:** |
138 | | -- **`python/cryptography-mixed`**: PyCA Cryptography with RSA, AES, PBKDF2 |
139 | | -- **`python/pycryptodome-legacy`**: PyCryptodome with RSA signatures and AES |
140 | | -- **`python/requirements-basic`**: Basic requirements.txt with Fernet and hashing |
| 52 | +Edit `patterns.toml` to add new libraries or algorithms. No code changes needed. |
141 | 53 |
|
142 | | -**Certificate Fixtures:** |
143 | | -- **`certificates/x509-rsa-ecdsa`**: X.509 certificates with RSA and ECDSA signatures |
144 | | - |
145 | | -Run fixture tests: |
146 | | -```bash |
147 | | -# Test RSA vulnerability detection |
148 | | -./target/release/cipherscope fixtures/rust/rsa-vulnerable |
149 | | -jq '.cryptoAssets[] | select(.assetProperties.nistQuantumSecurityLevel == 0)' fixtures/rust/rsa-vulnerable/mv-cbom.json |
150 | | - |
151 | | -# Test multi-language support |
152 | | -./target/release/cipherscope fixtures/java/maven-bouncycastle |
153 | | -./target/release/cipherscope fixtures/go/stdlib-crypto |
154 | | -./target/release/cipherscope fixtures/python/cryptography-mixed |
155 | | - |
156 | | -# Test recursive project discovery |
157 | | -./target/release/cipherscope fixtures/buck-nested --recursive |
158 | | -./target/release/cipherscope fixtures/bazel-nested --recursive |
159 | | -``` |
160 | | - |
161 | | -Benchmark performance: |
| 54 | +## Testing |
162 | 55 |
|
163 | 56 | ```bash |
164 | 57 | cargo test |
165 | | -cargo bench |
166 | 58 | ``` |
167 | 59 |
|
168 | | -### Contributing |
169 | | - |
170 | | -See `CONTRIBUTING.md` for guidelines on adding languages, libraries, and improving performance. |
| 60 | +## License |
171 | 61 |
|
| 62 | +MIT |
0 commit comments