src/pqc_lint/patterns/rust.py
1.0 KB · 32 lines · python Raw
1 """Rust crypto patterns."""
2
3 from __future__ import annotations
4
5 from pqc_lint.patterns.base import PatternMatcher, compile_patterns
6
7
8 class RustMatcher(PatternMatcher):
9 language = "rust"
10 file_extensions = (".rs",)
11 patterns = compile_patterns([
12 ("PQC001", r"\buse\s+rsa\b"),
13 ("PQC001", r"\brsa::RsaPrivateKey::new\s*\("),
14 ("PQC002", r"\buse\s+ecdsa\b"),
15 ("PQC002", r"\buse\s+p256\b"),
16 ("PQC002", r"\buse\s+p384\b"),
17 ("PQC002", r"\buse\s+k256\b"),
18 ("PQC003", r"\buse\s+ed25519_dalek\b"),
19 ("PQC003", r"\bed25519_dalek::Keypair::generate\s*\("),
20 ("PQC103", r"\buse\s+x25519_dalek\b"),
21 ("PQC103", r"\bx25519_dalek::EphemeralSecret\b"),
22 # ring
23 ("PQC001", r"\bring::rsa\b"),
24 ("PQC002", r"\bring::signature::ECDSA"),
25 ("PQC101", r"\bring::agreement::ECDH"),
26 # hashes
27 ("PQC301", r"\buse\s+md5\b"),
28 ("PQC301", r"\bmd5::Md5\b"),
29 ("PQC302", r"\buse\s+sha1\b"),
30 ("PQC302", r"\bsha1::Sha1\b"),
31 ])
32