Skip to content

Commit a2104de

Browse files
committed
Move CryptoAlgorithms::AlgorithmsName into a separate internal/CryptoAlgorithmNames.qll
1 parent f16d776 commit a2104de

File tree

8 files changed

+225
-226
lines changed

8 files changed

+225
-226
lines changed

config/identical-files.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,11 @@
457457
"python/ql/lib/semmle/python/concepts/CryptoAlgorithms.qll",
458458
"ruby/ql/lib/codeql/ruby/security/CryptoAlgorithms.qll"
459459
],
460+
"CryptoAlgorithmNames Python/JS/Ruby": [
461+
"javascript/ql/lib/semmle/javascript/security/internal/CryptoAlgorithmNames.qll",
462+
"python/ql/lib/semmle/python/concepts/internal/CryptoAlgorithmNames.qll",
463+
"ruby/ql/lib/codeql/ruby/security/internal/CryptoAlgorithmNames.qll"
464+
],
460465
"SensitiveDataHeuristics Python/JS": [
461466
"javascript/ql/lib/semmle/javascript/security/internal/SensitiveDataHeuristics.qll",
462467
"python/ql/lib/semmle/python/security/internal/SensitiveDataHeuristics.qll"

javascript/ql/lib/semmle/javascript/security/CryptoAlgorithms.qll

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4,81 +4,7 @@
44
* The classification into strong and weak are based on Wikipedia, OWASP and google (2017).
55
*/
66

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

839
/**
8410
* A cryptographic algorithm.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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 (2017).
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" }

python/ql/lib/semmle/python/concepts/CryptoAlgorithms.qll

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4,81 +4,7 @@
44
* The classification into strong and weak are based on Wikipedia, OWASP and google (2017).
55
*/
66

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

839
/**
8410
* A cryptographic algorithm.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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 (2017).
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

Comments
 (0)