@@ -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
/**
@@ -782,6 +795,17 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
782
795
abstract ArtifactOutputDataFlowNode getOutputArtifact ( ) ;
783
796
}
784
797
798
+ /**
799
+ * A key operation instance representing a signature being generated or verified.
800
+ */
801
+ abstract class SignatureOperationInstance extends KeyOperationInstance {
802
+ /**
803
+ * Gets the consumer of the signature that is being verified in case of a
804
+ * verification operation.
805
+ */
806
+ abstract ConsumerInputDataFlowNode getSignatureConsumer ( ) ;
807
+ }
808
+
785
809
/**
786
810
* A key-based algorithm instance used in cryptographic operations such as encryption, decryption,
787
811
* signing, verification, and key wrapping.
@@ -1264,6 +1288,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1264
1288
TNonceInput ( NonceArtifactConsumer e ) or
1265
1289
TMessageInput ( MessageArtifactConsumer e ) or
1266
1290
TSaltInput ( SaltArtifactConsumer e ) or
1291
+ TSignatureInput ( SignatureArtifactConsumer e ) or
1267
1292
TRandomNumberGeneration ( RandomNumberGenerationInstance e ) { e .flowsTo ( _) } or
1268
1293
// Key Creation Operation union type (e.g., key generation, key load)
1269
1294
TKeyCreationOperation ( KeyCreationOperationInstance e ) or
@@ -1325,14 +1350,14 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1325
1350
/**
1326
1351
* Returns the child of this node with the given edge name.
1327
1352
*
1328
- * 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.
1329
1354
*/
1330
1355
NodeBase getChild ( string edgeName ) { none ( ) }
1331
1356
1332
1357
/**
1333
1358
* Defines properties of this node by name and either a value or location or both.
1334
1359
*
1335
- * 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.
1336
1361
*/
1337
1362
predicate properties ( string key , string value , Location location ) { none ( ) }
1338
1363
@@ -1505,6 +1530,20 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1505
1530
override LocatableElement asElement ( ) { result = instance }
1506
1531
}
1507
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
+
1508
1547
/**
1509
1548
* A salt input.
1510
1549
*/
@@ -1528,13 +1567,22 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
1528
1567
1529
1568
KeyOperationOutputNode ( ) { this = TKeyOperationOutput ( instance ) }
1530
1569
1531
- final override string getInternalType ( ) { result = "KeyOperationOutput" }
1570
+ override string getInternalType ( ) { result = "KeyOperationOutput" }
1532
1571
1533
1572
override LocatableElement asElement ( ) { result = instance }
1534
1573
1535
1574
override string getSourceNodeRelationship ( ) { none ( ) }
1536
1575
}
1537
1576
1577
+ class SignOperationOutputNode extends KeyOperationOutputNode {
1578
+ SignOperationOutputNode ( ) {
1579
+ this .asElement ( ) .( KeyOperationOutputArtifactInstance ) .getCreator ( ) .getKeyOperationSubtype ( ) =
1580
+ TSignMode ( )
1581
+ }
1582
+
1583
+ override string getInternalType ( ) { result = "SignatureOutput" }
1584
+ }
1585
+
1538
1586
/**
1539
1587
* A source of random number generation.
1540
1588
*/
@@ -2107,6 +2155,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
2107
2155
}
2108
2156
2109
2157
class SignatureOperationNode extends KeyOperationNode {
2158
+ override SignatureOperationInstance instance ;
2110
2159
string nodeName ;
2111
2160
2112
2161
SignatureOperationNode ( ) {
@@ -2116,6 +2165,21 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
2116
2165
}
2117
2166
2118
2167
override string getInternalType ( ) { result = nodeName }
2168
+
2169
+ SignatureArtifactNode getASignatureArtifact ( ) {
2170
+ result .asElement ( ) = instance .getSignatureConsumer ( ) .getConsumer ( )
2171
+ }
2172
+
2173
+ override NodeBase getChild ( string key ) {
2174
+ result = super .getChild ( key )
2175
+ or
2176
+ // [KNOWN_OR_UNKNOWN] - only if we know the type is verify
2177
+ this .getKeyOperationSubtype ( ) = TVerifyMode ( ) and
2178
+ key = "Signature" and
2179
+ if exists ( this .getASignatureArtifact ( ) )
2180
+ then result = this .getASignatureArtifact ( )
2181
+ else result = this
2182
+ }
2119
2183
}
2120
2184
2121
2185
/**
@@ -2563,15 +2627,15 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
2563
2627
or
2564
2628
curveName = "CURVE25519" and keySize = 255 and curveFamily = CURVE25519 ( )
2565
2629
or
2630
+ curveName = "CURVE448" and keySize = 448 and curveFamily = CURVE448 ( )
2631
+ or
2566
2632
// TODO: separate these into key agreement logic or sign/verify (ECDSA / ECDH)
2567
2633
// or
2568
2634
// curveName = "X25519" and keySize = 255 and curveFamily = CURVE25519()
2569
2635
// or
2570
2636
// curveName = "ED25519" and keySize = 255 and curveFamily = CURVE25519()
2571
2637
// or
2572
2638
// curveName = "ED448" and keySize = 448 and curveFamily = CURVE448()
2573
- // curveName = "CURVE448" and keySize = 448 and curveFamily = CURVE448()
2574
- // or
2575
2639
// or
2576
2640
// curveName = "X448" and keySize = 448 and curveFamily = CURVE448()
2577
2641
curveName = "SM2" and keySize in [ 256 , 512 ] and curveFamily = SM2 ( )
0 commit comments