@@ -67,37 +67,42 @@ abstract class EVP_Cipher_Operation extends OpenSSLOperation, Crypto::KeyOperati
6767 }
6868}
6969
70- // abstract class EVP_Update_Call extends EVP_Cipher_Operation { }
71- abstract class EVP_Final_Call extends EVP_Cipher_Operation {
72- override Expr getInputArg ( ) { none ( ) }
73- }
74-
75- // TODO: only model Final (model final as operation and model update but not as an operation)
76- // Updates are multiple input consumers (most important)
77- // TODO: assuming update doesn't ouput, otherwise it outputs artifacts, but is not an operation
7870class EVP_Cipher_Call extends EVP_Cipher_Operation {
7971 EVP_Cipher_Call ( ) { this .( Call ) .getTarget ( ) .getName ( ) = "EVP_Cipher" }
8072
8173 override Expr getInputArg ( ) { result = this .( Call ) .getArgument ( 2 ) }
8274}
8375
84- // ******* TODO: model UPDATE but not as the core operation, rather a step towards final
85- // see the JCA
86- // class EVP_Encrypt_Decrypt_or_Cipher_Update_Call extends EVP_Update_Call {
87- // EVP_Encrypt_Decrypt_or_Cipher_Update_Call() {
88- // this.(Call).getTarget().getName() in [
89- // "EVP_EncryptUpdate", "EVP_DecryptUpdate", "EVP_CipherUpdate"
90- // ]
91- // }
92- // override Expr getInputArg() { result = this.(Call).getArgument(3) }
93- // }
94- class EVP_Encrypt_Decrypt_or_Cipher_Final_Call extends EVP_Final_Call {
95- EVP_Encrypt_Decrypt_or_Cipher_Final_Call ( ) {
76+ // NOTE: not modeled as cipher operations, these are intermediate calls
77+ class EVP_Update_Call extends Call {
78+ EVP_Update_Call ( ) {
79+ this .( Call ) .getTarget ( ) .getName ( ) in [
80+ "EVP_EncryptUpdate" , "EVP_DecryptUpdate" , "EVP_CipherUpdate"
81+ ]
82+ }
83+
84+ Expr getInputArg ( ) { result = this .( Call ) .getArgument ( 3 ) }
85+
86+ DataFlow:: Node getInputNode ( ) { result .asExpr ( ) = this .getInputArg ( ) }
87+
88+ Expr getContextArg ( ) { result = this .( Call ) .getArgument ( 0 ) }
89+ }
90+
91+ class EVP_Final_Call extends EVP_Cipher_Operation {
92+ EVP_Final_Call ( ) {
9693 this .( Call ) .getTarget ( ) .getName ( ) in [
9794 "EVP_EncryptFinal_ex" , "EVP_DecryptFinal_ex" , "EVP_CipherFinal_ex" , "EVP_EncryptFinal" ,
9895 "EVP_DecryptFinal" , "EVP_CipherFinal"
9996 ]
10097 }
98+
99+ EVP_Update_Call getUpdateCalls ( ) {
100+ CTXFlow:: ctxArgFlowsToCtxArg ( result .getContextArg ( ) , this .getContextArg ( ) )
101+ }
102+
103+ override Expr getInputArg ( ) { result = this .getUpdateCalls ( ) .getInputArg ( ) }
104+
105+ override Crypto:: ConsumerInputDataFlowNode getInputConsumer ( ) { result = this .getInputNode ( ) }
101106}
102107
103108class EVP_PKEY_Operation extends EVP_Cipher_Operation {
0 commit comments