1
1
/**
2
2
* Provides predicates relating to encryption in C and C++.
3
3
*/
4
+
4
5
import cpp
5
6
6
7
/**
7
8
* Returns an algorithm that is known to be insecure.
8
9
*/
9
- string algorithmBlacklist ( ) {
10
+ string getAnInsecureAlgorithmName ( ) {
10
11
result = "DES" or
11
12
result = "RC2" or
12
13
result = "RC4" or
@@ -18,7 +19,7 @@ string algorithmBlacklist() {
18
19
* Returns the name of a hash algorithm that is insecure if it is being used for
19
20
* encryption (but it is hard to know when that is happening).
20
21
*/
21
- string hashAlgorithmBlacklist ( ) {
22
+ string getAnInsecureHashAlgorithmName ( ) {
22
23
result = "SHA1" or
23
24
result = "MD5"
24
25
}
@@ -27,23 +28,23 @@ string hashAlgorithmBlacklist() {
27
28
* Returns a regular expression for matching strings that look like they
28
29
* contain an algorithm that is known to be insecure.
29
30
*/
30
- string algorithmBlacklistRegex ( ) {
31
+ string getInsecureAlgorithmRegex ( ) {
31
32
result =
32
33
// algorithms usually appear in names surrounded by characters that are not
33
34
// alphabetical characters in the same case. This handles the upper and lower
34
35
// case cases
35
- "(^|.*[^A-Z])(" + strictconcat ( algorithmBlacklist ( ) , "|" ) + ")([^A-Z].*|$)" + "|" +
36
+ "(^|.*[^A-Z])(" + strictconcat ( getAnInsecureAlgorithmName ( ) , "|" ) + ")([^A-Z].*|$)" + "|" +
36
37
// for lowercase, we want to be careful to avoid being confused by camelCase
37
38
// hence we require two preceding uppercase letters to be sure of a case switch,
38
39
// or a preceding non-alphabetic character
39
- "(^|.*[A-Z]{2}|.*[^a-zA-Z])(" + strictconcat ( algorithmBlacklist ( ) .toLowerCase ( ) , "|" ) +
40
+ "(^|.*[A-Z]{2}|.*[^a-zA-Z])(" + strictconcat ( getAnInsecureAlgorithmName ( ) .toLowerCase ( ) , "|" ) +
40
41
")([^a-z].*|$)"
41
42
}
42
43
43
44
/**
44
45
* Returns an algorithms that is known to be secure.
45
46
*/
46
- string algorithmWhitelist ( ) {
47
+ string getASecureAlgorithmName ( ) {
47
48
result = "RSA" or
48
49
result = "SHA256" or
49
50
result = "CCM" or
@@ -57,16 +58,44 @@ string algorithmWhitelist() {
57
58
* Returns a regular expression for matching strings that look like they
58
59
* contain an algorithm that is known to be secure.
59
60
*/
60
- string algorithmWhitelistRegex ( ) {
61
- // The implementation of this is a duplicate of algorithmBlacklistRegex , as
61
+ string getSecureAlgorithmRegex ( ) {
62
+ // The implementation of this is a duplicate of getInsecureAlgorithmRegex , as
62
63
// it isn't possible to have string -> string functions at the moment
63
64
// algorithms usually appear in names surrounded by characters that are not
64
65
// alphabetical characters in the same case. This handles the upper and lower
65
66
// case cases
66
- result = "(^|.*[^A-Z])" + algorithmWhitelist ( ) + "([^A-Z].*|$)"
67
+ result = "(^|.*[^A-Z])" + getASecureAlgorithmName ( ) + "([^A-Z].*|$)"
67
68
or
68
69
// for lowercase, we want to be careful to avoid being confused by camelCase
69
70
// hence we require two preceding uppercase letters to be sure of a case
70
71
// switch, or a preceding non-alphabetic character
71
- result = "(^|.*[A-Z]{2}|.*[^a-zA-Z])" + algorithmWhitelist ( ) .toLowerCase ( ) + "([^a-z].*|$)"
72
+ result = "(^|.*[A-Z]{2}|.*[^a-zA-Z])" + getASecureAlgorithmName ( ) .toLowerCase ( ) + "([^a-z].*|$)"
72
73
}
74
+
75
+ /**
76
+ * DEPRECATED: Terminology has been updated. Use `getAnInsecureAlgorithmName()`
77
+ * instead.
78
+ */
79
+ deprecated string algorithmBlacklist ( ) { result = getAnInsecureAlgorithmName ( ) }
80
+
81
+ /**
82
+ * DEPRECATED: Terminology has been updated. Use
83
+ * `getAnInsecureHashAlgorithmName()` instead.
84
+ */
85
+ deprecated string hashAlgorithmBlacklist ( ) { result = getAnInsecureHashAlgorithmName ( ) }
86
+
87
+ /**
88
+ * DEPRECATED: Terminology has been updated. Use `getInsecureAlgorithmRegex()` instead.
89
+ */
90
+ deprecated string algorithmBlacklistRegex ( ) { result = getInsecureAlgorithmRegex ( ) }
91
+
92
+ /**
93
+ * DEPRECATED: Terminology has been updated. Use `getASecureAlgorithmName()`
94
+ * instead.
95
+ */
96
+ deprecated string algorithmWhitelist ( ) { result = getASecureAlgorithmName ( ) }
97
+
98
+ /**
99
+ * DEPRECATED: Terminology has been updated. Use `getSecureAlgorithmRegex()` instead.
100
+ */
101
+ deprecated string algorithmWhitelistRegex ( ) { result = getSecureAlgorithmRegex ( ) }
0 commit comments