@@ -140,7 +140,13 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
140140 /**
141141 * An element that represents a _known_ cryptographic algorithm.
142142 */
143- abstract class AlgorithmElement extends KnownElement { }
143+ abstract class AlgorithmElement extends KnownElement {
144+ /**
145+ * Gets the raw name as it appears in source, e.g., "AES/CBC/PKCS7Padding".
146+ * This name is not parsed or formatted.
147+ */
148+ abstract string getRawAlgorithmName ( ) ;
149+ }
144150
145151 /**
146152 * An element that represents a _known_ cryptographic artifact.
@@ -286,12 +292,6 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
286292 }
287293
288294 abstract class CipherAlgorithmInstance extends AlgorithmElement {
289- /**
290- * Gets the raw name as it appears in source, e.g., "AES/CBC/PKCS7Padding".
291- * This name is not parsed or formatted.
292- */
293- abstract string getRawAlgorithmName ( ) ;
294-
295295 /**
296296 * Gets the type of this cipher, e.g., "AES" or "ChaCha20".
297297 */
@@ -358,7 +358,12 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
358358
359359 abstract class HashOperationInstance extends KnownElement { }
360360
361- abstract class HashAlgorithmInstance extends KnownElement { }
361+ abstract class HashAlgorithmInstance extends AlgorithmElement {
362+ /**
363+ * Gets the type of this digest algorithm, e.g., "SHA1", "SHA2", "MD5" etc.
364+ */
365+ abstract THashType getHashFamily ( ) ;
366+ }
362367
363368 abstract class KeyDerivationOperationInstance extends KnownElement { }
364369
@@ -875,15 +880,15 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
875880 IDEA ( ) or
876881 KUZNYECHIK ( ) or
877882 MAGMA ( ) or
878- TRIPLEDES ( ) or
879- DOUBLEDES ( ) or
883+ TripleDES ( ) or
884+ DoubleDES ( ) or
880885 RC2 ( ) or
881886 RC4 ( ) or
882887 RC5 ( ) or
883888 RSA ( ) or
884889 SEED ( ) or
885890 SM4 ( ) or
886- OTHERCIPHERTYPE ( )
891+ OtherCipherType ( )
887892
888893 final class CipherAlgorithmNode extends AlgorithmNode , TCipherAlgorithm {
889894 CipherAlgorithmInstance instance ;
@@ -932,27 +937,47 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
932937 final private predicate cipherFamilyToNameAndStructure (
933938 TCipherType type , string name , TCipherStructureType s
934939 ) {
935- type instanceof AES and name = "AES" and s = Block ( ) or
936- type instanceof ARIA and name = "ARIA" and s = Block ( ) or
937- type instanceof BLOWFISH and name = "Blowfish" and s = Block ( ) or
938- type instanceof CAMELLIA and name = "Camellia" and s = Block ( ) or
939- type instanceof CAST5 and name = "CAST5" and s = Block ( ) or
940- type instanceof CHACHA20 and name = "ChaCha20" and s = Stream ( ) or
941- type instanceof DES and name = "DES" and s = Block ( ) or
942- type instanceof DESX and name = "DESX" and s = Block ( ) or
943- type instanceof GOST and name = "GOST" and s = Block ( ) or
944- type instanceof IDEA and name = "IDEA" and s = Block ( ) or
945- type instanceof KUZNYECHIK and name = "Kuznyechik" and s = Block ( ) or
946- type instanceof MAGMA and name = "Magma" and s = Block ( ) or
947- type instanceof TRIPLEDES and name = "TripleDES" and s = Block ( ) or
948- type instanceof DOUBLEDES and name = "DoubleDES" and s = Block ( ) or
949- type instanceof RC2 and name = "RC2" and s = Block ( ) or
950- type instanceof RC4 and name = "RC4" and s = Stream ( ) or
951- type instanceof RC5 and name = "RC5" and s = Block ( ) or
952- type instanceof RSA and name = "RSA" and s = Asymmetric ( ) or
953- type instanceof SEED and name = "SEED" and s = Block ( ) or
954- type instanceof SM4 and name = "SM4" and s = Block ( ) or
955- type instanceof OTHERCIPHERTYPE and
940+ type instanceof AES and name = "AES" and s = Block ( )
941+ or
942+ type instanceof ARIA and name = "ARIA" and s = Block ( )
943+ or
944+ type instanceof BLOWFISH and name = "Blowfish" and s = Block ( )
945+ or
946+ type instanceof CAMELLIA and name = "Camellia" and s = Block ( )
947+ or
948+ type instanceof CAST5 and name = "CAST5" and s = Block ( )
949+ or
950+ type instanceof CHACHA20 and name = "ChaCha20" and s = Stream ( )
951+ or
952+ type instanceof DES and name = "DES" and s = Block ( )
953+ or
954+ type instanceof DESX and name = "DESX" and s = Block ( )
955+ or
956+ type instanceof GOST and name = "GOST" and s = Block ( )
957+ or
958+ type instanceof IDEA and name = "IDEA" and s = Block ( )
959+ or
960+ type instanceof KUZNYECHIK and name = "Kuznyechik" and s = Block ( )
961+ or
962+ type instanceof MAGMA and name = "Magma" and s = Block ( )
963+ or
964+ type instanceof TripleDES and name = "TripleDES" and s = Block ( )
965+ or
966+ type instanceof DoubleDES and name = "DoubleDES" and s = Block ( )
967+ or
968+ type instanceof RC2 and name = "RC2" and s = Block ( )
969+ or
970+ type instanceof RC4 and name = "RC4" and s = Stream ( )
971+ or
972+ type instanceof RC5 and name = "RC5" and s = Block ( )
973+ or
974+ type instanceof RSA and name = "RSA" and s = Asymmetric ( )
975+ or
976+ type instanceof SEED and name = "SEED" and s = Block ( )
977+ or
978+ type instanceof SM4 and name = "SM4" and s = Block ( )
979+ or
980+ type instanceof OtherCipherType and
956981 name = this .getRawAlgorithmName ( ) and
957982 s = UnknownCipherStructureType ( )
958983 }
@@ -1004,13 +1029,18 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
10041029 }
10051030
10061031 newtype THashType =
1032+ BLAKE2B ( ) or
1033+ BLAKE2S ( ) or
1034+ RIPEMD160 ( ) or
10071035 MD2 ( ) or
10081036 MD4 ( ) or
10091037 MD5 ( ) or
1038+ POLY1305 ( ) or
10101039 SHA1 ( ) or
10111040 SHA2 ( ) or
10121041 SHA3 ( ) or
1013- RIPEMD160 ( ) or
1042+ SHAKE ( ) or
1043+ SM3 ( ) or
10141044 WHIRLPOOL ( ) or
10151045 OtherHashType ( )
10161046
@@ -1021,19 +1051,29 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
10211051 override string getInternalType ( ) { result = "HashAlgorithm" }
10221052
10231053 final predicate hashTypeToNameMapping ( THashType type , string name ) {
1054+ type instanceof BLAKE2B and name = "BLAKE2B"
1055+ or
1056+ type instanceof BLAKE2S and name = "BLAKE2S"
1057+ or
1058+ type instanceof RIPEMD160 and name = "RIPEMD160"
1059+ or
10241060 type instanceof MD2 and name = "MD2"
10251061 or
10261062 type instanceof MD4 and name = "MD4"
10271063 or
10281064 type instanceof MD5 and name = "MD5"
10291065 or
1066+ type instanceof POLY1305 and name = "POLY1305"
1067+ or
10301068 type instanceof SHA1 and name = "SHA1"
10311069 or
10321070 type instanceof SHA2 and name = "SHA2"
10331071 or
10341072 type instanceof SHA3 and name = "SHA3"
10351073 or
1036- type instanceof RIPEMD160 and name = "RIPEMD160"
1074+ type instanceof SHAKE and name = "SHAKE"
1075+ or
1076+ type instanceof SM3 and name = "SM3"
10371077 or
10381078 type instanceof WHIRLPOOL and name = "WHIRLPOOL"
10391079 or
0 commit comments