-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathWeakHash.qll
More file actions
23 lines (22 loc) · 861 Bytes
/
WeakHash.qll
File metadata and controls
23 lines (22 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import experimental.quantum.Language
predicate isUnapprovedHash(Crypto::HashAlgorithmNode alg, Crypto::HashType htype, string msg) {
htype = alg.getHashType() and
(
(htype != Crypto::SHA2() and htype != Crypto::SHA3()) and
msg = "Use of unapproved hash algorithm or API: " + htype.toString() + "."
or
(htype = Crypto::SHA2() or htype = Crypto::SHA3()) and
not exists(alg.getDigestLength()) and
msg =
"Use of approved hash algorithm or API type " + htype.toString() + " but unknown digest size."
or
exists(int digestLength |
digestLength = alg.getDigestLength() and
(htype = Crypto::SHA2() or htype = Crypto::SHA3()) and
digestLength < 256 and
msg =
"Use of approved hash algorithm or API type " + htype.toString() + " but weak digest size ("
+ digestLength + ")."
)
)
}