Skip to content

Commit d690a34

Browse files
committed
quantum-c#: make type precise
1 parent 36213c5 commit d690a34

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

csharp/ql/lib/experimental/quantum/dotnet/Cryptography.qll

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,14 @@ private class RSAClass extends Type {
8484
RSAClass() { this.hasFullyQualifiedName("System.Security.Cryptography", "RSA") }
8585
}
8686

87-
// TODO
88-
// class ByteArrayTypeUnionReadOnlyByteSpan extends ArrayType {
89-
// ByteArrayTypeUnionReadOnlyByteSpan() {
90-
// this.hasFullyQualifiedName("System", "Byte[]") or
91-
// this.hasFullyQualifiedName("System", "ReadOnlySpan`1") or
92-
// }
93-
// }
87+
class ByteArrayType extends Type {
88+
ByteArrayType() { this.getName() = "Byte[]" }
89+
}
90+
91+
class ReadOnlyByteSpanType extends Type {
92+
ReadOnlyByteSpanType() { this.getName() = "ReadOnlySpan<Byte>" }
93+
}
94+
9495
abstract class DotNetSigner extends MethodCall {
9596
DotNetSigner() { this.getTarget().getName().matches(["Verify%", "Sign%"]) }
9697

@@ -102,8 +103,13 @@ abstract class DotNetSigner extends MethodCall {
102103

103104
Expr getSignatureArg() {
104105
this.isVerifier() and
105-
// TODO: Should replace getAChild* with the proper two types byte[] and ReadOnlySpan<byte>
106-
(result = this.getArgument([1, 3]) and result.getType().getAChild*() instanceof ByteType)
106+
(
107+
result = this.getArgument([1, 3]) and
108+
(
109+
result.getType() instanceof ByteArrayType or
110+
result.getType() instanceof ReadOnlyByteSpanType
111+
)
112+
)
107113
}
108114

109115
Expr getSignatureOutput() {

0 commit comments

Comments
 (0)