File tree Expand file tree Collapse file tree
cpp/ql/lib/experimental/Quantum/OpenSSL Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,9 +9,9 @@ import OpenSSLAlgorithmGetter
99 * If the literal does not represent any known cipher algorithm,
1010 * this predicate will not hold (i.e., it will not bind an unknown to an unknown cipher type)
1111 */
12- predicate literalToCipherFamilyType ( Literal e , Crypto:: TCipherType type ) {
13- exists ( string name , string algType | algType .toLowerCase ( ) .matches ( "%encryption" ) |
14- resolveAlgorithmFromLiteral ( e , name , algType ) and
12+ predicate knownOpenSSLConstantToCipherFamilyType ( KnownOpenSSLAlgorithmConstant e , Crypto:: TCipherType type ) {
13+ exists ( string name | e . getAlgType ( ) .toLowerCase ( ) .matches ( "%encryption" ) |
14+ name = e . getNormalizedName ( ) and
1515 (
1616 name .matches ( "AES%" ) and type instanceof Crypto:: AES
1717 or
@@ -97,5 +97,9 @@ class KnownOpenSSLCipherConstantAlgorithmInstance extends Crypto::CipherAlgorith
9797
9898 override string getRawAlgorithmName ( ) { result = this .( Literal ) .getValue ( ) .toString ( ) }
9999
100- override Crypto:: TCipherType getCipherFamily ( ) { literalToCipherFamilyType ( this , result ) }
101- }
100+ override Crypto:: TCipherType getCipherFamily ( ) {
101+ knownOpenSSLConstantToCipherFamilyType ( this , result )
102+ or
103+ not knownOpenSSLConstantToCipherFamilyType ( this , _) and result = Crypto:: OtherCipherType ( )
104+ }
105+ }
Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ import cpp
22import experimental.Quantum.Language
33import OpenSSLAlgorithmGetter
44
5- predicate literalToHashFamilyType ( Literal e , Crypto:: THashType type ) {
6- exists ( string name , string algType | algType .toLowerCase ( ) .matches ( "hash" ) |
7- resolveAlgorithmFromLiteral ( e , name , algType ) and
5+ predicate knownOpenSSLConstantToHashFamilyType ( KnownOpenSSLAlgorithmConstant e , Crypto:: THashType type ) {
6+ exists ( string name | e . getAlgType ( ) .toLowerCase ( ) .matches ( "hash" ) |
7+ name = e . getNormalizedName ( ) and
88 (
99 name .matches ( "BLAKE2B" ) and type instanceof Crypto:: BLAKE2B
1010 or
@@ -70,7 +70,10 @@ class KnownOpenSSLHashConstantAlgorithmInstance extends Crypto::HashAlgorithmIns
7070 AlgGetterToAlgConsumerFlow:: flow ( getterCall .getResultNode ( ) , DataFlow:: exprNode ( result ) )
7171 }
7272
73- override Crypto:: THashType getHashFamily ( ) { literalToHashFamilyType ( this , result ) }
73+ override Crypto:: THashType getHashFamily ( ) {
74+ knownOpenSSLConstantToHashFamilyType ( this , result ) or
75+ not knownOpenSSLConstantToHashFamilyType ( this , _) and result = Crypto:: OtherHashType ( )
76+ }
7477
7578 override string getRawAlgorithmName ( ) { result = this .( Literal ) .getValue ( ) .toString ( ) }
7679
You can’t perform that action at this time.
0 commit comments