@@ -60,6 +60,21 @@ class SigningNamedCurvePropertyAccess extends PropertyAccess {
6060 string getCurveName ( ) { result = curveName }
6161}
6262
63+ class HashAlgorithmNameType extends CryptographyType {
64+ HashAlgorithmNameType ( ) { this .hasName ( "HashAlgorithmName" ) }
65+ }
66+
67+ class HashAlgorithmName extends PropertyAccess {
68+ string algorithmName ;
69+
70+ HashAlgorithmName ( ) {
71+ this .getType ( ) instanceof HashAlgorithmNameType and
72+ this .getProperty ( ) .getName ( ) = algorithmName
73+ }
74+
75+ string getAlgorithmName ( ) { result = algorithmName }
76+ }
77+
6378/**
6479 * Private predicate mapping NIST names to SEC names and leaving all others the same.
6580 */
@@ -76,12 +91,12 @@ private predicate eccurveNameMapping(string nist, string secp) {
7691}
7792
7893// OPERATION INSTANCES
79- private class ECDsaClass extends Type {
80- ECDsaClass ( ) { this .hasFullyQualifiedName ( "System.Security.Cryptography" , "ECDsa" ) }
94+ private class ECDsaClass extends CryptographyType {
95+ ECDsaClass ( ) { this .hasName ( "ECDsa" ) }
8196}
8297
83- private class RSAClass extends Type {
84- RSAClass ( ) { this .hasFullyQualifiedName ( "System.Security.Cryptography" , "RSA" ) }
98+ private class RSAClass extends CryptographyType {
99+ RSAClass ( ) { this .hasName ( "RSA" ) }
85100}
86101
87102class ByteArrayType extends Type {
@@ -92,7 +107,7 @@ class ReadOnlyByteSpanType extends Type {
92107 ReadOnlyByteSpanType ( ) { this .getName ( ) = "ReadOnlySpan<Byte>" }
93108}
94109
95- abstract class DotNetSigner extends MethodCall {
110+ class DotNetSigner extends MethodCall {
96111 DotNetSigner ( ) { this .getTarget ( ) .getName ( ) .matches ( [ "Verify%" , "Sign%" ] ) }
97112
98113 Expr getMessageArg ( ) {
@@ -117,6 +132,11 @@ abstract class DotNetSigner extends MethodCall {
117132 result = this
118133 }
119134
135+ Expr getHashAlgorithmArg ( ) {
136+ // Get the hash algorithm argument if it has the correct type.
137+ result = this .getAnArgument ( ) and result .getType ( ) instanceof HashAlgorithmNameType
138+ }
139+
120140 predicate isSigner ( ) { this .getTarget ( ) .getName ( ) .matches ( "Sign%" ) }
121141
122142 predicate isVerifier ( ) { this .getTarget ( ) .getName ( ) .matches ( "Verify%" ) }
0 commit comments