1- import java
1+ private import java
2+ private import experimental.quantum.Language
3+ private import FlowAnalysis
4+ private import AlgorithmInstances
25
36module Params {
4- import FlowAnalysis
5- import AlgorithmInstances
6-
77 /**
88 * A model of the `Parameters` class in Bouncy Castle.
99 */
@@ -17,15 +17,15 @@ module Params {
1717
1818 class Curve extends Class {
1919 Curve ( ) {
20- this .getPackage ( ) .getName ( ) = "org.bouncycastle.math.ec" and
21- this .getName ( ) . matches ( "ECCurve" )
20+ this .getPackage ( ) .hasName ( "org.bouncycastle.math.ec" ) and
21+ this .hasName ( "ECCurve" )
2222 }
2323 }
2424
2525 class KeyParameters extends Parameters {
2626 KeyParameters ( ) {
27- this .getPackage ( ) . getName ( ) =
28- [ "org.bouncycastle.crypto.params" , "org.bouncycastle.pqc.crypto.lms" ] and
27+ this .getPackage ( )
28+ . hasName ( [ "org.bouncycastle.crypto.params" , "org.bouncycastle.pqc.crypto.lms" ] ) and
2929 this .getName ( ) .matches ( [ "%KeyParameter" , "%KeyParameters" ] )
3030 }
3131 }
@@ -95,7 +95,7 @@ module Params {
9595 }
9696
9797 /**
98- * The named elliptic curve passed to `X9ECParameters.getCurve()`.
98+ * A named elliptic curve passed to `X9ECParameters.getCurve()`.
9999 */
100100 class X9ECParametersInstantiation extends ParametersInstantiation {
101101 X9ECParametersInstantiation ( ) { this .( Expr ) .getType ( ) .getName ( ) = "X9ECParameters" }
@@ -108,7 +108,7 @@ module Params {
108108 }
109109
110110 /**
111- * The named elliptic curve passed to `ECNamedCurveTable.getParameterSpec()`.
111+ * A named elliptic curve passed to `ECNamedCurveTable.getParameterSpec()`.
112112 */
113113 class ECNamedCurveParameterSpecInstantiation extends ParametersInstantiation {
114114 ECNamedCurveParameterSpecInstantiation ( ) {
@@ -135,6 +135,11 @@ module Params {
135135 override Expr getNonceArg ( ) { result = this .( ConstructorCall ) .getArgument ( 2 ) }
136136 }
137137
138+ /**
139+ * A `ParametersWithIV` instantiation.
140+ *
141+ * This type is used to model data flow from a nonce to a cipher operation.
142+ */
138143 class ParametersWithIvInstantiation extends ParametersInstantiation {
139144 ParametersWithIvInstantiation ( ) {
140145 this .( ConstructorCall ) .getConstructedType ( ) .getName ( ) = "ParametersWithIV"
@@ -161,9 +166,6 @@ module Params {
161166 * Models for the signature algorithms defined by the `org.bouncycastle.crypto.signers` package.
162167 */
163168module Signers {
164- import FlowAnalysis
165- import AlgorithmInstances
166-
167169 /**
168170 * A model of the `Signer` class in Bouncy Castle.
169171 *
@@ -207,8 +209,8 @@ module Signers {
207209 }
208210
209211 /**
210- * This class represents signers with a one shot API (where the entire message
211- * is passed to either `generateSignature()` or `verifySignature`.).
212+ * A signer with a one shot API (where the entire message is passed to either
213+ * `generateSignature()` or `verifySignature`.).
212214 */
213215 class OneShotSigner extends Signer {
214216 OneShotSigner ( ) { this .getName ( ) .matches ( [ "DSASigner" , "ECDSA%" , "LMS%" , "HSS%" ] ) }
@@ -335,9 +337,6 @@ module Signers {
335337 * Models for the key generation algorithms defined by the `org.bouncycastle.crypto.generators` package.
336338 */
337339module Generators {
338- import FlowAnalysis
339- import AlgorithmInstances
340-
341340 /**
342341 * A model of the `KeyGenerator` and `KeyPairGenerator` classes in Bouncy Castle.
343342 */
@@ -366,6 +365,8 @@ module Generators {
366365 }
367366
368367 /**
368+ * An asymmetric key pair.
369+ *
369370 * This type is used to model data flow from a key pair to the private and
370371 * public components of the key pair.
371372 */
@@ -391,13 +392,13 @@ module Generators {
391392 private class KeyGeneratorNewCall = KeyGenerationAlgorithmInstance ;
392393
393394 /**
395+ * A call to a key generator `init()` method.
396+ *
394397 * The type is instantiated by a constructor call and initialized by a call to
395398 * `init()` which takes a single `KeyGenerationParameters` argument.
396399 */
397400 private class KeyGeneratorInitCall extends MethodCall {
398- KeyGenerator gen ;
399-
400- KeyGeneratorInitCall ( ) { this = gen .getAnInitCall ( ) }
401+ KeyGeneratorInitCall ( ) { this = any ( KeyGenerator gen ) .getAnInitCall ( ) }
401402
402403 Crypto:: ConsumerInputDataFlowNode getKeySizeConsumer ( ) { none ( ) }
403404
@@ -435,7 +436,8 @@ module Generators {
435436 class KeyGenerationOperationInstance extends Crypto:: KeyGenerationOperationInstance instanceof KeyGeneratorUseCall
436437 {
437438 override Crypto:: AlgorithmValueConsumer getAnAlgorithmValueConsumer ( ) {
438- // The algorithm is implicitly defined by the key generator type
439+ // The algorithm is implicitly defined by the key generator type, which is
440+ // determined by the constructor call.
439441 result = KeyGeneratorFlow:: getNewFromUse ( this , _, _)
440442 }
441443
@@ -529,6 +531,9 @@ module Modes {
529531 }
530532 }
531533
534+ /**
535+ * A block cipher engine, like `AESEngine`.
536+ */
532537 class BlockCipher extends Class {
533538 BlockCipher ( ) {
534539 this .getPackage ( ) .getName ( ) = "org.bouncycastle.crypto.engines" and
@@ -605,9 +610,7 @@ module Modes {
605610 * decrypt data.
606611 */
607612 private class BlockCipherModeUseCall extends MethodCall {
608- BlockCipherMode mode ;
609-
610- BlockCipherModeUseCall ( ) { this = mode .getAUseCall ( ) }
613+ BlockCipherModeUseCall ( ) { this = any ( BlockCipherMode mode ) .getAUseCall ( ) }
611614
612615 predicate isIntermediate ( ) { not this .getCallee ( ) .getName ( ) = "doFinal" }
613616
0 commit comments