@@ -20,7 +20,7 @@ abstract class CryptographicArtifact extends DataFlow::Node { }
2020abstract class SymmetricCipher extends CryptographicArtifact {
2121 abstract SymmetricEncryptionAlgorithm getEncryptionAlgorithm ( ) ;
2222
23- abstract BlockMode getBlockMode ( ) ;
23+ abstract BlockModeInstance getBlockMode ( ) ;
2424
2525 final predicate hasBlockMode ( ) { exists ( this .getBlockMode ( ) ) }
2626}
@@ -55,9 +55,14 @@ abstract class CryptographicOperation extends CryptographicArtifact, API::CallNo
5555 not this .hasAlgorithm ( )
5656 }
5757
58+ /** Gets the data flow node where the cryptographic algorithm used in this operation is configured. */
59+ abstract DataFlow:: Node getInitialisation ( ) ;
5860 // TODO: this might have to be parameterized by a configuration source for
5961 // situations where an operation is passed an algorithm
62+ /** Gets the algorithm used, if it matches a known `CryptographicAlgorithm`. */
6063 abstract CryptographicAlgorithm getAlgorithm ( ) ;
64+ /** Gets an input the algorithm is used on, for example the plain text input to be encrypted. */
65+ abstract DataFlow:: Node getAnInput ( ) ;
6166}
6267
6368/** A key generation operation for asymmetric keys */
@@ -129,10 +134,11 @@ abstract class KeyDerivationAlgorithm extends CryptographicAlgorithm {
129134}
130135
131136abstract class KeyDerivationOperation extends CryptographicOperation {
132- DataFlow:: Node getIterationSizeSrc ( ) { none ( ) }
133-
137+ DataFlow:: Node getSaltConfigSink ( ) { none ( ) }
134138 DataFlow:: Node getSaltConfigSrc ( ) { none ( ) }
135139
140+ DataFlow:: Node getIterationSizeSrc ( ) { none ( ) }
141+
136142 DataFlow:: Node getHashConfigSrc ( ) { none ( ) }
137143
138144 DataFlow:: Node getLanesConfigSrc ( ) { none ( ) }
@@ -175,6 +181,8 @@ abstract class EncryptionAlgorithm extends CryptographicAlgorithm {
175181 // class does not have this common predicate.
176182}
177183
184+ abstract class EncryptionOperation extends CryptographicOperation { }
185+
178186/**
179187 * Algorithms directly or indirectly related to asymmetric encryption,
180188 * e.g., RSA, DSA, but also RSA padding algorithms
@@ -200,6 +208,8 @@ abstract class SymmetricEncryptionAlgorithm extends EncryptionAlgorithm {
200208 // TODO: add a stream cipher predicate?
201209}
202210
211+ abstract class SymmetricEncryptionOperation extends EncryptionOperation { }
212+
203213// Used only to categorize all padding into a single object,
204214// DO_NOT add predicates here. Only for categorization purposes.
205215abstract class PaddingAlgorithm extends CryptographicAlgorithm { }
@@ -230,7 +240,7 @@ abstract class EllipticCurveAlgorithm extends AsymmetricAlgorithm {
230240 final int getCurveBitSize ( ) { isEllipticCurveAlgorithm ( this .getCurveName ( ) , result ) }
231241}
232242
233- abstract class BlockMode extends CryptographicAlgorithm {
243+ abstract class BlockModeInstance extends CryptographicAlgorithm {
234244 final string getBlockModeName ( ) {
235245 if exists ( string n | n = this .getName ( ) and isCipherBlockModeAlgorithm ( n ) )
236246 then isCipherBlockModeAlgorithm ( result ) and result = this .getName ( )
@@ -240,21 +250,38 @@ abstract class BlockMode extends CryptographicAlgorithm {
240250 /**
241251 * Gets the source of the IV configuration.
242252 */
243- abstract DataFlow:: Node getIVorNonce ( ) ;
253+ abstract DataFlow:: Node getIVOrNonceSrc ( ) ;
254+
255+ /**
256+ * Gets the sink of the IV configuration.
257+ */
258+ abstract DataFlow:: Node getIVOrNonceSink ( ) ;
244259
245- final predicate hasIVorNonce ( ) { exists ( this .getIVorNonce ( ) ) }
260+ final predicate hasIVorNonce ( ) { exists ( this .getIVOrNonceSrc ( ) ) }
246261}
247262
248263abstract class KeyWrapOperation extends CryptographicOperation { }
249264
250265abstract class AuthenticatedEncryptionAlgorithm extends SymmetricEncryptionAlgorithm {
251- final string getAuthticatedEncryptionName ( ) {
266+ final string getAuthenticatedEncryptionName ( ) {
252267 if exists ( string n | n = this .getName ( ) and isSymmetricEncryptionAlgorithm ( n ) )
253268 then isSymmetricEncryptionAlgorithm ( result ) and result = this .getName ( )
254269 else result = unknownAlgorithm ( )
255270 }
256271}
257272
273+ abstract class AuthenticatedEncryptionOperation extends SymmetricEncryptionOperation {
274+ /**
275+ * Gets the source of the IV configuration.
276+ */
277+ abstract DataFlow:: Node getIVOrNonceSrc ( ) ;
278+
279+ /**
280+ * Gets the sink of the IV configuration.
281+ */
282+ abstract DataFlow:: Node getIVOrNonceSink ( ) ;
283+ }
284+
258285abstract class KeyExchangeAlgorithm extends AsymmetricAlgorithm {
259286 final string getKeyExchangeName ( ) {
260287 if exists ( string n | n = this .getName ( ) and isKeyExchangeAlgorithm ( n ) )
0 commit comments