@@ -205,7 +205,7 @@ module JCAModel {
205
205
}
206
206
207
207
bindingset [ name]
208
- predicate mac_name_to_mac_type_known ( Crypto:: TMACType type , string name ) {
208
+ predicate mac_name_to_mac_type_known ( Crypto:: TMacType type , string name ) {
209
209
type = Crypto:: THMAC ( ) and
210
210
name .toUpperCase ( ) .matches ( "HMAC%" )
211
211
}
@@ -373,12 +373,12 @@ module JCAModel {
373
373
oaep_padding_string_components ( any ( CipherStringLiteral s ) .getPadding ( ) , hash , mfg )
374
374
}
375
375
376
- class OAEPPaddingHashAlgorithmInstance extends OAEPPaddingAlgorithmInstance ,
376
+ class OaepPaddingHashAlgorithmInstance extends OaepPaddingAlgorithmInstance ,
377
377
Crypto:: HashAlgorithmInstance instanceof CipherStringLiteral
378
378
{
379
379
string hashName ;
380
380
381
- OAEPPaddingHashAlgorithmInstance ( ) {
381
+ OaepPaddingHashAlgorithmInstance ( ) {
382
382
oaep_padding_string_components ( super .getPadding ( ) , hashName , _)
383
383
}
384
384
@@ -389,12 +389,12 @@ module JCAModel {
389
389
override int getFixedDigestLength ( ) { exists ( hash_name_to_type_known ( hashName , result ) ) }
390
390
}
391
391
392
- class OAEPPaddingAlgorithmInstance extends Crypto:: OAEPPaddingAlgorithmInstance ,
392
+ class OaepPaddingAlgorithmInstance extends Crypto:: OaepPaddingAlgorithmInstance ,
393
393
CipherStringLiteralPaddingAlgorithmInstance
394
394
{
395
- override Crypto:: HashAlgorithmInstance getOAEPEncodingHashAlgorithm ( ) { result = this }
395
+ override Crypto:: HashAlgorithmInstance getOaepEncodingHashAlgorithm ( ) { result = this }
396
396
397
- override Crypto:: HashAlgorithmInstance getMGF1HashAlgorithm ( ) { none ( ) } // TODO
397
+ override Crypto:: HashAlgorithmInstance getMgf1HashAlgorithm ( ) { none ( ) } // TODO
398
398
}
399
399
400
400
/**
@@ -1156,9 +1156,7 @@ module JCAModel {
1156
1156
}
1157
1157
1158
1158
module KeySpecInstantiationToGenerateSecretFlowConfig implements DataFlow:: ConfigSig {
1159
- predicate isSource ( DataFlow:: Node src ) {
1160
- exists ( KeySpecInstantiation call | src .asExpr ( ) = call )
1161
- }
1159
+ predicate isSource ( DataFlow:: Node src ) { src .asExpr ( ) instanceof KeySpecInstantiation }
1162
1160
1163
1161
predicate isSink ( DataFlow:: Node sink ) {
1164
1162
exists ( SecretKeyFactoryGenerateSecretCall call | sink .asExpr ( ) = call .getKeySpecArg ( ) )
@@ -1207,29 +1205,29 @@ module JCAModel {
1207
1205
predicate isIntermediate ( ) { none ( ) }
1208
1206
}
1209
1207
1210
- class KDFAlgorithmStringLiteral extends Crypto:: KeyDerivationAlgorithmInstance instanceof StringLiteral
1208
+ class KdfAlgorithmStringLiteral extends Crypto:: KeyDerivationAlgorithmInstance instanceof StringLiteral
1211
1209
{
1212
1210
SecretKeyFactoryKDFAlgorithmValueConsumer consumer ;
1213
1211
1214
- KDFAlgorithmStringLiteral ( ) {
1212
+ KdfAlgorithmStringLiteral ( ) {
1215
1213
kdf_names ( this .getValue ( ) ) and
1216
1214
KDFAlgorithmStringToGetInstanceFlow:: flow ( DataFlow:: exprNode ( this ) , consumer .getInputNode ( ) )
1217
1215
}
1218
1216
1219
- override string getRawKDFAlgorithmName ( ) { result = super .getValue ( ) }
1217
+ override string getRawKdfAlgorithmName ( ) { result = super .getValue ( ) }
1220
1218
1221
- override Crypto:: TKeyDerivationType getKDFType ( ) {
1219
+ override Crypto:: TKeyDerivationType getKdfType ( ) {
1222
1220
result = kdf_name_to_kdf_type ( super .getValue ( ) , _)
1223
1221
}
1224
1222
1225
1223
SecretKeyFactoryKDFAlgorithmValueConsumer getConsumer ( ) { result = consumer }
1226
1224
}
1227
1225
1228
- class PBKDF2AlgorithmStringLiteral extends KDFAlgorithmStringLiteral ,
1229
- Crypto:: PBKDF2AlgorithmInstance , Crypto:: HMACAlgorithmInstance , Crypto:: HashAlgorithmInstance ,
1226
+ class Pbkdf2AlgorithmStringLiteral extends KdfAlgorithmStringLiteral ,
1227
+ Crypto:: Pbkdf2AlgorithmInstance , Crypto:: HmacAlgorithmInstance , Crypto:: HashAlgorithmInstance ,
1230
1228
Crypto:: AlgorithmValueConsumer
1231
1229
{
1232
- PBKDF2AlgorithmStringLiteral ( ) { super .getKDFType ( ) instanceof Crypto:: PBKDF2 }
1230
+ Pbkdf2AlgorithmStringLiteral ( ) { super .getKdfType ( ) instanceof Crypto:: PBKDF2 }
1233
1231
1234
1232
override Crypto:: ConsumerInputDataFlowNode getInputNode ( ) { none ( ) }
1235
1233
@@ -1244,16 +1242,16 @@ module JCAModel {
1244
1242
}
1245
1243
1246
1244
override string getRawMacAlgorithmName ( ) {
1247
- result = super .getRawKDFAlgorithmName ( ) .splitAt ( "PBKDF2With" , 1 )
1245
+ result = super .getRawKdfAlgorithmName ( ) .splitAt ( "PBKDF2With" , 1 )
1248
1246
}
1249
1247
1250
1248
override string getRawHashAlgorithmName ( ) {
1251
- result = super .getRawKDFAlgorithmName ( ) .splitAt ( "WithHmac" , 1 )
1249
+ result = super .getRawKdfAlgorithmName ( ) .splitAt ( "WithHmac" , 1 )
1252
1250
}
1253
1251
1254
- override Crypto:: TMACType getMacType ( ) { result instanceof Crypto:: THMAC }
1252
+ override Crypto:: TMacType getMacType ( ) { result instanceof Crypto:: THMAC }
1255
1253
1256
- override Crypto:: AlgorithmValueConsumer getHMACAlgorithmValueConsumer ( ) { result = this }
1254
+ override Crypto:: AlgorithmValueConsumer getHmacAlgorithmValueConsumer ( ) { result = this }
1257
1255
1258
1256
override Crypto:: AlgorithmValueConsumer getHashAlgorithmValueConsumer ( ) { result = this }
1259
1257
}
@@ -1267,7 +1265,7 @@ module JCAModel {
1267
1265
override Crypto:: ConsumerInputDataFlowNode getInputNode ( ) { result .asExpr ( ) = this }
1268
1266
1269
1267
override Crypto:: AlgorithmInstance getAKnownAlgorithmSource ( ) {
1270
- exists ( KDFAlgorithmStringLiteral l | l .getConsumer ( ) = this and result = l )
1268
+ exists ( KdfAlgorithmStringLiteral l | l .getConsumer ( ) = this and result = l )
1271
1269
}
1272
1270
1273
1271
SecretKeyFactoryGetInstanceCall getInstantiation ( ) { result = call }
@@ -1442,105 +1440,105 @@ module JCAModel {
1442
1440
* MACs
1443
1441
*/
1444
1442
1445
- module MACKnownAlgorithmToConsumerConfig implements DataFlow:: ConfigSig {
1443
+ module MacKnownAlgorithmToConsumerConfig implements DataFlow:: ConfigSig {
1446
1444
predicate isSource ( DataFlow:: Node src ) { mac_names ( src .asExpr ( ) .( StringLiteral ) .getValue ( ) ) }
1447
1445
1448
1446
predicate isSink ( DataFlow:: Node sink ) {
1449
- exists ( MACGetInstanceCall call | sink .asExpr ( ) = call .getAlgorithmArg ( ) )
1447
+ exists ( MacGetInstanceCall call | sink .asExpr ( ) = call .getAlgorithmArg ( ) )
1450
1448
}
1451
1449
}
1452
1450
1453
- module MACKnownAlgorithmToConsumerFlow = DataFlow:: Global< MACKnownAlgorithmToConsumerConfig > ;
1451
+ module MacKnownAlgorithmToConsumerFlow = DataFlow:: Global< MacKnownAlgorithmToConsumerConfig > ;
1454
1452
1455
- module MACGetInstanceToMACOperationFlowConfig implements DataFlow:: ConfigSig {
1456
- predicate isSource ( DataFlow:: Node src ) { src .asExpr ( ) instanceof MACGetInstanceCall }
1453
+ module MacGetInstanceToMacOperationFlowConfig implements DataFlow:: ConfigSig {
1454
+ predicate isSource ( DataFlow:: Node src ) { src .asExpr ( ) instanceof MacGetInstanceCall }
1457
1455
1458
1456
predicate isSink ( DataFlow:: Node sink ) {
1459
- exists ( MACOperationCall call | sink .asExpr ( ) = call .( MethodCall ) .getQualifier ( ) ) or
1460
- exists ( MACInitCall call | sink .asExpr ( ) = call .( MethodCall ) .getQualifier ( ) )
1457
+ exists ( MacOperationCall call | sink .asExpr ( ) = call .( MethodCall ) .getQualifier ( ) ) or
1458
+ exists ( MacInitCall call | sink .asExpr ( ) = call .( MethodCall ) .getQualifier ( ) )
1461
1459
}
1462
1460
}
1463
1461
1464
- module MACGetInstanceToMACOperationFlow =
1465
- DataFlow:: Global< MACGetInstanceToMACOperationFlowConfig > ;
1462
+ module MacGetInstanceToMacOperationFlow =
1463
+ DataFlow:: Global< MacGetInstanceToMacOperationFlowConfig > ;
1466
1464
1467
- module MACInitCallToMACOperationFlowConfig implements DataFlow:: ConfigSig {
1465
+ module MacInitCallToMacOperationFlowConfig implements DataFlow:: ConfigSig {
1468
1466
// TODO: use flow state with one config
1469
1467
predicate isSource ( DataFlow:: Node src ) {
1470
- exists ( MACInitCall init | src .asExpr ( ) = init .getQualifier ( ) )
1468
+ exists ( MacInitCall init | src .asExpr ( ) = init .getQualifier ( ) )
1471
1469
}
1472
1470
1473
1471
predicate isSink ( DataFlow:: Node sink ) {
1474
- exists ( MACOperationCall call | sink .asExpr ( ) = call .( MethodCall ) .getQualifier ( ) )
1472
+ exists ( MacOperationCall call | sink .asExpr ( ) = call .( MethodCall ) .getQualifier ( ) )
1475
1473
}
1476
1474
}
1477
1475
1478
- module MACInitCallToMACOperationFlow = DataFlow:: Global< MACInitCallToMACOperationFlowConfig > ;
1476
+ module MacInitCallToMacOperationFlow = DataFlow:: Global< MacInitCallToMacOperationFlowConfig > ;
1479
1477
1480
- class KnownMACAlgorithm extends Crypto:: MACAlgorithmInstance instanceof StringLiteral {
1481
- MACGetInstanceAlgorithmValueConsumer consumer ;
1478
+ class KnownMacAlgorithm extends Crypto:: MacAlgorithmInstance instanceof StringLiteral {
1479
+ MacGetInstanceAlgorithmValueConsumer consumer ;
1482
1480
1483
- KnownMACAlgorithm ( ) {
1481
+ KnownMacAlgorithm ( ) {
1484
1482
mac_names ( this .getValue ( ) ) and
1485
- MACKnownAlgorithmToConsumerFlow :: flow ( DataFlow:: exprNode ( this ) , consumer .getInputNode ( ) )
1483
+ MacKnownAlgorithmToConsumerFlow :: flow ( DataFlow:: exprNode ( this ) , consumer .getInputNode ( ) )
1486
1484
}
1487
1485
1488
- MACGetInstanceAlgorithmValueConsumer getConsumer ( ) { result = consumer }
1486
+ MacGetInstanceAlgorithmValueConsumer getConsumer ( ) { result = consumer }
1489
1487
1490
1488
override string getRawMacAlgorithmName ( ) { result = super .getValue ( ) }
1491
1489
1492
- override Crypto:: TMACType getMacType ( ) {
1490
+ override Crypto:: TMacType getMacType ( ) {
1493
1491
if mac_name_to_mac_type_known ( _, super .getValue ( ) )
1494
1492
then mac_name_to_mac_type_known ( result , super .getValue ( ) )
1495
1493
else result instanceof Crypto:: TOtherMACType
1496
1494
}
1497
1495
}
1498
1496
1499
- class MACGetInstanceCall extends MethodCall {
1500
- MACGetInstanceCall ( ) { this .getCallee ( ) .hasQualifiedName ( "javax.crypto" , "Mac" , "getInstance" ) }
1497
+ class MacGetInstanceCall extends MethodCall {
1498
+ MacGetInstanceCall ( ) { this .getCallee ( ) .hasQualifiedName ( "javax.crypto" , "Mac" , "getInstance" ) }
1501
1499
1502
1500
Expr getAlgorithmArg ( ) { result = this .getArgument ( 0 ) }
1503
1501
1504
- MACOperationCall getOperation ( ) {
1505
- MACGetInstanceToMACOperationFlow :: flow ( DataFlow:: exprNode ( this ) ,
1502
+ MacOperationCall getOperation ( ) {
1503
+ MacGetInstanceToMacOperationFlow :: flow ( DataFlow:: exprNode ( this ) ,
1506
1504
DataFlow:: exprNode ( result .( MethodCall ) .getQualifier ( ) ) )
1507
1505
}
1508
1506
1509
- MACInitCall getInitCall ( ) {
1510
- MACGetInstanceToMACOperationFlow :: flow ( DataFlow:: exprNode ( this ) ,
1507
+ MacInitCall getInitCall ( ) {
1508
+ MacGetInstanceToMacOperationFlow :: flow ( DataFlow:: exprNode ( this ) ,
1511
1509
DataFlow:: exprNode ( result .getQualifier ( ) ) )
1512
1510
}
1513
1511
}
1514
1512
1515
- class MACInitCall extends MethodCall {
1516
- MACInitCall ( ) { this .getCallee ( ) .hasQualifiedName ( "javax.crypto" , "Mac" , "init" ) }
1513
+ class MacInitCall extends MethodCall {
1514
+ MacInitCall ( ) { this .getCallee ( ) .hasQualifiedName ( "javax.crypto" , "Mac" , "init" ) }
1517
1515
1518
1516
Expr getKeyArg ( ) {
1519
1517
result = this .getArgument ( 0 ) and this .getMethod ( ) .getParameterType ( 0 ) .hasName ( "Key" )
1520
1518
}
1521
1519
1522
- MACOperationCall getOperation ( ) {
1523
- MACInitCallToMACOperationFlow :: flow ( DataFlow:: exprNode ( this .getQualifier ( ) ) ,
1520
+ MacOperationCall getOperation ( ) {
1521
+ MacInitCallToMacOperationFlow :: flow ( DataFlow:: exprNode ( this .getQualifier ( ) ) ,
1524
1522
DataFlow:: exprNode ( result .( MethodCall ) .getQualifier ( ) ) )
1525
1523
}
1526
1524
}
1527
1525
1528
- class MACGetInstanceAlgorithmValueConsumer extends Crypto:: AlgorithmValueConsumer {
1529
- MACGetInstanceCall call ;
1526
+ class MacGetInstanceAlgorithmValueConsumer extends Crypto:: AlgorithmValueConsumer {
1527
+ MacGetInstanceCall call ;
1530
1528
1531
- MACGetInstanceAlgorithmValueConsumer ( ) { this = call .getAlgorithmArg ( ) }
1529
+ MacGetInstanceAlgorithmValueConsumer ( ) { this = call .getAlgorithmArg ( ) }
1532
1530
1533
1531
override Crypto:: ConsumerInputDataFlowNode getInputNode ( ) { result .asExpr ( ) = this }
1534
1532
1535
1533
override Crypto:: AlgorithmInstance getAKnownAlgorithmSource ( ) {
1536
- exists ( KnownMACAlgorithm l | l .getConsumer ( ) = this and result = l )
1534
+ exists ( KnownMacAlgorithm l | l .getConsumer ( ) = this and result = l )
1537
1535
}
1538
1536
}
1539
1537
1540
- class MACOperationCall extends Crypto:: MACOperationInstance instanceof MethodCall {
1538
+ class MacOperationCall extends Crypto:: MacOperationInstance instanceof MethodCall {
1541
1539
Expr output ;
1542
1540
1543
- MACOperationCall ( ) {
1541
+ MacOperationCall ( ) {
1544
1542
super .getMethod ( ) .getDeclaringType ( ) .hasQualifiedName ( "javax.crypto" , "Mac" ) and
1545
1543
(
1546
1544
super .getMethod ( ) .hasStringSignature ( [ "doFinal()" , "doFinal(byte[])" ] ) and this = output
@@ -1551,13 +1549,13 @@ module JCAModel {
1551
1549
}
1552
1550
1553
1551
override Crypto:: AlgorithmValueConsumer getAnAlgorithmValueConsumer ( ) {
1554
- exists ( MACGetInstanceCall instantiation |
1552
+ exists ( MacGetInstanceCall instantiation |
1555
1553
instantiation .getOperation ( ) = this and result = instantiation .getAlgorithmArg ( )
1556
1554
)
1557
1555
}
1558
1556
1559
1557
override Crypto:: ConsumerInputDataFlowNode getKeyConsumer ( ) {
1560
- exists ( MACGetInstanceCall instantiation , MACInitCall initCall |
1558
+ exists ( MacGetInstanceCall instantiation , MacInitCall initCall |
1561
1559
instantiation .getOperation ( ) = this and
1562
1560
initCall .getOperation ( ) = this and
1563
1561
instantiation .getInitCall ( ) = initCall and
0 commit comments