Skip to content

Commit 55119cf

Browse files
authored
Merge branch 'main' into openssl_elliptic_curve_algorithm_instances_and_consumers
2 parents 4309499 + 8780399 commit 55119cf

File tree

4 files changed

+48
-33
lines changed

4 files changed

+48
-33
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ module OpenSSLModel {
66
import experimental.quantum.OpenSSL.AlgorithmInstances.OpenSSLAlgorithmInstances
77
import experimental.quantum.OpenSSL.AlgorithmValueConsumers.OpenSSLAlgorithmValueConsumers
88
import experimental.quantum.OpenSSL.Operations.OpenSSLOperations
9+
import experimental.quantum.OpenSSL.Random
910
}

cpp/ql/lib/experimental/quantum/OpenSSL/Operations/EVPCipherOperation.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class EVP_Cipher_Call extends EVP_Cipher_Operation {
7474
}
7575

7676
// NOTE: not modeled as cipher operations, these are intermediate calls
77-
class EVP_Update_Call extends Call {
78-
EVP_Update_Call() {
77+
class EVP_Cipher_Update_Call extends Call {
78+
EVP_Cipher_Update_Call() {
7979
this.(Call).getTarget().getName() in [
8080
"EVP_EncryptUpdate", "EVP_DecryptUpdate", "EVP_CipherUpdate"
8181
]
@@ -88,15 +88,15 @@ class EVP_Update_Call extends Call {
8888
Expr getContextArg() { result = this.(Call).getArgument(0) }
8989
}
9090

91-
class EVP_Final_Call extends EVP_Cipher_Operation {
92-
EVP_Final_Call() {
91+
class EVP_Cipher_Final_Call extends EVP_Cipher_Operation {
92+
EVP_Cipher_Final_Call() {
9393
this.(Call).getTarget().getName() in [
9494
"EVP_EncryptFinal_ex", "EVP_DecryptFinal_ex", "EVP_CipherFinal_ex", "EVP_EncryptFinal",
9595
"EVP_DecryptFinal", "EVP_CipherFinal"
9696
]
9797
}
9898

99-
EVP_Update_Call getUpdateCalls() {
99+
EVP_Cipher_Update_Call getUpdateCalls() {
100100
CTXFlow::ctxArgFlowsToCtxArg(result.getContextArg(), this.getContextArg())
101101
}
102102

cpp/ql/lib/experimental/quantum/OpenSSL/Operations/EVPHashOperation.qll

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ abstract class EVP_Hash_Operation extends OpenSSLOperation, Crypto::HashOperatio
1616
EVP_Hash_Initializer getInitCall() {
1717
CTXFlow::ctxArgFlowsToCtxArg(result.getContextArg(), this.getContextArg())
1818
}
19+
20+
/**
21+
* By default, the algorithm value comes from the init call.
22+
* There are variants where this isn't true, in which case the
23+
* subclass should override this method.
24+
*/
25+
override Crypto::AlgorithmValueConsumer getAnAlgorithmValueConsumer() {
26+
AlgGetterToAlgConsumerFlow::flow(result.(OpenSSLAlgorithmValueConsumer).getResultNode(),
27+
DataFlow::exprNode(this.getInitCall().getAlgorithmArg()))
28+
}
1929
}
2030

2131
private module AlgGetterToAlgConsumerConfig implements DataFlow::ConfigSig {
@@ -88,30 +98,34 @@ class EVP_Digest_Operation extends EVP_Hash_Operation {
8898

8999
override Crypto::ConsumerInputDataFlowNode getInputConsumer() { result = this.getInputNode() }
90100
}
91-
// // override Crypto::AlgorithmValueConsumer getAnAlgorithmValueConsumer() {
92-
// // AlgGetterToAlgConsumerFlow::flow(result.(OpenSSLAlgorithmValueConsumer).getResultNode(),
93-
// // DataFlow::exprNode(this.getInitCall().getAlgorithmArg()))
94-
// // }
95-
// // ***** TODO *** complete modelinlg for hash operations, but have consideration for terminal and non-terminal (non intermedaite) steps
96-
// // see the JCA. May need to update the cipher operations similarly
97-
// // ALSO SEE cipher for how we currently model initialization of the algorithm through an init call
98-
// class EVP_DigestUpdate_Operation extends EVP_Hash_Operation {
99-
// EVP_DigestUpdate_Operation() {
100-
// this.(Call).getTarget().getName() = "EVP_DigestUpdate" and
101-
// isPossibleOpenSSLFunction(this.(Call).getTarget())
102-
// }
103-
// override Crypto::AlgorithmConsumer getAlgorithmConsumer() {
104-
// this.getInitCall().getAlgorithmArg() = result
105-
// }
106-
// }
107-
// class EVP_DigestFinal_Variants_Operation extends EVP_Hash_Operation {
108-
// EVP_DigestFinal_Variants_Operation() {
109-
// this.(Call).getTarget().getName() in [
110-
// "EVP_DigestFinal", "EVP_DigestFinal_ex", "EVP_DigestFinalXOF"
111-
// ] and
112-
// isPossibleOpenSSLFunction(this.(Call).getTarget())
113-
// }
114-
// override Crypto::AlgorithmConsumer getAlgorithmConsumer() {
115-
// this.getInitCall().getAlgorithmArg() = result
116-
// }
117-
// }
101+
102+
// NOTE: not modeled as hash operations, these are intermediate calls
103+
class EVP_Digest_Update_Call extends Call {
104+
EVP_Digest_Update_Call() { this.(Call).getTarget().getName() in ["EVP_DigestUpdate"] }
105+
106+
Expr getInputArg() { result = this.(Call).getArgument(1) }
107+
108+
DataFlow::Node getInputNode() { result.asExpr() = this.getInputArg() }
109+
110+
Expr getContextArg() { result = this.(Call).getArgument(0) }
111+
}
112+
113+
class EVP_Digest_Final_Call extends EVP_Hash_Operation {
114+
EVP_Digest_Final_Call() {
115+
this.(Call).getTarget().getName() in [
116+
"EVP_DigestFinal", "EVP_DigestFinal_ex", "EVP_DigestFinalXOF"
117+
]
118+
}
119+
120+
EVP_Digest_Update_Call getUpdateCalls() {
121+
CTXFlow::ctxArgFlowsToCtxArg(result.getContextArg(), this.getContextArg())
122+
}
123+
124+
override Expr getInputArg() { result = this.getUpdateCalls().getInputArg() }
125+
126+
override Crypto::ConsumerInputDataFlowNode getInputConsumer() { result = this.getInputNode() }
127+
128+
override Expr getOutputArg() { result = this.(Call).getArgument(1) }
129+
130+
override Crypto::ArtifactOutputDataFlowNode getOutputArtifact() { result = this.getOutputNode() }
131+
}

docs/codeql/reusables/supported-versions-compilers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
JavaScript,ECMAScript 2022 or lower,Not applicable,"``.js``, ``.jsx``, ``.mjs``, ``.es``, ``.es6``, ``.htm``, ``.html``, ``.xhtm``, ``.xhtml``, ``.vue``, ``.hbs``, ``.ejs``, ``.njk``, ``.json``, ``.yaml``, ``.yml``, ``.raml``, ``.xml`` [8]_"
2626
Python [9]_,"2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13",Not applicable,``.py``
2727
Ruby [10]_,"up to 3.3",Not applicable,"``.rb``, ``.erb``, ``.gemspec``, ``Gemfile``"
28-
Swift [11]_,"Swift 5.4-6.0","Swift compiler","``.swift``"
28+
Swift [11]_,"Swift 5.4-6.1","Swift compiler","``.swift``"
2929
TypeScript [12]_,"2.6-5.8",Standard TypeScript compiler,"``.ts``, ``.tsx``, ``.mts``, ``.cts``"
3030

3131
.. container:: footnote-group

0 commit comments

Comments
 (0)