@@ -29,7 +29,9 @@ private string rankedInsecureAlgorithm(int i) {
2929 // weak hash algorithms and block modes as well.
3030 result =
3131 rank [ i ] ( string s |
32- isWeakEncryptionAlgorithm ( s ) or isWeakHashingAlgorithm ( s ) or isWeakBlockMode ( s )
32+ isWeakEncryptionAlgorithm ( s ) or
33+ isWeakHashingAlgorithm ( s ) or
34+ s .( Cryptography:: BlockMode ) .isWeak ( )
3335 )
3436}
3537
@@ -329,21 +331,18 @@ private API::Node cipherApi() {
329331 result = API:: getTopLevelMember ( "OpenSSL" ) .getMember ( "Cipher" ) .getMember ( "Cipher" )
330332}
331333
332- private class BlockMode extends string {
333- BlockMode ( ) { this = [ "ECB" , "CBC" , "GCM" , "CCM" , "CFB" , "OFB" , "CTR" ] }
334- }
335-
336334private newtype TCipherMode =
337335 TStreamCipher ( ) or
338- TBlockMode ( BlockMode blockMode )
336+ TBlockMode ( Cryptography :: BlockMode blockMode )
339337
340338/**
341339 * Represents the mode used by this stream cipher.
342340 * If this cipher uses a block encryption algorithm, then this is a specific
343341 * block mode.
344342 */
345343private class CipherMode extends TCipherMode {
346- private BlockMode getBlockMode ( ) { this = TBlockMode ( result ) }
344+ /** Gets the underlying block mode, if any. */
345+ Cryptography:: BlockMode getBlockMode ( ) { this = TBlockMode ( result ) }
347346
348347 /** Gets a textual representation of this node. */
349348 string toString ( ) {
@@ -360,7 +359,7 @@ private class CipherMode extends TCipherMode {
360359 predicate isBlockMode ( string s ) { this .getBlockMode ( ) = s .toUpperCase ( ) }
361360
362361 /** Holds if this cipher mode is a weak block mode. */
363- predicate isWeak ( ) { isWeakBlockMode ( this .getBlockMode ( ) ) }
362+ predicate isWeak ( ) { this .getBlockMode ( ) . isWeak ( ) }
364363}
365364
366365private string getStringArgument ( DataFlow:: CallNode call , int i ) {
@@ -549,4 +548,8 @@ private class CipherOperation extends Cryptography::CryptographicOperation::Rang
549548 cipherNode .getCipher ( ) .isWeak ( ) or
550549 cipherNode .getCipherMode ( ) .isWeak ( )
551550 }
551+
552+ override Cryptography:: BlockMode getBlockMode ( ) {
553+ result = cipherNode .getCipherMode ( ) .getBlockMode ( )
554+ }
552555}
0 commit comments