Skip to content

Commit 036035b

Browse files
committed
Adding modeling for OpenSSL random number generation.
1 parent fe52351 commit 036035b

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

cpp/ql/lib/experimental/Quantum/OpenSSL/OpenSSL.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module OpenSSLModel {
77
import experimental.Quantum.OpenSSL.EVPHashOperation
88
import experimental.Quantum.OpenSSL.EVPCipherAlgorithmSource
99
import experimental.Quantum.OpenSSL.EVPHashAlgorithmSource
10+
import experimental.Quantum.OpenSSL.Random
1011

1112

1213
// // TODO: trace CTX from init variants to the context arg of EVP update calls
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import cpp
2+
private import experimental.Quantum.Language
3+
private import codeql.cryptography.Model
4+
private import LibraryDetector
5+
private import semmle.code.cpp.dataflow.new.DataFlow
6+
7+
class OpenSSLRandomNumberGeneratorInstance extends Crypto::RandomNumberGenerationInstance instanceof Call
8+
{
9+
OpenSSLRandomNumberGeneratorInstance() {
10+
this.(Call).getTarget().getName() in ["RAND_bytes", "RAND_pseudo_bytes"] and
11+
isPossibleOpenSSLFunction(this.(Call).getTarget())
12+
}
13+
14+
override Crypto::DataFlowNode getOutputNode() {
15+
result.asDefiningArgument() = this.(Call).getArgument(0)
16+
}
17+
18+
override predicate flowsTo(Crypto::FlowAwareElement other) {
19+
ArtifactUniversalFlow::flow(this.getOutputNode(), other.getInputNode())
20+
}
21+
}

0 commit comments

Comments
 (0)