@@ -5,7 +5,7 @@ import semmle.code.java.controlflow.Dominance
5
5
6
6
module JCAModel {
7
7
import Language
8
- import Crypto :: KeyOpAlg as KeyOpAlg
8
+ import codeql.quantum.experimental.Standardization :: Types :: KeyOpAlg as KeyOpAlg
9
9
10
10
abstract class CipherAlgorithmValueConsumer extends Crypto:: AlgorithmValueConsumer { }
11
11
@@ -115,7 +115,7 @@ module JCAModel {
115
115
}
116
116
117
117
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 ) {
119
119
name = "SHA-1" and result instanceof Crypto:: SHA1 and digestLength = 160
120
120
or
121
121
name = [ "SHA-256" , "SHA-384" , "SHA-512" ] and
@@ -152,24 +152,22 @@ module JCAModel {
152
152
}
153
153
154
154
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"
159
157
or
160
- type = Crypto :: CBC ( ) and name = "CBC"
158
+ type = KeyOpAlg :: CBC ( ) and name = "CBC"
161
159
or
162
- type = Crypto :: GCM ( ) and name = "GCM"
160
+ type = KeyOpAlg :: GCM ( ) and name = "GCM"
163
161
or
164
- type = Crypto :: CTR ( ) and name = "CTR"
162
+ type = KeyOpAlg :: CTR ( ) and name = "CTR"
165
163
or
166
- type = Crypto :: XTS ( ) and name = "XTS"
164
+ type = KeyOpAlg :: XTS ( ) and name = "XTS"
167
165
or
168
- type = Crypto :: CCM ( ) and name = "CCM"
166
+ type = KeyOpAlg :: CCM ( ) and name = "CCM"
169
167
or
170
- type = Crypto :: SIV ( ) and name = "SIV"
168
+ type = KeyOpAlg :: SIV ( ) and name = "SIV"
171
169
or
172
- type = Crypto :: OCB ( ) and name = "OCB"
170
+ type = KeyOpAlg :: OCB ( ) and name = "OCB"
173
171
}
174
172
175
173
bindingset [ name]
@@ -206,7 +204,7 @@ module JCAModel {
206
204
207
205
bindingset [ name]
208
206
predicate mac_name_to_mac_type_known ( Crypto:: TMacType type , string name ) {
209
- type = Crypto:: THMAC ( ) and
207
+ type = Crypto:: HMAC ( ) and
210
208
name .toUpperCase ( ) .matches ( "HMAC%" )
211
209
}
212
210
@@ -298,18 +296,18 @@ module JCAModel {
298
296
override string getRawPaddingAlgorithmName ( ) { result = super .getPadding ( ) }
299
297
300
298
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"
303
301
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?
305
303
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%
307
305
}
308
306
309
- override Crypto :: TPaddingType getPaddingType ( ) {
307
+ override KeyOpAlg :: PaddingSchemeType getPaddingType ( ) {
310
308
if this .paddingToNameMappingKnown ( _, super .getPadding ( ) )
311
309
then this .paddingToNameMappingKnown ( result , super .getPadding ( ) )
312
- else result instanceof Crypto :: OtherPadding
310
+ else result instanceof KeyOpAlg :: OtherPadding
313
311
}
314
312
}
315
313
@@ -320,10 +318,10 @@ module JCAModel {
320
318
321
319
override string getRawModeAlgorithmName ( ) { result = super .getMode ( ) }
322
320
323
- override Crypto :: TBlockCipherModeOfOperationType getModeType ( ) {
321
+ override KeyOpAlg :: ModeOfOperationType getModeType ( ) {
324
322
if mode_name_to_type_known ( _, super .getMode ( ) )
325
323
then mode_name_to_type_known ( result , super .getMode ( ) )
326
- else result instanceof Crypto :: OtherMode
324
+ else result instanceof KeyOpAlg :: OtherMode
327
325
}
328
326
}
329
327
@@ -347,7 +345,7 @@ module JCAModel {
347
345
348
346
override string getRawAlgorithmName ( ) { result = super .getValue ( ) }
349
347
350
- override KeyOpAlg:: Algorithm getAlgorithmType ( ) {
348
+ override KeyOpAlg:: AlgorithmType getAlgorithmType ( ) {
351
349
if cipher_name_to_type_known ( _, super .getAlgorithmName ( ) )
352
350
then cipher_name_to_type_known ( result , super .getAlgorithmName ( ) )
353
351
else result instanceof KeyOpAlg:: TUnknownKeyOperationAlgorithmType
@@ -1249,7 +1247,7 @@ module JCAModel {
1249
1247
result = super .getRawKdfAlgorithmName ( ) .splitAt ( "WithHmac" , 1 )
1250
1248
}
1251
1249
1252
- override Crypto:: TMacType getMacType ( ) { result instanceof Crypto:: THMAC }
1250
+ override Crypto:: MacType getMacType ( ) { result = Crypto:: HMAC ( ) }
1253
1251
1254
1252
override Crypto:: AlgorithmValueConsumer getHmacAlgorithmValueConsumer ( ) { result = this }
1255
1253
@@ -1487,10 +1485,10 @@ module JCAModel {
1487
1485
1488
1486
override string getRawMacAlgorithmName ( ) { result = super .getValue ( ) }
1489
1487
1490
- override Crypto:: TMacType getMacType ( ) {
1488
+ override Crypto:: MacType getMacType ( ) {
1491
1489
if mac_name_to_mac_type_known ( _, super .getValue ( ) )
1492
1490
then mac_name_to_mac_type_known ( result , super .getValue ( ) )
1493
- else result instanceof Crypto:: TOtherMACType
1491
+ else result = Crypto:: OtherMacType ( )
1494
1492
}
1495
1493
}
1496
1494
@@ -1597,15 +1595,18 @@ module JCAModel {
1597
1595
1598
1596
override string getRawEllipticCurveName ( ) { result = super .getValue ( ) }
1599
1597
1600
- override Crypto:: TEllipticCurveType getEllipticCurveType ( ) {
1601
- if Crypto:: ellipticCurveNameToKeySizeAndFamilyMapping ( this .getRawEllipticCurveName ( ) , _, _)
1598
+ override Crypto:: EllipticCurveFamilyType getEllipticCurveFamilyType ( ) {
1599
+ if
1600
+ Crypto:: ellipticCurveNameToKnownKeySizeAndFamilyMapping ( this .getRawEllipticCurveName ( ) , _, _)
1602
1601
then
1603
- Crypto:: ellipticCurveNameToKeySizeAndFamilyMapping ( this .getRawEllipticCurveName ( ) , _, result )
1602
+ Crypto:: ellipticCurveNameToKnownKeySizeAndFamilyMapping ( this .getRawEllipticCurveName ( ) , _,
1603
+ result )
1604
1604
else result = Crypto:: OtherEllipticCurveType ( )
1605
1605
}
1606
1606
1607
1607
override int getKeySize ( ) {
1608
- Crypto:: ellipticCurveNameToKeySizeAndFamilyMapping ( this .getRawEllipticCurveName ( ) , result , _)
1608
+ Crypto:: ellipticCurveNameToKnownKeySizeAndFamilyMapping ( this .getRawEllipticCurveName ( ) ,
1609
+ result , _)
1609
1610
}
1610
1611
1611
1612
EllipticCurveAlgorithmValueConsumer getConsumer ( ) { result = consumer }
0 commit comments