Content-Length: 354520 | pFad | http://github.com/github/codeql/commit/007683f06ae0175eec7114d56f8b3eb6c09899ab

BC Crypto: Simplifying constant comparisons. · github/codeql@007683f · GitHub
Skip to content

Commit 007683f

Browse files
committed
Crypto: Simplifying constant comparisons.
1 parent 28f4824 commit 007683f

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

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

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,20 @@ class KnownOpenSSLCipherAlgorithmConstant extends KnownOpenSSLAlgorithmConstant
3333
}
3434

3535
class KnownOpenSSLPaddingAlgorithmConstant extends KnownOpenSSLAlgorithmConstant {
36-
string algType;
37-
3836
KnownOpenSSLPaddingAlgorithmConstant() {
39-
resolveAlgorithmFromExpr(this, _, algType) and
40-
algType.matches("%PADDING")
37+
exists(string algType |
38+
resolveAlgorithmFromExpr(this, _, algType) and
39+
algType.matches("%PADDING")
40+
)
4141
}
4242
}
4343

4444
class KnownOpenSSLBlockModeAlgorithmConstant extends KnownOpenSSLAlgorithmConstant {
45-
string algType;
46-
47-
KnownOpenSSLBlockModeAlgorithmConstant() {
48-
resolveAlgorithmFromExpr(this, _, algType) and
49-
algType.matches("%BLOCK_MODE")
50-
}
45+
KnownOpenSSLBlockModeAlgorithmConstant() { resolveAlgorithmFromExpr(this, _, "BLOCK_MODE") }
5146
}
5247

5348
class KnownOpenSSLHashAlgorithmConstant extends KnownOpenSSLAlgorithmConstant {
54-
string algType;
55-
56-
KnownOpenSSLHashAlgorithmConstant() {
57-
resolveAlgorithmFromExpr(this, _, algType) and
58-
algType.matches("%HASH")
59-
}
49+
KnownOpenSSLHashAlgorithmConstant() { resolveAlgorithmFromExpr(this, _, "HASH") }
6050

6151
int getExplicitDigestLength() {
6252
exists(string name |
@@ -69,20 +59,12 @@ class KnownOpenSSLHashAlgorithmConstant extends KnownOpenSSLAlgorithmConstant {
6959

7060
class KnownOpenSSLEllipticCurveAlgorithmConstant extends KnownOpenSSLAlgorithmConstant {
7161
KnownOpenSSLEllipticCurveAlgorithmConstant() {
72-
exists(string algType |
73-
resolveAlgorithmFromExpr(this, _, algType) and
74-
algType.matches("ELLIPTIC_CURVE")
75-
)
62+
resolveAlgorithmFromExpr(this, _, "ELLIPTIC_CURVE")
7663
}
7764
}
7865

7966
class KnownOpenSSLSignatureAlgorithmConstant extends KnownOpenSSLAlgorithmConstant {
80-
string algType;
81-
82-
KnownOpenSSLSignatureAlgorithmConstant() {
83-
resolveAlgorithmFromExpr(this, _, algType) and
84-
algType.matches("SIGNATURE")
85-
}
67+
KnownOpenSSLSignatureAlgorithmConstant() { resolveAlgorithmFromExpr(this, _, "SIGNATURE") }
8668
}
8769

8870
/**

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/github/codeql/commit/007683f06ae0175eec7114d56f8b3eb6c09899ab

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy