Skip to content

Commit 55bbcee

Browse files
committed
Crypto: Make WeakAsymmetricKeyGenSize a path problem.
1 parent 7e8acd7 commit 55bbcee

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

java/ql/src/experimental/quantum/Examples/WeakAsymmetricKeyGenSize.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ where
5959
// Also note the algorithm may also be re-specified at a use of the key
6060
alg = keygen.getAKnownAlgorithm() and
6161
not alg instanceof Crypto::EllipticCurveNode and // Elliptic curve sizes are handled separately and are more tied directly to the algorithm
62+
not alg.(Crypto::KeyAgreementAlgorithmNode).getKeyAgreementType() = Crypto::ECDH() and // ECDH key sizes should be handled with elliptic curves
6263
alg instanceof Crypto::AsymmetricAlgorithmNode and
6364
keySize < 2048 and
6465
srcNode.getNode().asExpr() = keygen.getAKeySizeSource().asElement() and
65-
sinkNode.getNode() = keygen.getKeySizeConsumer().getConsumer().getInputNode()
66+
sinkNode.getNode() = keygen.getKeySizeConsumer().getConsumer().getInputNode() and
67+
KeySizeFlow::flowPath(srcNode, sinkNode)
6668
select sinkNode, srcNode, sinkNode,
6769
"Use of weak asymmetric key size (" + keySize.toString() + " bits) for algorithm $@", alg,
6870
alg.getAlgorithmName()

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,8 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
17121712
}
17131713

17141714
override string getAlgorithmName() { result = this.getRawAlgorithmName() } // TODO: standardize?
1715+
1716+
KeyAgreementType getKeyAgreementType() { result = instance.asAlg().getKeyAgreementType() }
17151717
}
17161718

17171719
class KeyGenerationOperationNode extends KeyCreationOperationNode {

0 commit comments

Comments
 (0)