Skip to content

Commit e277b63

Browse files
committed
Fix QL-for-QL alerts
1 parent 61ec2aa commit e277b63

File tree

9 files changed

+49
-49
lines changed

9 files changed

+49
-49
lines changed

java/ql/lib/experimental/quantum/JCA.qll

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,9 +1954,9 @@ module JCAModel {
19541954
result = this
19551955
or
19561956
// Explicit PSS hash from PSSParameterSpec via Signature.setParameter()
1957-
exists(PSSParameterSpecInstantiation spec |
1957+
exists(PssParameterSpecInstantiation spec |
19581958
pssSpecForSignatureLiteral(spec, this) and
1959-
result.(PSSParameterSpecDigestHashAlgorithmInstance).getSpec() = spec
1959+
result.(PssParameterSpecDigestHashAlgorithmInstance).getSpec() = spec
19601960
)
19611961
}
19621962

@@ -1965,9 +1965,9 @@ module JCAModel {
19651965
result = this
19661966
or
19671967
// Explicit MGF1 hash from PSSParameterSpec via Signature.setParameter()
1968-
exists(PSSParameterSpecInstantiation spec |
1968+
exists(PssParameterSpecInstantiation spec |
19691969
pssSpecForSignatureLiteral(spec, this) and
1970-
result.(PSSParameterSpecMgf1HashAlgorithmInstance).getSpec() = spec
1970+
result.(PssParameterSpecMgf1HashAlgorithmInstance).getSpec() = spec
19711971
)
19721972
}
19731973
}
@@ -1976,8 +1976,8 @@ module JCAModel {
19761976
* A PSSParameterSpec instantiation, e.g.,
19771977
* new PSSParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256, 32, 1)
19781978
*/
1979-
class PSSParameterSpecInstantiation extends ClassInstanceExpr {
1980-
PSSParameterSpecInstantiation() {
1979+
class PssParameterSpecInstantiation extends ClassInstanceExpr {
1980+
PssParameterSpecInstantiation() {
19811981
this.getConstructedType().hasQualifiedName("java.security.spec", "PSSParameterSpec")
19821982
}
19831983

@@ -1999,8 +1999,8 @@ module JCAModel {
19991999
* `MGF1ParameterSpec.SHA256`. These fields represent well-known MGF1 hash
20002000
* algorithm configurations.
20012001
*/
2002-
class MGF1ParameterSpecFieldAccess extends FieldAccess {
2003-
MGF1ParameterSpecFieldAccess() {
2002+
class Mgf1ParameterSpecFieldAccess extends FieldAccess {
2003+
Mgf1ParameterSpecFieldAccess() {
20042004
this.getField().getDeclaringType().hasQualifiedName("java.security.spec", "MGF1ParameterSpec") and
20052005
this.getField().isStatic()
20062006
}
@@ -2030,18 +2030,18 @@ module JCAModel {
20302030
*
20312031
* Type resolution delegates to hash_name_to_type_known from Standardization.
20322032
*/
2033-
class PSSParameterSpecDigestHashAlgorithmInstance extends Crypto::HashAlgorithmInstance instanceof JavaConstant
2033+
class PssParameterSpecDigestHashAlgorithmInstance extends Crypto::HashAlgorithmInstance instanceof JavaConstant
20342034
{
2035-
PSSParameterSpecInstantiation spec;
2035+
PssParameterSpecInstantiation spec;
20362036

2037-
PSSParameterSpecDigestHashAlgorithmInstance() {
2037+
PssParameterSpecDigestHashAlgorithmInstance() {
20382038
this = spec.getDigestAlgorithmArg() and
20392039
// Only instantiate when the value resolves to a known hash type
20402040
exists(hash_name_to_type_known(super.getValue(), _))
20412041
}
20422042

20432043
/** Gets the PSSParameterSpec this digest hash belongs to. */
2044-
PSSParameterSpecInstantiation getSpec() { result = spec }
2044+
PssParameterSpecInstantiation getSpec() { result = spec }
20452045

20462046
override string getRawHashAlgorithmName() { result = super.getValue() }
20472047

@@ -2062,20 +2062,20 @@ module JCAModel {
20622062
* The field name is normalized to a standard hash algorithm name (e.g.,
20632063
* SHA256 -> SHA-256), then type resolution delegates to hash_name_to_type_known.
20642064
*/
2065-
class PSSParameterSpecMgf1HashAlgorithmInstance extends Crypto::HashAlgorithmInstance instanceof MGF1ParameterSpecFieldAccess
2065+
class PssParameterSpecMgf1HashAlgorithmInstance extends Crypto::HashAlgorithmInstance instanceof Mgf1ParameterSpecFieldAccess
20662066
{
2067-
PSSParameterSpecInstantiation spec;
2067+
PssParameterSpecInstantiation spec;
20682068
string normalizedName;
20692069

2070-
PSSParameterSpecMgf1HashAlgorithmInstance() {
2070+
PssParameterSpecMgf1HashAlgorithmInstance() {
20712071
this = spec.getMgfSpecArg() and
20722072
normalizedName = super.getHashAlgorithmName() and
20732073
// Only instantiate when the normalized name resolves to a known hash type
20742074
exists(hash_name_to_type_known(normalizedName, _))
20752075
}
20762076

20772077
/** Gets the PSSParameterSpec this MGF1 hash belongs to. */
2078-
PSSParameterSpecInstantiation getSpec() { result = spec }
2078+
PssParameterSpecInstantiation getSpec() { result = spec }
20792079

20802080
override string getRawHashAlgorithmName() { result = super.getField().getName() }
20812081

@@ -2219,15 +2219,15 @@ module JCAModel {
22192219
/**
22202220
* Flow from `PSSParameterSpec` instantiation to `Signature.setParameter()` argument.
22212221
*/
2222-
module PSSSpecToSetParameterConfig implements DataFlow::ConfigSig {
2223-
predicate isSource(DataFlow::Node src) { src.asExpr() instanceof PSSParameterSpecInstantiation }
2222+
module PssSpecToSetParameterConfig implements DataFlow::ConfigSig {
2223+
predicate isSource(DataFlow::Node src) { src.asExpr() instanceof PssParameterSpecInstantiation }
22242224

22252225
predicate isSink(DataFlow::Node sink) {
22262226
exists(SignatureSetParameterCall c | sink.asExpr() = c.getParameterSpecArg())
22272227
}
22282228
}
22292229

2230-
module PSSSpecToSetParameterFlow = DataFlow::Global<PSSSpecToSetParameterConfig>;
2230+
module PssSpecToSetParameterFlow = DataFlow::Global<PssSpecToSetParameterConfig>;
22312231

22322232
/**
22332233
* Connects a PSSParameterSpec instantiation to the signature PSS padding literal
@@ -2239,7 +2239,7 @@ module JCAModel {
22392239
* 3. The PSSParameterSpec flows to the same setParameter's argument
22402240
*/
22412241
private predicate pssSpecForSignatureLiteral(
2242-
PSSParameterSpecInstantiation spec, SignaturePssPaddingAlgorithmInstance literal
2242+
PssParameterSpecInstantiation spec, SignaturePssPaddingAlgorithmInstance literal
22432243
) {
22442244
exists(
22452245
SignatureSetParameterCall setParam, SignatureGetInstanceCall getInstance,
@@ -2249,7 +2249,7 @@ module JCAModel {
22492249
consumer = getInstance.getAlgorithmArg() and
22502250
SignatureToSetParameterFlow::flow(DataFlow::exprNode(getInstance),
22512251
DataFlow::exprNode(setParam.getQualifier())) and
2252-
PSSSpecToSetParameterFlow::flow(DataFlow::exprNode(spec),
2252+
PssSpecToSetParameterFlow::flow(DataFlow::exprNode(spec),
22532253
DataFlow::exprNode(setParam.getParameterSpecArg()))
22542254
)
22552255
}

java/ql/src/experimental/quantum/Examples/Demo/InventoryCurves.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import experimental.quantum.Language
1212

1313
from Crypto::EllipticCurveNode c, string detail
1414
where
15-
if exists(string ks | c.properties("KeySize", ks, _))
15+
if c.properties("KeySize", _, _)
1616
then
1717
exists(string ks |
1818
c.properties("KeySize", ks, _) and

java/ql/src/experimental/quantum/Examples/Demo/ProtocolJWS_PS.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ import Crypto::KeyOpAlg as KeyOpAlg
1313

1414
from
1515
Crypto::SignatureOperationNode sigOp, Crypto::KeyOperationAlgorithmNode alg,
16-
Crypto::PSSPaddingAlgorithmNode pss, Crypto::HashAlgorithmNode hash, int digestLen
16+
Crypto::PssPaddingAlgorithmNode pss, Crypto::HashAlgorithmNode hash, int digestLen
1717
where
1818
alg = sigOp.getAKnownAlgorithm() and
1919
alg.getAlgorithmType() = KeyOpAlg::TAsymmetricCipher(KeyOpAlg::RSA()) and
2020
pss = alg.getPaddingAlgorithm() and
2121
// Get hash from the PSS padding or from the signature operation
2222
(
23-
hash = pss.getPSSHashAlgorithm()
23+
hash = pss.getPssHashAlgorithm()
2424
or
25-
hash = sigOp.getHashAlgorithm() and not exists(pss.getPSSHashAlgorithm())
25+
hash = sigOp.getHashAlgorithm() and not exists(pss.getPssHashAlgorithm())
2626
) and
2727
hash.getHashType() = Crypto::SHA2() and
2828
digestLen = hash.getDigestLength() and

java/ql/src/experimental/quantum/Examples/Demo/ProtocolJWS_RS.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ where
1818
alg = sigOp.getAKnownAlgorithm() and
1919
alg.getAlgorithmType() = KeyOpAlg::TAsymmetricCipher(KeyOpAlg::RSA()) and
2020
// No PSS padding — implies PKCS#1 v1.5
21-
not alg.getPaddingAlgorithm() instanceof Crypto::PSSPaddingAlgorithmNode and
21+
not alg.getPaddingAlgorithm() instanceof Crypto::PssPaddingAlgorithmNode and
2222
// Hash is SHA-2 with standard JWS digest lengths
2323
hash = sigOp.getHashAlgorithm() and
2424
hash.getHashType() = Crypto::SHA2() and

java/ql/src/experimental/quantum/Examples/Demo/ProtocolRSA_OAEP.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import experimental.quantum.Language
1212
import Crypto::KeyOpAlg as KeyOpAlg
1313

14-
from Crypto::KeyOperationAlgorithmNode alg, Crypto::OAEPPaddingAlgorithmNode pad
14+
from Crypto::KeyOperationAlgorithmNode alg, Crypto::OaepPaddingAlgorithmNode pad
1515
where
1616
alg.getAlgorithmType() = KeyOpAlg::TAsymmetricCipher(KeyOpAlg::RSA()) and
1717
pad = alg.getPaddingAlgorithm()

java/ql/src/experimental/quantum/Examples/Demo/ProtocolRSA_PKCS1v15.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ where
2121
or
2222
// RSA signature without PSS — implies PKCS#1 v1.5 (e.g., SHA256withRSA)
2323
exists(Crypto::SignatureOperationNode sigOp | alg = sigOp.getAKnownAlgorithm()) and
24-
not alg.getPaddingAlgorithm() instanceof Crypto::PSSPaddingAlgorithmNode and
24+
not alg.getPaddingAlgorithm() instanceof Crypto::PssPaddingAlgorithmNode and
2525
variant = "implicit PKCS#1 v1.5 (RSA signature without PSS)"
2626
)
2727
select alg, "RSA PKCS#1 v1.5 protocol detected: " + variant + "."

java/ql/src/experimental/quantum/Examples/Demo/ProtocolRSA_PSS.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import experimental.quantum.Language
1212
import Crypto::KeyOpAlg as KeyOpAlg
1313

14-
from Crypto::KeyOperationAlgorithmNode alg, Crypto::PSSPaddingAlgorithmNode pss
14+
from Crypto::KeyOperationAlgorithmNode alg, Crypto::PssPaddingAlgorithmNode pss
1515
where
1616
alg.getAlgorithmType() = KeyOpAlg::TAsymmetricCipher(KeyOpAlg::RSA()) and
1717
pss = alg.getPaddingAlgorithm()

java/ql/src/experimental/quantum/Examples/Demo/QuantumVulnerablePadding.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ from Crypto::PaddingAlgorithmNode pad, string msg
1414
where
1515
isQuantumVulnerablePaddingType(pad.getPaddingType()) and
1616
(
17-
pad instanceof Crypto::PSSPaddingAlgorithmNode and
17+
pad instanceof Crypto::PssPaddingAlgorithmNode and
1818
msg = "Quantum-vulnerable PSS padding scheme detected."
1919
or
20-
pad instanceof Crypto::OAEPPaddingAlgorithmNode and
20+
pad instanceof Crypto::OaepPaddingAlgorithmNode and
2121
msg = "Quantum-vulnerable OAEP padding scheme detected."
2222
or
23-
not pad instanceof Crypto::PSSPaddingAlgorithmNode and
24-
not pad instanceof Crypto::OAEPPaddingAlgorithmNode and
23+
not pad instanceof Crypto::PssPaddingAlgorithmNode and
24+
not pad instanceof Crypto::OaepPaddingAlgorithmNode and
2525
msg = "Quantum-vulnerable padding scheme: " + pad.getPaddingType().toString() + "."
2626
)
2727
select pad, msg

shared/quantum/codeql/quantum/experimental/Model.qll

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,16 +2155,16 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
21552155
override string getRawAlgorithmName() { result = instance.getRawPaddingAlgorithmName() }
21562156
}
21572157

2158-
class OAEPPaddingAlgorithmNode extends PaddingAlgorithmNode {
2158+
class OaepPaddingAlgorithmNode extends PaddingAlgorithmNode {
21592159
override OaepPaddingAlgorithmInstance instance;
21602160

2161-
OAEPPaddingAlgorithmNode() { this = TPaddingAlgorithm(instance) }
2161+
OaepPaddingAlgorithmNode() { this = TPaddingAlgorithm(instance) }
21622162

2163-
HashAlgorithmNode getOAEPEncodingHashAlgorithm() {
2163+
HashAlgorithmNode getOaepEncodingHashAlgorithm() {
21642164
result.asElement() = instance.getOaepEncodingHashAlgorithm()
21652165
}
21662166

2167-
HashAlgorithmNode getMGF1HashAlgorithm() {
2167+
HashAlgorithmNode getMgf1HashAlgorithm() {
21682168
result.asElement() = instance.getMgf1HashAlgorithm()
21692169
}
21702170

@@ -2173,26 +2173,26 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
21732173
or
21742174
// [KNOWN_OR_UNKNOWN]
21752175
edgeName = "MD" and
2176-
if exists(this.getOAEPEncodingHashAlgorithm())
2177-
then result = this.getOAEPEncodingHashAlgorithm()
2176+
if exists(this.getOaepEncodingHashAlgorithm())
2177+
then result = this.getOaepEncodingHashAlgorithm()
21782178
else result = this
21792179
or
21802180
// [KNOWN_OR_UNKNOWN]
21812181
edgeName = "MGF1Hash" and
2182-
if exists(this.getMGF1HashAlgorithm())
2183-
then result = this.getMGF1HashAlgorithm()
2182+
if exists(this.getMgf1HashAlgorithm())
2183+
then result = this.getMgf1HashAlgorithm()
21842184
else result = this
21852185
}
21862186
}
21872187

2188-
class PSSPaddingAlgorithmNode extends PaddingAlgorithmNode {
2188+
class PssPaddingAlgorithmNode extends PaddingAlgorithmNode {
21892189
override PssPaddingAlgorithmInstance instance;
21902190

2191-
PSSPaddingAlgorithmNode() { this = TPaddingAlgorithm(instance) }
2191+
PssPaddingAlgorithmNode() { this = TPaddingAlgorithm(instance) }
21922192

2193-
HashAlgorithmNode getPSSHashAlgorithm() { result.asElement() = instance.getHashAlgorithm() }
2193+
HashAlgorithmNode getPssHashAlgorithm() { result.asElement() = instance.getHashAlgorithm() }
21942194

2195-
HashAlgorithmNode getMGF1HashAlgorithm() {
2195+
HashAlgorithmNode getMgf1HashAlgorithm() {
21962196
result.asElement() = instance.getMgf1HashAlgorithm()
21972197
}
21982198

@@ -2201,14 +2201,14 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
22012201
or
22022202
// [KNOWN_OR_UNKNOWN]
22032203
edgeName = "MD" and
2204-
if exists(this.getPSSHashAlgorithm())
2205-
then result = this.getPSSHashAlgorithm()
2204+
if exists(this.getPssHashAlgorithm())
2205+
then result = this.getPssHashAlgorithm()
22062206
else result = this
22072207
or
22082208
// [KNOWN_OR_UNKNOWN]
22092209
edgeName = "MGF1Hash" and
2210-
if exists(this.getMGF1HashAlgorithm())
2211-
then result = this.getMGF1HashAlgorithm()
2210+
if exists(this.getMgf1HashAlgorithm())
2211+
then result = this.getMgf1HashAlgorithm()
22122212
else result = this
22132213
}
22142214
}

0 commit comments

Comments
 (0)