Skip to content

Commit ad86e57

Browse files
committed
autoformat
1 parent b683a3c commit ad86e57

38 files changed

+16192
-15602
lines changed
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
import experimental.cryptography.CryptoArtifact
22
import experimental.cryptography.CryptoAlgorithmNames
3-
43
import experimental.cryptography.modules.OpenSSL as OpenSSL
5-

cpp/ql/lib/experimental/cryptography/CryptoAlgorithmNames.qll

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,47 @@
1111
string unknownAlgorithm() { result = "UNKNOWN" }
1212

1313
string getHashType() { result = "HASH" }
14+
1415
string getSymmetricEncryptionType() { result = "SYMMETRIC_ENCRYPTION" }
16+
1517
string getAsymmetricEncryptionType() { result = "ASYMMETRIC_ENCRYPTION" }
18+
1619
string getKeyDerivationType() { result = "KEY_DERIVATION" }
20+
1721
string getCipherBlockModeType() { result = "BLOCK_MODE" }
22+
1823
string getSymmetricPaddingType() { result = "SYMMETRIC_PADDING" }
24+
1925
string getAsymmetricPaddingType() { result = "ASYMMETRIC_PADDING" }
26+
2027
string getEllipticCurveType() { result = "ELLIPTIC_CURVE" }
28+
2129
string getSignatureType() { result = "SIGNATURE" }
30+
2231
string getKeyExchangeType() { result = "KEY_EXCHANGE" }
2332

24-
string getAsymmetricType(){
25-
result in [getAsymmetricEncryptionType(), getSignatureType(), getKeyExchangeType(), getEllipticCurveType()]
33+
string getAsymmetricType() {
34+
result in [
35+
getAsymmetricEncryptionType(), getSignatureType(), getKeyExchangeType(),
36+
getEllipticCurveType()
37+
]
2638
}
2739

28-
predicate isKnownType(string algType){
40+
predicate isKnownType(string algType) {
2941
algType in [
30-
getHashType(), getSymmetricEncryptionType(), getAsymmetricEncryptionType(), getKeyDerivationType(),
31-
getCipherBlockModeType(), getSymmetricPaddingType(), getAsymmetricPaddingType(), getEllipticCurveType(),
32-
getSignatureType(), getKeyExchangeType()
33-
]
42+
getHashType(), getSymmetricEncryptionType(), getAsymmetricEncryptionType(),
43+
getKeyDerivationType(), getCipherBlockModeType(), getSymmetricPaddingType(),
44+
getAsymmetricPaddingType(), getEllipticCurveType(), getSignatureType(), getKeyExchangeType()
45+
]
3446
}
3547

36-
3748
predicate isKnownAlgorithm(string name) { isKnownAlgorithm(name, _) }
3849

3950
predicate isKnownAlgorithm(string name, string algType) {
4051
isHashingAlgorithm(name) and algType = "HASH"
4152
or
42-
isEncryptionAlgorithm(name, algType) and algType in ["SYMMETRIC_ENCRYPTION", "ASYMMETRIC_ENCRYPTION"]
53+
isEncryptionAlgorithm(name, algType) and
54+
algType in ["SYMMETRIC_ENCRYPTION", "ASYMMETRIC_ENCRYPTION"]
4355
or
4456
isKeyDerivationAlgorithm(name) and algType = "KEY_DERIVATION"
4557
or
@@ -60,11 +72,11 @@ predicate isKnownAlgorithm(string name, string algType) {
6072
predicate isHashingAlgorithm(string name) {
6173
name =
6274
[
63-
"BLAKE2", "BLAKE2B", "BLAKE2S",
64-
"SHA2", "SHA224", "SHA256", "SHA384", "SHA512", "SHA512224", "SHA512256",
65-
"SHA3", "SHA3224", "SHA3256", "SHA3384", "SHA3512", "SHAKE128", "SHAKE256", "SM3",
66-
"WHIRLPOOL", "POLY1305", "HAVEL128", "MD2", "MD4", "MD5", "PANAMA", "RIPEMD", "RIPEMD128",
67-
"RIPEMD256", "RIPEMD160", "RIPEMD320", "SHA0", "SHA1", "SHA", "MGF1","MGF1SHA1", "MDC2", "SIPHASH"
75+
"BLAKE2", "BLAKE2B", "BLAKE2S", "SHA2", "SHA224", "SHA256", "SHA384", "SHA512", "SHA512224",
76+
"SHA512256", "SHA3", "SHA3224", "SHA3256", "SHA3384", "SHA3512", "SHAKE128", "SHAKE256",
77+
"SM3", "WHIRLPOOL", "POLY1305", "HAVEL128", "MD2", "MD4", "MD5", "PANAMA", "RIPEMD",
78+
"RIPEMD128", "RIPEMD256", "RIPEMD160", "RIPEMD320", "SHA0", "SHA1", "SHA", "MGF1", "MGF1SHA1",
79+
"MDC2", "SIPHASH"
6880
]
6981
}
7082

@@ -86,10 +98,10 @@ predicate isSymmetricEncryptionAlgorithm(string name) {
8698
"AES", "AES128", "AES192", "AES256", "ARIA", "BLOWFISH", "BF", "ECIES", "CAST", "CAST5",
8799
"CAMELLIA", "CAMELLIA128", "CAMELLIA192", "CAMELLIA256", "CHACHA", "CHACHA20",
88100
"CHACHA20POLY1305", "GOST", "GOSTR34102001", "GOSTR341094", "GOSTR341194", "GOST2814789",
89-
"GOSTR341194", "GOST2814789", "GOST28147", "GOSTR341094", "GOST89", "GOST94", "GOST34102012",
90-
"GOST34112012", "IDEA", "RABBIT",
91-
"SEED", "SM4", "DES", "DESX", "3DES", "TDES", "2DES", "DES3", "TRIPLEDES", "TDEA", "TRIPLEDEA",
92-
"ARC2", "RC2", "ARC4", "RC4", "ARCFOUR", "ARC5", "RC5", "MAGMA", "KUZNYECHIK"
101+
"GOSTR341194", "GOST2814789", "GOST28147", "GOSTR341094", "GOST89", "GOST94", "GOST34102012",
102+
"GOST34112012", "IDEA", "RABBIT", "SEED", "SM4", "DES", "DESX", "3DES", "TDES", "2DES",
103+
"DES3", "TRIPLEDES", "TDEA", "TRIPLEDEA", "ARC2", "RC2", "ARC4", "RC4", "ARCFOUR", "ARC5",
104+
"RC5", "MAGMA", "KUZNYECHIK"
93105
]
94106
}
95107

@@ -201,20 +213,25 @@ predicate isEllipticCurveAlgorithm(string curveName, int keySize) {
201213
curveName = "NUMSP512T1" and keySize = 512
202214
or
203215
curveName = "SM2" and keySize in [256, 512]
204-
205216
}
206217

207218
/**
208219
* Holds if `name` corresponds to a known signature algorithm.
209220
*/
210-
predicate isSignatureAlgorithm(string name) {
211-
name = ["DSA", "ECDSA", "EDDSA", "ES256", "ES256K", "ES384", "ES512", "ED25519", "ED448", "ECDSA256", "ECDSA384", "ECDSA512"]
221+
predicate isSignatureAlgorithm(string name) {
222+
name =
223+
[
224+
"DSA", "ECDSA", "EDDSA", "ES256", "ES256K", "ES384", "ES512", "ED25519", "ED448", "ECDSA256",
225+
"ECDSA384", "ECDSA512"
226+
]
212227
}
213228

214229
/**
215230
* Holds if `name` is a key exchange algorithm.
216231
*/
217-
predicate isKeyExchangeAlgorithm(string name) { name = ["ECDH", "DH", "DIFFIEHELLMAN", "X25519", "X448"] }
232+
predicate isKeyExchangeAlgorithm(string name) {
233+
name = ["ECDH", "DH", "DIFFIEHELLMAN", "X25519", "X448"]
234+
}
218235

219236
/**
220237
* Holds if `name` corresponds to a known asymmetric encryption.

0 commit comments

Comments
 (0)