@@ -12,6 +12,8 @@ private import experimental.quantum.OpenSSL.AlgorithmValueConsumers.OpenSSLAlgor
1212abstract class EVP_Hash_Operation extends OpenSSLOperation , Crypto:: HashOperationInstance {
1313 Expr getContextArg ( ) { result = this .( Call ) .getArgument ( 0 ) }
1414
15+ Expr getAlgorithmArg ( ) { result = this .getInitCall ( ) .getAlgorithmArg ( ) }
16+
1517 EVP_Hash_Initializer getInitCall ( ) {
1618 CTXFlow:: ctxArgFlowsToCtxArg ( result .getContextArg ( ) , this .getContextArg ( ) )
1719 }
@@ -23,7 +25,7 @@ abstract class EVP_Hash_Operation extends OpenSSLOperation, Crypto::HashOperatio
2325 */
2426 override Crypto:: AlgorithmValueConsumer getAnAlgorithmValueConsumer ( ) {
2527 AlgGetterToAlgConsumerFlow:: flow ( result .( OpenSSLAlgorithmValueConsumer ) .getResultNode ( ) ,
26- DataFlow:: exprNode ( this .getInitCall ( ) . getAlgorithmArg ( ) ) )
28+ DataFlow:: exprNode ( this .getAlgorithmArg ( ) ) )
2729 }
2830}
2931
@@ -33,7 +35,7 @@ private module AlgGetterToAlgConsumerConfig implements DataFlow::ConfigSig {
3335 }
3436
3537 predicate isSink ( DataFlow:: Node sink ) {
36- exists ( EVP_Hash_Operation c | c .getInitCall ( ) . getAlgorithmArg ( ) = sink .asExpr ( ) )
38+ exists ( EVP_Hash_Operation c | c .getAlgorithmArg ( ) = sink .asExpr ( ) )
3739 }
3840}
3941
@@ -64,6 +66,8 @@ class EVP_Q_Digest_Operation extends EVP_Hash_Operation {
6466 // simply return 'this', see modeled hash algorithm consuers for EVP_Q_Digest
6567 this = result
6668 }
69+
70+ override Expr getAlgorithmArg ( ) { result = this .( Call ) .getArgument ( 1 ) }
6771}
6872
6973class EVP_Digest_Operation extends EVP_Hash_Operation {
@@ -72,17 +76,14 @@ class EVP_Digest_Operation extends EVP_Hash_Operation {
7276 // There is no context argument for this function
7377 override Expr getContextArg ( ) { none ( ) }
7478
75- override Crypto:: AlgorithmValueConsumer getAnAlgorithmValueConsumer ( ) {
76- AlgGetterToAlgConsumerFlow:: flow ( result .( OpenSSLAlgorithmValueConsumer ) .getResultNode ( ) ,
77- DataFlow:: exprNode ( this .( Call ) .getArgument ( 4 ) ) )
78- }
79-
8079 override EVP_Hash_Initializer getInitCall ( ) {
8180 // This variant of digest does not use an init
8281 // and even if it were used, the init would be ignored/undefined
8382 none ( )
8483 }
8584
85+ override Expr getAlgorithmArg ( ) { result = this .( Call ) .getArgument ( 4 ) }
86+
8687 override Expr getOutputArg ( ) { result = this .( Call ) .getArgument ( 2 ) }
8788
8889 override Expr getInputArg ( ) { result = this .( Call ) .getArgument ( 0 ) }
0 commit comments