Skip to content

Commit 100045d

Browse files
committed
Crypto: optimizing out the "getPossibleNidFromLiteral" predicate, and now relying on the charpred of OpenSSLAlgorithmCandidateLiteral.
1 parent a36fd2c commit 100045d

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

cpp/ql/lib/experimental/quantum/OpenSSL/AlgorithmInstances/KnownAlgorithmConstants.qll

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,7 @@ predicate resolveAlgorithmFromCall(Call c, string normalized, string algType) {
105105
predicate resolveAlgorithmFromLiteral(
106106
OpenSSLAlgorithmCandidateLiteral e, string normalized, string algType
107107
) {
108-
exists(int nid |
109-
nid = getPossibleNidFromLiteral(e) and knownOpenSSLAlgorithmLiteral(_, nid, normalized, algType)
110-
)
108+
knownOpenSSLAlgorithmLiteral(_, e.getValue().toInt(), normalized, algType)
111109
or
112110
exists(string name |
113111
name = resolveAlgorithmAlias(e.getValue()) and
@@ -126,17 +124,6 @@ string resolveAlgorithmAlias(string name) {
126124
)
127125
}
128126

129-
/**
130-
* Determines if an int literal (NID) is a candidate for being an algorithm literal.
131-
* Checks for common cases where literals are used that would not be indicative of an algorithm.
132-
* Returns the int literal value if the literal is a candidate for an algorithm.
133-
*/
134-
private int getPossibleNidFromLiteral(OpenSSLAlgorithmCandidateLiteral e) {
135-
result = e.getValue().toInt() and
136-
not e instanceof CharLiteral and
137-
not e instanceof StringLiteral
138-
}
139-
140127
string getAlgorithmAlias(string alias) {
141128
customAliases(result, alias)
142129
or

0 commit comments

Comments
 (0)