Skip to content

Commit 61ec2aa

Browse files
committed
Autoformat QL files
1 parent 24e5c4c commit 61ec2aa

File tree

7 files changed

+29
-56
lines changed

7 files changed

+29
-56
lines changed

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

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ module JCAModel {
2727
predicate cipher_names(string algo) {
2828
algo.toUpperCase()
2929
.matches([
30-
"AES", "AESWrap", "AESWrapPad", "ARCFOUR", "ARIA", "Blowfish", "Camellia",
31-
"ChaCha20", "ChaCha20-Poly1305", "DES", "DESede", "DESedeWrap", "ECIES",
32-
"PBEWith%", "RC2", "RC4", "RC5", "RSA", "Salsa20", "SEED", "Skipjack", "Idea",
33-
"Twofish"
30+
"AES", "AESWrap", "AESWrapPad", "ARCFOUR", "ARIA", "Blowfish", "Camellia", "ChaCha20",
31+
"ChaCha20-Poly1305", "DES", "DESede", "DESedeWrap", "ECIES", "PBEWith%", "RC2", "RC4",
32+
"RC5", "RSA", "Salsa20", "SEED", "Skipjack", "Idea", "Twofish"
3433
].toUpperCase())
3534
}
3635

@@ -204,7 +203,8 @@ module JCAModel {
204203
upper.matches("DESEDE%") and
205204
type = KeyOpAlg::TSymmetricCipher(KeyOpAlg::TRIPLE_DES())
206205
or
207-
not upper.matches("DESEDE%") and upper.matches("DES%") and
206+
not upper.matches("DESEDE%") and
207+
upper.matches("DES%") and
208208
type = KeyOpAlg::TSymmetricCipher(KeyOpAlg::DES())
209209
or
210210
upper = "TRIPLEDES" and
@@ -1879,9 +1879,7 @@ module JCAModel {
18791879

18801880
override Crypto::ModeOfOperationAlgorithmInstance getModeOfOperationAlgorithm() { none() }
18811881

1882-
override Crypto::PaddingAlgorithmInstance getPaddingAlgorithm() {
1883-
result = this
1884-
}
1882+
override Crypto::PaddingAlgorithmInstance getPaddingAlgorithm() { result = this }
18851883

18861884
override predicate shouldHaveModeOfOperation() { none() }
18871885

@@ -1984,24 +1982,16 @@ module JCAModel {
19841982
}
19851983

19861984
/** Gets the digest algorithm name argument (arg 0). */
1987-
Expr getDigestAlgorithmArg() {
1988-
result = this.getArgument(0)
1989-
}
1985+
Expr getDigestAlgorithmArg() { result = this.getArgument(0) }
19901986

19911987
/** Gets the MGF algorithm name argument (arg 1). */
1992-
Expr getMgfAlgorithmArg() {
1993-
result = this.getArgument(1)
1994-
}
1988+
Expr getMgfAlgorithmArg() { result = this.getArgument(1) }
19951989

19961990
/** Gets the salt length argument (arg 3). */
1997-
Expr getSaltLengthArg() {
1998-
result = this.getArgument(3)
1999-
}
1991+
Expr getSaltLengthArg() { result = this.getArgument(3) }
20001992

20011993
/** Gets the MGF parameter spec argument (arg 2), e.g., MGF1ParameterSpec.SHA256. */
2002-
Expr getMgfSpecArg() {
2003-
result = this.getArgument(2)
2004-
}
1994+
Expr getMgfSpecArg() { result = this.getArgument(2) }
20051995
}
20061996

20071997
/**
@@ -2011,9 +2001,7 @@ module JCAModel {
20112001
*/
20122002
class MGF1ParameterSpecFieldAccess extends FieldAccess {
20132003
MGF1ParameterSpecFieldAccess() {
2014-
this.getField()
2015-
.getDeclaringType()
2016-
.hasQualifiedName("java.security.spec", "MGF1ParameterSpec") and
2004+
this.getField().getDeclaringType().hasQualifiedName("java.security.spec", "MGF1ParameterSpec") and
20172005
this.getField().isStatic()
20182006
}
20192007

@@ -2042,8 +2030,7 @@ module JCAModel {
20422030
*
20432031
* Type resolution delegates to hash_name_to_type_known from Standardization.
20442032
*/
2045-
class PSSParameterSpecDigestHashAlgorithmInstance extends Crypto::HashAlgorithmInstance
2046-
instanceof JavaConstant
2033+
class PSSParameterSpecDigestHashAlgorithmInstance extends Crypto::HashAlgorithmInstance instanceof JavaConstant
20472034
{
20482035
PSSParameterSpecInstantiation spec;
20492036

@@ -2075,8 +2062,7 @@ module JCAModel {
20752062
* The field name is normalized to a standard hash algorithm name (e.g.,
20762063
* SHA256 -> SHA-256), then type resolution delegates to hash_name_to_type_known.
20772064
*/
2078-
class PSSParameterSpecMgf1HashAlgorithmInstance extends Crypto::HashAlgorithmInstance
2079-
instanceof MGF1ParameterSpecFieldAccess
2065+
class PSSParameterSpecMgf1HashAlgorithmInstance extends Crypto::HashAlgorithmInstance instanceof MGF1ParameterSpecFieldAccess
20802066
{
20812067
PSSParameterSpecInstantiation spec;
20822068
string normalizedName;
@@ -2093,13 +2079,9 @@ module JCAModel {
20932079

20942080
override string getRawHashAlgorithmName() { result = super.getField().getName() }
20952081

2096-
override Crypto::THashType getHashType() {
2097-
result = hash_name_to_type_known(normalizedName, _)
2098-
}
2082+
override Crypto::THashType getHashType() { result = hash_name_to_type_known(normalizedName, _) }
20992083

2100-
override int getFixedDigestLength() {
2101-
exists(hash_name_to_type_known(normalizedName, result))
2102-
}
2084+
override int getFixedDigestLength() { exists(hash_name_to_type_known(normalizedName, result)) }
21032085
}
21042086

21052087
class SignatureInitCall extends MethodCall {
@@ -2119,9 +2101,11 @@ module JCAModel {
21192101
*/
21202102
class SignatureSetParameterCall extends MethodCall {
21212103
SignatureSetParameterCall() {
2104+
this.getMethod().hasQualifiedName("java.security", "Signature", "setParameter") and
21222105
this.getMethod()
2123-
.hasQualifiedName("java.security", "Signature", "setParameter") and
2124-
this.getMethod().getParameterType(0).(RefType).hasQualifiedName("java.security.spec", "AlgorithmParameterSpec")
2106+
.getParameterType(0)
2107+
.(RefType)
2108+
.hasQualifiedName("java.security.spec", "AlgorithmParameterSpec")
21252109
}
21262110

21272111
/** Gets the AlgorithmParameterSpec argument. */
@@ -2236,9 +2220,7 @@ module JCAModel {
22362220
* Flow from `PSSParameterSpec` instantiation to `Signature.setParameter()` argument.
22372221
*/
22382222
module PSSSpecToSetParameterConfig implements DataFlow::ConfigSig {
2239-
predicate isSource(DataFlow::Node src) {
2240-
src.asExpr() instanceof PSSParameterSpecInstantiation
2241-
}
2223+
predicate isSource(DataFlow::Node src) { src.asExpr() instanceof PSSParameterSpecInstantiation }
22422224

22432225
predicate isSink(DataFlow::Node sink) {
22442226
exists(SignatureSetParameterCall c | sink.asExpr() = c.getParameterSpecArg())
@@ -2260,8 +2242,7 @@ module JCAModel {
22602242
PSSParameterSpecInstantiation spec, SignaturePssPaddingAlgorithmInstance literal
22612243
) {
22622244
exists(
2263-
SignatureSetParameterCall setParam,
2264-
SignatureGetInstanceCall getInstance,
2245+
SignatureSetParameterCall setParam, SignatureGetInstanceCall getInstance,
22652246
SignatureGetInstanceAlgorithmValueConsumer consumer
22662247
|
22672248
consumer = literal.getConsumer() and

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@ from Crypto::KeyCreationOperationNode keygen, Crypto::AlgorithmNode alg, int key
1414
where
1515
alg = keygen.getAKnownAlgorithm() and
1616
keygen.getAKeySizeSource().asElement().(Literal).getValue().toInt() = keySize
17-
select keygen,
18-
"Key creation with algorithm $@ using " + keySize.toString() + "-bit key.", alg,
17+
select keygen, "Key creation with algorithm $@ using " + keySize.toString() + "-bit key.", alg,
1918
alg.getAlgorithmName()

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

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

14-
from
15-
Crypto::KeyOperationAlgorithmNode alg, Crypto::OAEPPaddingAlgorithmNode pad
14+
from Crypto::KeyOperationAlgorithmNode alg, Crypto::OAEPPaddingAlgorithmNode pad
1615
where
1716
alg.getAlgorithmType() = KeyOpAlg::TAsymmetricCipher(KeyOpAlg::RSA()) and
1817
pad = alg.getPaddingAlgorithm()

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

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

14-
from
15-
Crypto::KeyOperationAlgorithmNode alg, Crypto::PSSPaddingAlgorithmNode pss
14+
from Crypto::KeyOperationAlgorithmNode alg, Crypto::PSSPaddingAlgorithmNode pss
1615
where
1716
alg.getAlgorithmType() = KeyOpAlg::TAsymmetricCipher(KeyOpAlg::RSA()) and
1817
pss = alg.getPaddingAlgorithm()

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ where
1515
exists(Crypto::KeyOperationAlgorithmNode keyAlg |
1616
keyAlg = alg and
1717
isQuantumVulnerableAlgorithmType(keyAlg.getAlgorithmType()) and
18-
msg =
19-
"Quantum-vulnerable key operation algorithm: " + keyAlg.getAlgorithmName() + "."
18+
msg = "Quantum-vulnerable key operation algorithm: " + keyAlg.getAlgorithmName() + "."
2019
)
2120
or
2221
exists(Crypto::KeyAgreementAlgorithmNode kaAlg |
2322
kaAlg = alg and
2423
isQuantumVulnerableKeyAgreementType(kaAlg.getKeyAgreementType()) and
25-
msg =
26-
"Quantum-vulnerable key agreement algorithm: " + kaAlg.getAlgorithmName() + "."
24+
msg = "Quantum-vulnerable key agreement algorithm: " + kaAlg.getAlgorithmName() + "."
2725
)
2826
select alg, msg

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ where
2323
kaAlg = alg and isQuantumVulnerableKeyAgreementType(kaAlg.getKeyAgreementType())
2424
)
2525
)
26-
select keygen,
27-
"Quantum-vulnerable key size (" + keySize.toString() + " bits) for algorithm $@.", alg,
28-
alg.getAlgorithmName()
26+
select keygen, "Quantum-vulnerable key size (" + keySize.toString() + " bits) for algorithm $@.",
27+
alg, alg.getAlgorithmName()

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2190,9 +2190,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
21902190

21912191
PSSPaddingAlgorithmNode() { this = TPaddingAlgorithm(instance) }
21922192

2193-
HashAlgorithmNode getPSSHashAlgorithm() {
2194-
result.asElement() = instance.getHashAlgorithm()
2195-
}
2193+
HashAlgorithmNode getPSSHashAlgorithm() { result.asElement() = instance.getHashAlgorithm() }
21962194

21972195
HashAlgorithmNode getMGF1HashAlgorithm() {
21982196
result.asElement() = instance.getMgf1HashAlgorithm()

0 commit comments

Comments
 (0)