@@ -5,7 +5,7 @@ import semmle.code.java.controlflow.Dominance
55
66module JCAModel {
77 import Language
8- import Crypto :: KeyOpAlg as KeyOpAlg
8+ import codeql.quantum.experimental.Standardization :: Types :: KeyOpAlg as KeyOpAlg
99
1010 abstract class CipherAlgorithmValueConsumer extends Crypto:: AlgorithmValueConsumer { }
1111
@@ -115,7 +115,7 @@ module JCAModel {
115115 }
116116
117117 bindingset [ name]
118- Crypto:: THashType hash_name_to_type_known ( string name , int digestLength ) {
118+ Crypto:: HashType hash_name_to_type_known ( string name , int digestLength ) {
119119 name = "SHA-1" and result instanceof Crypto:: SHA1 and digestLength = 160
120120 or
121121 name = [ "SHA-256" , "SHA-384" , "SHA-512" ] and
@@ -152,24 +152,22 @@ module JCAModel {
152152 }
153153
154154 bindingset [ name]
155- private predicate mode_name_to_type_known (
156- Crypto:: TBlockCipherModeOfOperationType type , string name
157- ) {
158- type = Crypto:: ECB ( ) and name = "ECB"
155+ private predicate mode_name_to_type_known ( KeyOpAlg:: ModeOfOperationType type , string name ) {
156+ type = KeyOpAlg:: ECB ( ) and name = "ECB"
159157 or
160- type = Crypto :: CBC ( ) and name = "CBC"
158+ type = KeyOpAlg :: CBC ( ) and name = "CBC"
161159 or
162- type = Crypto :: GCM ( ) and name = "GCM"
160+ type = KeyOpAlg :: GCM ( ) and name = "GCM"
163161 or
164- type = Crypto :: CTR ( ) and name = "CTR"
162+ type = KeyOpAlg :: CTR ( ) and name = "CTR"
165163 or
166- type = Crypto :: XTS ( ) and name = "XTS"
164+ type = KeyOpAlg :: XTS ( ) and name = "XTS"
167165 or
168- type = Crypto :: CCM ( ) and name = "CCM"
166+ type = KeyOpAlg :: CCM ( ) and name = "CCM"
169167 or
170- type = Crypto :: SIV ( ) and name = "SIV"
168+ type = KeyOpAlg :: SIV ( ) and name = "SIV"
171169 or
172- type = Crypto :: OCB ( ) and name = "OCB"
170+ type = KeyOpAlg :: OCB ( ) and name = "OCB"
173171 }
174172
175173 bindingset [ name]
@@ -206,7 +204,7 @@ module JCAModel {
206204
207205 bindingset [ name]
208206 predicate mac_name_to_mac_type_known ( Crypto:: TMacType type , string name ) {
209- type = Crypto:: THMAC ( ) and
207+ type = Crypto:: HMAC ( ) and
210208 name .toUpperCase ( ) .matches ( "HMAC%" )
211209 }
212210
@@ -298,18 +296,18 @@ module JCAModel {
298296 override string getRawPaddingAlgorithmName ( ) { result = super .getPadding ( ) }
299297
300298 bindingset [ name]
301- private predicate paddingToNameMappingKnown ( Crypto :: TPaddingType type , string name ) {
302- type instanceof Crypto :: NoPadding and name = "NOPADDING"
299+ private predicate paddingToNameMappingKnown ( KeyOpAlg :: PaddingSchemeType type , string name ) {
300+ type instanceof KeyOpAlg :: NoPadding and name = "NOPADDING"
303301 or
304- type instanceof Crypto :: PKCS7 and name = [ "PKCS5Padding" , "PKCS7Padding" ] // TODO: misnomer in the JCA?
302+ type instanceof KeyOpAlg :: PKCS7 and name = [ "PKCS5Padding" , "PKCS7Padding" ] // TODO: misnomer in the JCA?
305303 or
306- type instanceof Crypto :: OAEP and name .matches ( "OAEP%" ) // TODO: handle OAEPWith%
304+ type instanceof KeyOpAlg :: OAEP and name .matches ( "OAEP%" ) // TODO: handle OAEPWith%
307305 }
308306
309- override Crypto :: TPaddingType getPaddingType ( ) {
307+ override KeyOpAlg :: PaddingSchemeType getPaddingType ( ) {
310308 if this .paddingToNameMappingKnown ( _, super .getPadding ( ) )
311309 then this .paddingToNameMappingKnown ( result , super .getPadding ( ) )
312- else result instanceof Crypto :: OtherPadding
310+ else result instanceof KeyOpAlg :: OtherPadding
313311 }
314312 }
315313
@@ -320,10 +318,10 @@ module JCAModel {
320318
321319 override string getRawModeAlgorithmName ( ) { result = super .getMode ( ) }
322320
323- override Crypto :: TBlockCipherModeOfOperationType getModeType ( ) {
321+ override KeyOpAlg :: ModeOfOperationType getModeType ( ) {
324322 if mode_name_to_type_known ( _, super .getMode ( ) )
325323 then mode_name_to_type_known ( result , super .getMode ( ) )
326- else result instanceof Crypto :: OtherMode
324+ else result instanceof KeyOpAlg :: OtherMode
327325 }
328326 }
329327
@@ -347,7 +345,7 @@ module JCAModel {
347345
348346 override string getRawAlgorithmName ( ) { result = super .getValue ( ) }
349347
350- override KeyOpAlg:: Algorithm getAlgorithmType ( ) {
348+ override KeyOpAlg:: AlgorithmType getAlgorithmType ( ) {
351349 if cipher_name_to_type_known ( _, super .getAlgorithmName ( ) )
352350 then cipher_name_to_type_known ( result , super .getAlgorithmName ( ) )
353351 else result instanceof KeyOpAlg:: TUnknownKeyOperationAlgorithmType
@@ -1249,7 +1247,7 @@ module JCAModel {
12491247 result = super .getRawKdfAlgorithmName ( ) .splitAt ( "WithHmac" , 1 )
12501248 }
12511249
1252- override Crypto:: TMacType getMacType ( ) { result instanceof Crypto:: THMAC }
1250+ override Crypto:: MacType getMacType ( ) { result = Crypto:: HMAC ( ) }
12531251
12541252 override Crypto:: AlgorithmValueConsumer getHmacAlgorithmValueConsumer ( ) { result = this }
12551253
@@ -1487,10 +1485,10 @@ module JCAModel {
14871485
14881486 override string getRawMacAlgorithmName ( ) { result = super .getValue ( ) }
14891487
1490- override Crypto:: TMacType getMacType ( ) {
1488+ override Crypto:: MacType getMacType ( ) {
14911489 if mac_name_to_mac_type_known ( _, super .getValue ( ) )
14921490 then mac_name_to_mac_type_known ( result , super .getValue ( ) )
1493- else result instanceof Crypto:: TOtherMACType
1491+ else result = Crypto:: OtherMacType ( )
14941492 }
14951493 }
14961494
@@ -1597,15 +1595,18 @@ module JCAModel {
15971595
15981596 override string getRawEllipticCurveName ( ) { result = super .getValue ( ) }
15991597
1600- override Crypto:: TEllipticCurveType getEllipticCurveType ( ) {
1601- if Crypto:: ellipticCurveNameToKeySizeAndFamilyMapping ( this .getRawEllipticCurveName ( ) , _, _)
1598+ override Crypto:: EllipticCurveFamilyType getEllipticCurveFamilyType ( ) {
1599+ if
1600+ Crypto:: ellipticCurveNameToKnownKeySizeAndFamilyMapping ( this .getRawEllipticCurveName ( ) , _, _)
16021601 then
1603- Crypto:: ellipticCurveNameToKeySizeAndFamilyMapping ( this .getRawEllipticCurveName ( ) , _, result )
1602+ Crypto:: ellipticCurveNameToKnownKeySizeAndFamilyMapping ( this .getRawEllipticCurveName ( ) , _,
1603+ result )
16041604 else result = Crypto:: OtherEllipticCurveType ( )
16051605 }
16061606
16071607 override int getKeySize ( ) {
1608- Crypto:: ellipticCurveNameToKeySizeAndFamilyMapping ( this .getRawEllipticCurveName ( ) , result , _)
1608+ Crypto:: ellipticCurveNameToKnownKeySizeAndFamilyMapping ( this .getRawEllipticCurveName ( ) ,
1609+ result , _)
16091610 }
16101611
16111612 EllipticCurveAlgorithmValueConsumer getConsumer ( ) { result = consumer }
0 commit comments