C++: Rearrange the library.

This commit is contained in:
Geoffrey White
2021-05-13 08:38:58 +01:00
parent 0450caa73d
commit 40cf29b625
2 changed files with 13 additions and 5 deletions

View File

@@ -18,7 +18,7 @@ abstract class InsecureCryptoSpec extends Locatable {
}
Function getAnInsecureFunction() {
result.getName().regexpMatch(getInsecureAlgorithmRegex()) and
isInsecureEncryption(result.getName()) and
exists(result.getACallToThisFunction())
}
@@ -36,7 +36,7 @@ class InsecureFunctionCall extends InsecureCryptoSpec, FunctionCall {
}
Macro getAnInsecureMacro() {
result.getName().regexpMatch(getInsecureAlgorithmRegex()) and
isInsecureEncryption(result.getName()) and
exists(result.getAnInvocation())
}

View File

@@ -14,6 +14,13 @@ string getAnInsecureAlgorithmName() {
]
}
/**
* Gets the name of an algorithm that is known to be secure.
*/
string getASecureAlgorithmName() {
result = ["RSA", "SHA256", "CCM", "GCM", "AES", "Blowfish", "ECIES"]
}
/**
* Gets the name of a hash algorithm that is insecure if it is being used for
* encryption (but it is hard to know when that is happening).
@@ -39,10 +46,11 @@ string getInsecureAlgorithmRegex() {
}
/**
* Gets the name of an algorithm that is known to be secure.
* Holds if `name` looks like it might be related to operations with an
* insecure encyption algorithm.
*/
string getASecureAlgorithmName() {
result = ["RSA", "SHA256", "CCM", "GCM", "AES", "Blowfish", "ECIES"]
bindingset[name] predicate isInsecureEncryption(string name) {
name.regexpMatch(getInsecureAlgorithmRegex())
}
/**