@@ -12,14 +12,24 @@ signature module InputSig<LocationSig Location> {
12
12
string toString ( ) ;
13
13
}
14
14
15
+ class DataFlowNode {
16
+ Location getLocation ( ) ;
17
+
18
+ string toString ( ) ;
19
+ }
20
+
15
21
class UnknownLocation instanceof Location ;
22
+
23
+ predicate rngToIvFlow ( DataFlowNode rng , DataFlowNode iv ) ;
16
24
}
17
25
18
26
module CryptographyBase< LocationSig Location, InputSig< Location > Input> {
19
27
final class LocatableElement = Input:: LocatableElement ;
20
28
21
29
final class UnknownLocation = Input:: UnknownLocation ;
22
30
31
+ final class DataFlowNode = Input:: DataFlowNode ;
32
+
23
33
final class UnknownPropertyValue extends string {
24
34
UnknownPropertyValue ( ) { this = "<unknown>" }
25
35
}
@@ -93,12 +103,15 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
93
103
94
104
abstract class NonceArtifactInstance extends LocatableElement { }
95
105
106
+ abstract class RandomNumberGenerationInstance extends LocatableElement { }
107
+
96
108
newtype TNode =
97
109
// Artifacts (data that is not an operation or algorithm, e.g., a key)
98
110
TDigest ( DigestArtifactInstance e ) or
99
111
TKey ( KeyArtifactInstance e ) or
100
112
TInitializationVector ( InitializationVectorArtifactInstance e ) or
101
113
TNonce ( NonceArtifactInstance e ) or
114
+ TRandomNumberGeneration ( RandomNumberGenerationInstance e ) or
102
115
// Operations (e.g., hashing, encryption)
103
116
THashOperation ( HashOperationInstance e ) or
104
117
TKeyDerivationOperation ( KeyDerivationOperationInstance e ) or
@@ -115,7 +128,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
115
128
TPaddingAlgorithm ( PaddingAlgorithmInstance e ) or
116
129
// Composite and hybrid cryptosystems (e.g., RSA-OAEP used with AES, post-quantum hybrid cryptosystems)
117
130
// These nodes are always parent nodes and are not modeled but rather defined via library-agnostic patterns.
118
- TKemDemHybridCryptosystem ( EncryptionAlgorithmInstance dem ) or // TODO, change this relation and the below ones
131
+ TKemDemHybridCryptosystem ( EncryptionAlgorithm dem ) or // TODO, change this relation and the below ones
119
132
TKeyAgreementHybridCryptosystem ( EncryptionAlgorithmInstance ka ) or
120
133
TAsymmetricEncryptionMacHybridCryptosystem ( EncryptionAlgorithmInstance enc ) or
121
134
TPostQuantumHybridCryptosystem ( EncryptionAlgorithmInstance enc )
@@ -127,9 +140,9 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
127
140
*/
128
141
abstract class NodeBase extends TNode {
129
142
/**
130
- * Returns a string representation of this node, usually the name of the operation/algorithm/property .
143
+ * Returns a string representation of this node.
131
144
*/
132
- abstract string toString ( ) ;
145
+ string toString ( ) { result = this . getInternalType ( ) }
133
146
134
147
/**
135
148
* Returns a string representation of the internal type of this node, usually the name of the class.
@@ -172,15 +185,48 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
172
185
173
186
class Asset = NodeBase ;
174
187
175
- class Artifact = NodeBase ;
188
+ abstract class Artifact extends NodeBase {
189
+ abstract DataFlowNode asOutputData ( ) ;
190
+
191
+ abstract DataFlowNode getInputData ( ) ;
192
+ }
176
193
177
194
/**
178
195
* An initialization vector
179
196
*/
180
- abstract class InitializationVector extends Asset , TInitializationVector {
197
+ abstract class InitializationVector extends Artifact , TInitializationVector {
181
198
final override string getInternalType ( ) { result = "InitializationVector" }
182
199
183
- final override string toString ( ) { result = this .getInternalType ( ) }
200
+ RandomNumberGeneration getRNGSource ( ) {
201
+ Input:: rngToIvFlow ( result .asOutputData ( ) , this .getInputData ( ) )
202
+ }
203
+ }
204
+
205
+ newtype TRNGSourceSecurity =
206
+ RNGSourceSecure ( ) or // Secure RNG source (unrelated to seed)
207
+ RNGSourceInsecure ( ) // Insecure RNG source (unrelated to seed)
208
+
209
+ class RNGSourceSecurity extends TRNGSourceSecurity {
210
+ string toString ( ) {
211
+ this instanceof RNGSourceSecure and result = "Secure RNG Source"
212
+ or
213
+ this instanceof RNGSourceInsecure and result = "Insecure RNG Source"
214
+ }
215
+ }
216
+
217
+ newtype TRNGSeedSecurity =
218
+ RNGSeedSecure ( ) or
219
+ RNGSeedInsecure ( )
220
+
221
+ /**
222
+ * A source of random number generation
223
+ */
224
+ abstract class RandomNumberGeneration extends Artifact , TRandomNumberGeneration {
225
+ final override string getInternalType ( ) { result = "RandomNumberGeneration" }
226
+
227
+ abstract RNGSourceSecurity getSourceSecurity ( ) ;
228
+
229
+ abstract TRNGSeedSecurity getSeedSecurity ( Location location ) ;
184
230
}
185
231
186
232
/**
@@ -197,8 +243,6 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
197
243
*/
198
244
abstract string getOperationType ( ) ;
199
245
200
- final override string toString ( ) { result = this .getOperationType ( ) }
201
-
202
246
final override string getInternalType ( ) { result = this .getOperationType ( ) }
203
247
204
248
override NodeBase getChild ( string edgeName ) {
@@ -210,8 +254,6 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
210
254
}
211
255
212
256
abstract class Algorithm extends Asset {
213
- final override string toString ( ) { result = this .getAlgorithmType ( ) }
214
-
215
257
final override string getInternalType ( ) { result = this .getAlgorithmType ( ) }
216
258
217
259
/**
0 commit comments