@@ -424,6 +424,17 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
424
424
final override ConsumerInputDataFlowNode getInputNode ( ) { result = inputNode }
425
425
}
426
426
427
+ final private class SignatureArtifactConsumer extends ArtifactConsumerAndInstance {
428
+ ConsumerInputDataFlowNode inputNode ;
429
+
430
+ SignatureArtifactConsumer ( ) {
431
+ exists ( SignatureOperationInstance op | inputNode = op .getSignatureConsumer ( ) ) and
432
+ this = Input:: dfn_to_element ( inputNode )
433
+ }
434
+
435
+ final override ConsumerInputDataFlowNode getInputNode ( ) { result = inputNode }
436
+ }
437
+
427
438
/**
428
439
* An artifact that is produced by an operation, representing a concrete artifact instance rather than a synthetic consumer artifact.
429
440
*/
@@ -458,6 +469,8 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
458
469
}
459
470
460
471
override DataFlowNode getOutputNode ( ) { result = creator .getOutputArtifact ( ) }
472
+
473
+ KeyOperationInstance getCreator ( ) { result = creator }
461
474
}
462
475
463
476
/**
@@ -783,25 +796,14 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
783
796
}
784
797
785
798
/**
786
- * The output artifact from a signature operation, representing a signature
787
- * that is either generated or verified.
788
- */
789
- abstract class SignatureArtifactInstance extends KeyOperationOutputArtifactInstance { }
790
-
791
- /**
792
- * A key operation instance representing the generation or verification of a
793
- * signature.
799
+ * A key operation instance representing a signature being generated or verified.
794
800
*/
795
801
abstract class SignatureOperationInstance extends KeyOperationInstance {
796
802
/**
797
- * Gets the consumer of the signature input for this operation. This is
798
- * typically a signature that is being verified against a message .
803
+ * Gets the consumer of the signature that is being verified in case of a
804
+ * verification operation .
799
805
*/
800
- abstract ConsumerInputDataFlowNode getSignatureArtifactConsumer ( ) ;
801
-
802
- final SignatureArtifactInstance getSignatureOutputArtifact ( ) {
803
- result .getOutputNode ( ) = this .getOutputArtifact ( )
804
- }
806
+ abstract ConsumerInputDataFlowNode getSignatureConsumer ( ) ;
805
807
}
806
808
807
809
/**
@@ -1286,6 +1288,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1286
1288
TNonceInput ( NonceArtifactConsumer e ) or
1287
1289
TMessageInput ( MessageArtifactConsumer e ) or
1288
1290
TSaltInput ( SaltArtifactConsumer e ) or
1291
+ TSignatureInput ( SignatureArtifactConsumer e ) or
1289
1292
TRandomNumberGeneration ( RandomNumberGenerationInstance e ) { e .flowsTo ( _) } or
1290
1293
// Key Creation Operation union type (e.g., key generation, key load)
1291
1294
TKeyCreationOperation ( KeyCreationOperationInstance e ) or
@@ -1295,7 +1298,6 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1295
1298
TKeyOperation ( KeyOperationInstance e ) or
1296
1299
TKeyOperationAlgorithm ( KeyOperationAlgorithmInstanceOrValueConsumer e ) or
1297
1300
TKeyOperationOutput ( KeyOperationOutputArtifactInstance e ) or
1298
- TSignature ( SignatureOperationInstance e ) or
1299
1301
// Non-Standalone Algorithms (e.g., Mode, Padding)
1300
1302
// These algorithms are always tied to a key operation algorithm
1301
1303
TModeOfOperationAlgorithm ( ModeOfOperationAlgorithmInstance e ) or
@@ -1348,14 +1350,14 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1348
1350
/**
1349
1351
* Returns the child of this node with the given edge name.
1350
1352
*
1351
- * This predicate is overriden by derived classes to construct the graph of cryptographic operations.
1353
+ * This predicate is overridden by derived classes to construct the graph of cryptographic operations.
1352
1354
*/
1353
1355
NodeBase getChild ( string edgeName ) { none ( ) }
1354
1356
1355
1357
/**
1356
1358
* Defines properties of this node by name and either a value or location or both.
1357
1359
*
1358
- * This predicate is overriden by derived classes to construct the graph of cryptographic operations.
1360
+ * This predicate is overridden by derived classes to construct the graph of cryptographic operations.
1359
1361
*/
1360
1362
predicate properties ( string key , string value , Location location ) { none ( ) }
1361
1363
@@ -1528,6 +1530,20 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1528
1530
override LocatableElement asElement ( ) { result = instance }
1529
1531
}
1530
1532
1533
+ /**
1534
+ * A signature input. This may represent a signature, or a signature component
1535
+ * such as the scalar values r and s in ECDSA.
1536
+ */
1537
+ final class SignatureArtifactNode extends ArtifactNode , TSignatureInput {
1538
+ SignatureArtifactConsumer instance ;
1539
+
1540
+ SignatureArtifactNode ( ) { this = TSignatureInput ( instance ) }
1541
+
1542
+ final override string getInternalType ( ) { result = "SignatureInput" }
1543
+
1544
+ override LocatableElement asElement ( ) { result = instance }
1545
+ }
1546
+
1531
1547
/**
1532
1548
* A salt input.
1533
1549
*/
@@ -1551,23 +1567,20 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1551
1567
1552
1568
KeyOperationOutputNode ( ) { this = TKeyOperationOutput ( instance ) }
1553
1569
1554
- final override string getInternalType ( ) { result = "KeyOperationOutput" }
1570
+ override string getInternalType ( ) { result = "KeyOperationOutput" }
1555
1571
1556
1572
override LocatableElement asElement ( ) { result = instance }
1557
1573
1558
1574
override string getSourceNodeRelationship ( ) { none ( ) }
1559
1575
}
1560
1576
1561
- class SignatureArtifactNode extends ArtifactNode , TKeyOperationOutput {
1562
- SignatureArtifactInstance instance ;
1563
-
1564
- SignatureArtifactNode ( ) { this = TKeyOperationOutput ( instance ) }
1565
-
1566
- final override string getInternalType ( ) { result = "Signature" }
1567
-
1568
- override LocatableElement asElement ( ) { result = instance }
1577
+ class SignOperationOutputNode extends KeyOperationOutputNode {
1578
+ SignOperationOutputNode ( ) {
1579
+ this .asElement ( ) .( KeyOperationOutputArtifactInstance ) .getCreator ( ) .getKeyOperationSubtype ( ) =
1580
+ TSignMode ( )
1581
+ }
1569
1582
1570
- override string getSourceNodeRelationship ( ) { none ( ) }
1583
+ override string getInternalType ( ) { result = "SignatureOutput" }
1571
1584
}
1572
1585
1573
1586
/**
@@ -2153,10 +2166,18 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
2153
2166
2154
2167
override string getInternalType ( ) { result = nodeName }
2155
2168
2156
- SignatureArtifactNode getSignatureArtifact ( ) {
2157
- result .asElement ( ) = instance .getOutputArtifactInstance ( )
2169
+ SignatureArtifactNode getASignatureArtifact ( ) {
2170
+ result .asElement ( ) = instance .getSignatureConsumer ( ) .getConsumer ( )
2171
+ }
2172
+
2173
+ override NodeBase getChild ( string key ) {
2174
+ result = super .getChild ( key )
2158
2175
or
2159
- result .asElement ( ) = instance .getSignatureArtifactConsumer ( ) .getConsumer ( )
2176
+ // [KNOWN_OR_UNKNOWN]
2177
+ key = "Signature" and
2178
+ if exists ( this .getASignatureArtifact ( ) )
2179
+ then result = this .getASignatureArtifact ( )
2180
+ else result = this
2160
2181
}
2161
2182
}
2162
2183
0 commit comments