@@ -16,6 +16,16 @@ abstract class EVP_Hash_Operation extends OpenSSLOperation, Crypto::HashOperatio
16
16
EVP_Hash_Initializer getInitCall ( ) {
17
17
CTXFlow:: ctxArgFlowsToCtxArg ( result .getContextArg ( ) , this .getContextArg ( ) )
18
18
}
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
+ }
19
29
}
20
30
21
31
private module AlgGetterToAlgConsumerConfig implements DataFlow:: ConfigSig {
@@ -88,30 +98,34 @@ class EVP_Digest_Operation extends EVP_Hash_Operation {
88
98
89
99
override Crypto:: ConsumerInputDataFlowNode getInputConsumer ( ) { result = this .getInputNode ( ) }
90
100
}
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
+ }
0 commit comments