|
| 1 | +/** |
| 2 | + * Names of cryptographic algorithms, separated into strong and weak variants. |
| 3 | + * |
| 4 | + * The names are normalized: upper-case, no spaces, dashes or underscores. |
| 5 | + * |
| 6 | + * The names are inspired by the names used in real world crypto libraries. |
| 7 | + * |
| 8 | + * The classification into strong and weak are based on Wikipedia, OWASP and Google (2021). |
| 9 | + */ |
| 10 | + |
| 11 | +/** |
| 12 | + * Holds if `name` corresponds to a strong hashing algorithm. |
| 13 | + */ |
| 14 | +predicate isStrongHashingAlgorithm(string name) { |
| 15 | + name = |
| 16 | + [ |
| 17 | + "DSA", "ED25519", "ES256", "ECDSA256", "ES384", "ECDSA384", "ES512", "ECDSA512", "SHA2", |
| 18 | + "SHA224", "SHA256", "SHA384", "SHA512", "SHA3", "SHA3224", "SHA3256", "SHA3384", "SHA3512" |
| 19 | + ] |
| 20 | +} |
| 21 | + |
| 22 | +/** |
| 23 | + * Holds if `name` corresponds to a weak hashing algorithm. |
| 24 | + */ |
| 25 | +predicate isWeakHashingAlgorithm(string name) { |
| 26 | + name = |
| 27 | + [ |
| 28 | + "HAVEL128", "MD2", "MD4", "MD5", "PANAMA", "RIPEMD", "RIPEMD128", "RIPEMD256", "RIPEMD160", |
| 29 | + "RIPEMD320", "SHA0", "SHA1" |
| 30 | + ] |
| 31 | +} |
| 32 | + |
| 33 | +/** |
| 34 | + * Holds if `name` corresponds to a strong encryption algorithm. |
| 35 | + */ |
| 36 | +predicate isStrongEncryptionAlgorithm(string name) { |
| 37 | + name = |
| 38 | + [ |
| 39 | + "AES", "AES128", "AES192", "AES256", "AES512", "AES-128", "AES-192", "AES-256", "AES-512", |
| 40 | + "ARIA", "BLOWFISH", "BF", "ECIES", "CAST", "CAST5", "CAMELLIA", "CAMELLIA128", "CAMELLIA192", |
| 41 | + "CAMELLIA256", "CAMELLIA-128", "CAMELLIA-192", "CAMELLIA-256", "CHACHA", "GOST", "GOST89", |
| 42 | + "IDEA", "RABBIT", "RSA", "SEED", "SM4" |
| 43 | + ] |
| 44 | +} |
| 45 | + |
| 46 | +/** |
| 47 | + * Holds if `name` corresponds to a weak encryption algorithm. |
| 48 | + */ |
| 49 | +predicate isWeakEncryptionAlgorithm(string name) { |
| 50 | + name = |
| 51 | + [ |
| 52 | + "DES", "3DES", "DES3", "TRIPLEDES", "DESX", "TDEA", "TRIPLEDEA", "ARC2", "RC2", "ARC4", "RC4", |
| 53 | + "ARCFOUR", "ARC5", "RC5" |
| 54 | + ] |
| 55 | +} |
| 56 | + |
| 57 | +/** |
| 58 | + * Holds if `name` corresponds to a strong password hashing algorithm. |
| 59 | + */ |
| 60 | +predicate isStrongPasswordHashingAlgorithm(string name) { |
| 61 | + name = ["ARGON2", "PBKDF2", "BCRYPT", "SCRYPT"] |
| 62 | +} |
| 63 | + |
| 64 | +/** |
| 65 | + * Holds if `name` corresponds to a weak password hashing algorithm. |
| 66 | + */ |
| 67 | +predicate isWeakPasswordHashingAlgorithm(string name) { name = "EVPKDF" } |
| 68 | + |
| 69 | +/** |
| 70 | + * Holds if `name` corresponds to a weak block cipher mode of operation. |
| 71 | + */ |
| 72 | +predicate isWeakBlockMode(string name) { name = "ECB" } |
0 commit comments