11private import csharp
22private import experimental.quantum.Language
3+ private import FlowAnalysis
34
45class CryptographyType extends Type {
56 CryptographyType ( ) { this .hasFullyQualifiedName ( "System.Security.Cryptography" , _) }
@@ -190,6 +191,13 @@ class ReadOnlyByteSpanType extends Type {
190191 ReadOnlyByteSpanType ( ) { this .getName ( ) = "ReadOnlySpan<Byte>" }
191192}
192193
194+ class ByteArrayOrReadOnlyByteSpanType extends Type {
195+ ByteArrayOrReadOnlyByteSpanType ( ) {
196+ this instanceof ByteArrayType or
197+ this instanceof ReadOnlyByteSpanType
198+ }
199+ }
200+
193201class HashUse extends MethodCall {
194202 HashUse ( ) {
195203 this .getQualifier ( ) .getType ( ) instanceof HashAlgorithmType and
@@ -217,9 +225,13 @@ class HashUse extends MethodCall {
217225 else result = this
218226 }
219227
220- Expr getInputConsumer ( ) {
221- not this .getTarget ( ) . getName ( ) = "HashFinal" and result = this . getArgument ( 0 )
228+ Expr getInputArg ( ) {
229+ result = this .getAnArgument ( ) and result . getType ( ) instanceof ByteArrayOrReadOnlyByteSpanType
222230 }
231+ // Expr getStreamArg() {
232+ // result = this.getAnArgument() and
233+ // result.getType() instanceof Stream
234+ // }
223235}
224236
225237class SignerUse extends MethodCall {
@@ -238,10 +250,7 @@ class SignerUse extends MethodCall {
238250 this .isVerifier ( ) and
239251 (
240252 result = this .getArgument ( [ 1 , 3 ] ) and
241- (
242- result .getType ( ) instanceof ByteArrayType or
243- result .getType ( ) instanceof ReadOnlyByteSpanType
244- )
253+ result .getType ( ) instanceof ByteArrayOrReadOnlyByteSpanType
245254 )
246255 }
247256
0 commit comments