Skip to content

Commit a46bd4c

Browse files
committed
Crypto: JCA random number generation model.
1 parent 507174e commit a46bd4c

File tree

1 file changed

+15
-0
lines changed
  • java/ql/lib/experimental/quantum

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,21 @@ module JCAModel {
10471047
}
10481048
}
10491049

1050+
/**
1051+
* An instance of `java.security.SecureRandom.nextBytes(byte[])` call.
1052+
* This is already generally modeled for Java in CodeQL, but
1053+
* we model it again as part of the crypto API model to have a cohesive model.
1054+
*/
1055+
class JavaSecuritySecureRandom extends Crypto::RandomNumberGenerationInstance instanceof Call {
1056+
JavaSecuritySecureRandom() {
1057+
this.getCallee().hasQualifiedName("java.security", "SecureRandom", "nextBytes")
1058+
}
1059+
1060+
override Crypto::DataFlowNode getOutputNode() { result.asExpr() = this.(Call).getArgument(0) }
1061+
1062+
override string getGeneratorName() { result = this.(Call).getCallee().getName() }
1063+
}
1064+
10501065
class KeyGeneratorGenerateCall extends Crypto::KeyGenerationOperationInstance instanceof MethodCall
10511066
{
10521067
Crypto::KeyArtifactType type;

0 commit comments

Comments
 (0)