-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathWeakBlockModes.ql
More file actions
32 lines (27 loc) · 992 Bytes
/
WeakBlockModes.ql
File metadata and controls
32 lines (27 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* @name Weak AES Block mode
* @id java/quantum/examples/weak-block-modes
* @description An AES cipher is in use with an insecure block mode
* @kind problem
* @problem.severity error
* @tags quantum
* experimental
*/
import java
import experimental.quantum.Language
class WeakAESBlockModeAlgNode extends Crypto::KeyOperationAlgorithmNode {
Crypto::ModeOfOperationAlgorithmNode mode;
WeakAESBlockModeAlgNode() {
this.getAlgorithmType() = Crypto::KeyOpAlg::TSymmetricCipher(Crypto::KeyOpAlg::AES()) and
mode = super.getModeOfOperation() and
(
mode.getModeType() = Crypto::KeyOpAlg::ECB() or
mode.getModeType() = Crypto::KeyOpAlg::CFB() or
mode.getModeType() = Crypto::KeyOpAlg::OFB() or
mode.getModeType() = Crypto::KeyOpAlg::CTR()
)
}
Crypto::ModeOfOperationAlgorithmNode getMode() { result = mode }
}
from WeakAESBlockModeAlgNode alg
select alg, "Weak AES block mode instance $@.", alg.getMode(), alg.getMode().toString()