Skip to content

Commit 7c18686

Browse files
committed
Crypto: Further ql-for-ql alert alert fixes.
1 parent 790a607 commit 7c18686

File tree

13 files changed

+54
-37
lines changed

13 files changed

+54
-37
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class KnownOpenSslBlockModeConstantAlgorithmInstance extends OpenSslAlgorithmIns
5252
this instanceof OpenSslAlgorithmLiteral and
5353
exists(DataFlow::Node src, DataFlow::Node sink |
5454
// Sink is an argument to a CipherGetterCall
55-
sink = getterCall.(OpenSslAlgorithmValueConsumer).getInputNode() and
55+
sink = getterCall.getInputNode() and
5656
// Source is `this`
5757
src.asExpr() = this and
5858
// This traces to a getter

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class KnownOpenSslCipherConstantAlgorithmInstance extends OpenSslAlgorithmInstan
7777
this instanceof OpenSslAlgorithmLiteral and
7878
exists(DataFlow::Node src, DataFlow::Node sink |
7979
// Sink is an argument to a CipherGetterCall
80-
sink = getterCall.(OpenSslAlgorithmValueConsumer).getInputNode() and
80+
sink = getterCall.getInputNode() and
8181
// Source is `this`
8282
src.asExpr() = this and
8383
// This traces to a getter

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class KnownOpenSslHashConstantAlgorithmInstance extends OpenSslAlgorithmInstance
5757
this instanceof OpenSslAlgorithmLiteral and
5858
exists(DataFlow::Node src, DataFlow::Node sink |
5959
// Sink is an argument to a CipherGetterCall
60-
sink = getterCall.(OpenSslAlgorithmValueConsumer).getInputNode() and
60+
sink = getterCall.getInputNode() and
6161
// Source is `this`
6262
src.asExpr() = this and
6363
// This traces to a getter

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ class KnownOpenSslHashAlgorithmExpr extends Expr instanceof KnownOpenSslAlgorith
134134
}
135135
}
136136

137-
class KnownOpenSslMACAlgorithmExpr extends Expr instanceof KnownOpenSslAlgorithmExpr {
138-
KnownOpenSslMACAlgorithmExpr() { resolveAlgorithmFromExpr(this, _, "MAC") }
137+
class KnownOpenSslMacAlgorithmExpr extends Expr instanceof KnownOpenSslAlgorithmExpr {
138+
KnownOpenSslMacAlgorithmExpr() { resolveAlgorithmFromExpr(this, _, "MAC") }
139139
}
140140

141-
class KnownOpenSslHMACAlgorithmExpr extends Expr instanceof KnownOpenSslMACAlgorithmExpr {
142-
KnownOpenSslHMACAlgorithmExpr() { resolveAlgorithmFromExpr(this, "HMAC", "MAC") }
141+
class KnownOpenSslHMacAlgorithmExpr extends Expr instanceof KnownOpenSslMacAlgorithmExpr {
142+
KnownOpenSslHMacAlgorithmExpr() { resolveAlgorithmFromExpr(this, "HMAC", "MAC") }
143143

144144
/**
145145
* Gets an explicit cipher algorithm for this MAC algorithm.
@@ -148,8 +148,8 @@ class KnownOpenSslHMACAlgorithmExpr extends Expr instanceof KnownOpenSslMACAlgor
148148
KnownOpenSslHashAlgorithmExpr getExplicitHashAlgorithm() { result = this }
149149
}
150150

151-
class KnownOpenSslCMACAlgorithmExpr extends Expr instanceof KnownOpenSslMACAlgorithmExpr {
152-
KnownOpenSslCMACAlgorithmExpr() { resolveAlgorithmFromExpr(this, "CMAC", "MAC") }
151+
class KnownOpenSslCMacAlgorithmExpr extends Expr instanceof KnownOpenSslMacAlgorithmExpr {
152+
KnownOpenSslCMacAlgorithmExpr() { resolveAlgorithmFromExpr(this, "CMAC", "MAC") }
153153

154154
/**
155155
* Gets an explicit cipher algorithm for this MAC algorithm.

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ private import experimental.quantum.OpenSSL.AlgorithmInstances.OpenSSLAlgorithmI
66
private import experimental.quantum.OpenSSL.Operations.OpenSSLOperations
77
private import AlgToAVCFlow
88

9-
class KnownOpenSslMACConstantAlgorithmInstance extends OpenSslAlgorithmInstance,
10-
Crypto::MACAlgorithmInstance instanceof KnownOpenSslMACAlgorithmExpr
9+
class KnownOpenSslMacConstantAlgorithmInstance extends OpenSslAlgorithmInstance,
10+
Crypto::MACAlgorithmInstance instanceof KnownOpenSslMacAlgorithmExpr
1111
{
1212
OpenSslAlgorithmValueConsumer getterCall;
1313

14-
KnownOpenSslMACConstantAlgorithmInstance() {
14+
KnownOpenSslMacConstantAlgorithmInstance() {
1515
// Two possibilities:
1616
// 1) The source is a literal and flows to a getter, then we know we have an instance
1717
// 2) The source is a KnownOpenSslAlgorithm is call, and we know we have an instance immediately from that
@@ -33,24 +33,24 @@ class KnownOpenSslMACConstantAlgorithmInstance extends OpenSslAlgorithmInstance,
3333

3434
override OpenSslAlgorithmValueConsumer getAvc() { result = getterCall }
3535

36-
override string getRawMACAlgorithmName() {
36+
override string getRawMacAlgorithmName() {
3737
result = this.(Literal).getValue().toString()
3838
or
3939
result = this.(Call).getTarget().getName()
4040
}
4141

42-
override Crypto::TMACType getMACType() {
43-
this instanceof KnownOpenSslHMACAlgorithmExpr and result instanceof Crypto::THMAC
42+
override Crypto::TMACType getMacType() {
43+
this instanceof KnownOpenSslHMacAlgorithmExpr and result instanceof Crypto::THMAC
4444
or
45-
this instanceof KnownOpenSslCMACAlgorithmExpr and result instanceof Crypto::TCMAC
45+
this instanceof KnownOpenSslCMacAlgorithmExpr and result instanceof Crypto::TCMAC
4646
}
4747
}
4848

49-
class KnownOpenSslHMACConstantAlgorithmInstance extends Crypto::HMACAlgorithmInstance,
50-
KnownOpenSslMACConstantAlgorithmInstance
49+
class KnownOpenSslHMacConstantAlgorithmInstance extends Crypto::HMACAlgorithmInstance,
50+
KnownOpenSslMacConstantAlgorithmInstance
5151
{
5252
override Crypto::AlgorithmValueConsumer getHashAlgorithmValueConsumer() {
53-
if exists(this.(KnownOpenSslHMACAlgorithmExpr).getExplicitHashAlgorithm())
53+
if exists(this.(KnownOpenSslHMacAlgorithmExpr).getExplicitHashAlgorithm())
5454
then
5555
// ASSUMPTION: if there is an explicit hash algorithm, it is already modeled
5656
// and we can simply grab that model's AVC

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class KnownOpenSslPaddingConstantAlgorithmInstance extends OpenSslAlgorithmInsta
6363
this instanceof KnownOpenSslPaddingAlgorithmExpr and
6464
exists(DataFlow::Node src, DataFlow::Node sink |
6565
// Sink is an argument to a CipherGetterCall
66-
sink = getterCall.(OpenSslAlgorithmValueConsumer).getInputNode() and
66+
sink = getterCall.getInputNode() and
6767
// Source is `this`
6868
src.asExpr() = this and
6969
// This traces to a getter
@@ -81,7 +81,7 @@ class KnownOpenSslPaddingConstantAlgorithmInstance extends OpenSslAlgorithmInsta
8181
this instanceof OpenSslPaddingLiteral and
8282
exists(DataFlow::Node src, DataFlow::Node sink |
8383
// Sink is an argument to a CipherGetterCall
84-
sink = getterCall.(OpenSslAlgorithmValueConsumer).getInputNode() and
84+
sink = getterCall.getInputNode() and
8585
// Source is `this`
8686
src.asExpr() = this and
8787
// This traces to a padding-specific consumer

cpp/ql/lib/experimental/quantum/OpenSSL/AlgorithmValueConsumers/KEMAlgorithmValueConsumer.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ private import semmle.code.cpp.dataflow.new.DataFlow
44
private import experimental.quantum.OpenSSL.AlgorithmValueConsumers.OpenSSLAlgorithmValueConsumerBase
55
private import experimental.quantum.OpenSSL.AlgorithmInstances.OpenSSLAlgorithmInstances
66

7-
abstract class KEMAlgorithmValueConsumer extends OpenSslAlgorithmValueConsumer { }
7+
abstract class KemAlgorithmValueConsumer extends OpenSslAlgorithmValueConsumer { }
88

9-
class EvpKEMAlgorithmValueConsumer extends KEMAlgorithmValueConsumer {
9+
class EvpKemAlgorithmValueConsumer extends KemAlgorithmValueConsumer {
1010
DataFlow::Node valueArgNode;
1111
DataFlow::Node resultNode;
1212

13-
EvpKEMAlgorithmValueConsumer() {
13+
EvpKemAlgorithmValueConsumer() {
1414
resultNode.asExpr() = this and
1515
(
1616
this.(Call).getTarget().getName() = "EVP_KEM_fetch" and

cpp/ql/lib/experimental/quantum/OpenSSL/AlgorithmValueConsumers/PaddingAlgorithmValueConsumer.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ abstract class PaddingAlgorithmValueConsumer extends OpenSslAlgorithmValueConsum
99
// https://docs.openssl.org/master/man7/EVP_ASYM_CIPHER-RSA/#rsa-asymmetric-cipher-parameters
1010
// TODO: need to handle setting padding through EVP_PKEY_CTX_set_params, where modes like "OSSL_PKEY_RSA_PAD_MODE_OAEP"
1111
// are set.
12-
class Evp_PKEY_CTX_set_rsa_padding_AlgorithmValueConsumer extends PaddingAlgorithmValueConsumer {
12+
class Evp_PKey_Ctx_set_rsa_padding_AlgorithmValueConsumer extends PaddingAlgorithmValueConsumer {
1313
DataFlow::Node valueArgNode;
1414
DataFlow::Node resultNode;
1515

16-
Evp_PKEY_CTX_set_rsa_padding_AlgorithmValueConsumer() {
16+
Evp_PKey_Ctx_set_rsa_padding_AlgorithmValueConsumer() {
1717
resultNode.asExpr() = this and
1818
this.(Call).getTarget().getName() = "EVP_PKEY_CTX_set_rsa_padding" and
1919
valueArgNode.asExpr() = this.(Call).getArgument(1)

cpp/ql/lib/experimental/quantum/OpenSSL/Operations/EVPCipherOperation.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ class Evp_Cipher_EX2_or_Simple_Init_Call extends Evp_EX2_Initializer {
7070
}
7171
}
7272

73-
class Evp_CipherInit_SKEY_Call extends Evp_EX2_Initializer {
74-
Evp_CipherInit_SKEY_Call() { this.(Call).getTarget().getName() in ["EVP_CipherInit_SKEY"] }
73+
class Evp_CipherInit_SKey_Call extends Evp_EX2_Initializer {
74+
Evp_CipherInit_SKey_Call() { this.(Call).getTarget().getName() = "EVP_CipherInit_SKEY" }
7575

7676
override Expr getKeyOperationSubtypeArg() { result = this.(Call).getArgument(5) }
7777
}

cpp/ql/lib/experimental/quantum/OpenSSL/Operations/EVPSignatureOperation.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ abstract class EvpSignatureOperation extends EvpOperation, Crypto::SignatureOper
132132

133133
/**
134134
* Keys provided in the initialization call or in a context are found by this method.
135-
* Keys in explicit arguments are found by overriden methods in extending classes.
135+
* Keys in explicit arguments are found by overridden methods in extending classes.
136136
*/
137137
override Crypto::ConsumerInputDataFlowNode getKeyConsumer() {
138138
result = DataFlow::exprNode(this.getInitCall().(EvpKeyInitializer).getKeyArg())

0 commit comments

Comments
 (0)