@@ -27,10 +27,9 @@ module JCAModel {
2727 predicate cipher_names ( string algo ) {
2828 algo .toUpperCase ( )
2929 .matches ( [
30- "AES" , "AESWrap" , "AESWrapPad" , "ARCFOUR" , "ARIA" , "Blowfish" , "Camellia" ,
31- "ChaCha20" , "ChaCha20-Poly1305" , "DES" , "DESede" , "DESedeWrap" , "ECIES" ,
32- "PBEWith%" , "RC2" , "RC4" , "RC5" , "RSA" , "Salsa20" , "SEED" , "Skipjack" , "Idea" ,
33- "Twofish"
30+ "AES" , "AESWrap" , "AESWrapPad" , "ARCFOUR" , "ARIA" , "Blowfish" , "Camellia" , "ChaCha20" ,
31+ "ChaCha20-Poly1305" , "DES" , "DESede" , "DESedeWrap" , "ECIES" , "PBEWith%" , "RC2" , "RC4" ,
32+ "RC5" , "RSA" , "Salsa20" , "SEED" , "Skipjack" , "Idea" , "Twofish"
3433 ] .toUpperCase ( ) )
3534 }
3635
@@ -204,7 +203,8 @@ module JCAModel {
204203 upper .matches ( "DESEDE%" ) and
205204 type = KeyOpAlg:: TSymmetricCipher ( KeyOpAlg:: TRIPLE_DES ( ) )
206205 or
207- not upper .matches ( "DESEDE%" ) and upper .matches ( "DES%" ) and
206+ not upper .matches ( "DESEDE%" ) and
207+ upper .matches ( "DES%" ) and
208208 type = KeyOpAlg:: TSymmetricCipher ( KeyOpAlg:: DES ( ) )
209209 or
210210 upper = "TRIPLEDES" and
@@ -1879,9 +1879,7 @@ module JCAModel {
18791879
18801880 override Crypto:: ModeOfOperationAlgorithmInstance getModeOfOperationAlgorithm ( ) { none ( ) }
18811881
1882- override Crypto:: PaddingAlgorithmInstance getPaddingAlgorithm ( ) {
1883- result = this
1884- }
1882+ override Crypto:: PaddingAlgorithmInstance getPaddingAlgorithm ( ) { result = this }
18851883
18861884 override predicate shouldHaveModeOfOperation ( ) { none ( ) }
18871885
@@ -1984,24 +1982,16 @@ module JCAModel {
19841982 }
19851983
19861984 /** Gets the digest algorithm name argument (arg 0). */
1987- Expr getDigestAlgorithmArg ( ) {
1988- result = this .getArgument ( 0 )
1989- }
1985+ Expr getDigestAlgorithmArg ( ) { result = this .getArgument ( 0 ) }
19901986
19911987 /** Gets the MGF algorithm name argument (arg 1). */
1992- Expr getMgfAlgorithmArg ( ) {
1993- result = this .getArgument ( 1 )
1994- }
1988+ Expr getMgfAlgorithmArg ( ) { result = this .getArgument ( 1 ) }
19951989
19961990 /** Gets the salt length argument (arg 3). */
1997- Expr getSaltLengthArg ( ) {
1998- result = this .getArgument ( 3 )
1999- }
1991+ Expr getSaltLengthArg ( ) { result = this .getArgument ( 3 ) }
20001992
20011993 /** Gets the MGF parameter spec argument (arg 2), e.g., MGF1ParameterSpec.SHA256. */
2002- Expr getMgfSpecArg ( ) {
2003- result = this .getArgument ( 2 )
2004- }
1994+ Expr getMgfSpecArg ( ) { result = this .getArgument ( 2 ) }
20051995 }
20061996
20071997 /**
@@ -2011,9 +2001,7 @@ module JCAModel {
20112001 */
20122002 class MGF1ParameterSpecFieldAccess extends FieldAccess {
20132003 MGF1ParameterSpecFieldAccess ( ) {
2014- this .getField ( )
2015- .getDeclaringType ( )
2016- .hasQualifiedName ( "java.security.spec" , "MGF1ParameterSpec" ) and
2004+ this .getField ( ) .getDeclaringType ( ) .hasQualifiedName ( "java.security.spec" , "MGF1ParameterSpec" ) and
20172005 this .getField ( ) .isStatic ( )
20182006 }
20192007
@@ -2042,8 +2030,7 @@ module JCAModel {
20422030 *
20432031 * Type resolution delegates to hash_name_to_type_known from Standardization.
20442032 */
2045- class PSSParameterSpecDigestHashAlgorithmInstance extends Crypto:: HashAlgorithmInstance
2046- instanceof JavaConstant
2033+ class PSSParameterSpecDigestHashAlgorithmInstance extends Crypto:: HashAlgorithmInstance instanceof JavaConstant
20472034 {
20482035 PSSParameterSpecInstantiation spec ;
20492036
@@ -2075,8 +2062,7 @@ module JCAModel {
20752062 * The field name is normalized to a standard hash algorithm name (e.g.,
20762063 * SHA256 -> SHA-256), then type resolution delegates to hash_name_to_type_known.
20772064 */
2078- class PSSParameterSpecMgf1HashAlgorithmInstance extends Crypto:: HashAlgorithmInstance
2079- instanceof MGF1ParameterSpecFieldAccess
2065+ class PSSParameterSpecMgf1HashAlgorithmInstance extends Crypto:: HashAlgorithmInstance instanceof MGF1ParameterSpecFieldAccess
20802066 {
20812067 PSSParameterSpecInstantiation spec ;
20822068 string normalizedName ;
@@ -2093,13 +2079,9 @@ module JCAModel {
20932079
20942080 override string getRawHashAlgorithmName ( ) { result = super .getField ( ) .getName ( ) }
20952081
2096- override Crypto:: THashType getHashType ( ) {
2097- result = hash_name_to_type_known ( normalizedName , _)
2098- }
2082+ override Crypto:: THashType getHashType ( ) { result = hash_name_to_type_known ( normalizedName , _) }
20992083
2100- override int getFixedDigestLength ( ) {
2101- exists ( hash_name_to_type_known ( normalizedName , result ) )
2102- }
2084+ override int getFixedDigestLength ( ) { exists ( hash_name_to_type_known ( normalizedName , result ) ) }
21032085 }
21042086
21052087 class SignatureInitCall extends MethodCall {
@@ -2119,9 +2101,11 @@ module JCAModel {
21192101 */
21202102 class SignatureSetParameterCall extends MethodCall {
21212103 SignatureSetParameterCall ( ) {
2104+ this .getMethod ( ) .hasQualifiedName ( "java.security" , "Signature" , "setParameter" ) and
21222105 this .getMethod ( )
2123- .hasQualifiedName ( "java.security" , "Signature" , "setParameter" ) and
2124- this .getMethod ( ) .getParameterType ( 0 ) .( RefType ) .hasQualifiedName ( "java.security.spec" , "AlgorithmParameterSpec" )
2106+ .getParameterType ( 0 )
2107+ .( RefType )
2108+ .hasQualifiedName ( "java.security.spec" , "AlgorithmParameterSpec" )
21252109 }
21262110
21272111 /** Gets the AlgorithmParameterSpec argument. */
@@ -2236,9 +2220,7 @@ module JCAModel {
22362220 * Flow from `PSSParameterSpec` instantiation to `Signature.setParameter()` argument.
22372221 */
22382222 module PSSSpecToSetParameterConfig implements DataFlow:: ConfigSig {
2239- predicate isSource ( DataFlow:: Node src ) {
2240- src .asExpr ( ) instanceof PSSParameterSpecInstantiation
2241- }
2223+ predicate isSource ( DataFlow:: Node src ) { src .asExpr ( ) instanceof PSSParameterSpecInstantiation }
22422224
22432225 predicate isSink ( DataFlow:: Node sink ) {
22442226 exists ( SignatureSetParameterCall c | sink .asExpr ( ) = c .getParameterSpecArg ( ) )
@@ -2260,8 +2242,7 @@ module JCAModel {
22602242 PSSParameterSpecInstantiation spec , SignaturePssPaddingAlgorithmInstance literal
22612243 ) {
22622244 exists (
2263- SignatureSetParameterCall setParam ,
2264- SignatureGetInstanceCall getInstance ,
2245+ SignatureSetParameterCall setParam , SignatureGetInstanceCall getInstance ,
22652246 SignatureGetInstanceAlgorithmValueConsumer consumer
22662247 |
22672248 consumer = literal .getConsumer ( ) and
0 commit comments