@@ -295,6 +295,8 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
295295 (
296296 exists ( KeyCreationOperationInstance op | input = op .getKeySizeConsumer ( ) )
297297 or
298+ exists ( KeyGenerationOperationInstance op | input = op .getKeyValueConsumer ( ) )
299+ or
298300 exists ( KeyDerivationOperationInstance op |
299301 input = op .getIterationCountConsumer ( ) or
300302 input = op .getOutputKeySizeConsumer ( )
@@ -539,6 +541,8 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
539541 (
540542 exists ( KeyOperationInstance op | inputNode = op .getKeyConsumer ( ) )
541543 or
544+ exists ( KeyGenerationOperationInstance op | inputNode = op .getKeyValueConsumer ( ) )
545+ or
542546 exists ( MacOperationInstance op | inputNode = op .getKeyConsumer ( ) )
543547 or
544548 exists ( KeyAgreementSecretGenerationOperationInstance op |
@@ -959,10 +963,18 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
959963 final override string getKeyCreationTypeDescription ( ) { result = "KeyGeneration" }
960964
961965 /**
962- * Gets a consumer of a raw value that is used to generate the key.
963- * Not all key generation operations require a raw value.
966+ * Gets the consumer of a key for this key generaiton operation.
967+ * This occurs when a key generation operaiton is based on a raw key value
968+ * or it generates another key or key context from a previously generated key.
964969 */
965- abstract ConsumerInputDataFlowNode getRawKeyValueConsumer ( ) ;
970+ abstract ConsumerInputDataFlowNode getKeyValueConsumer ( ) ;
971+
972+ /**
973+ * Holds if the key generation operation has a key consumer
974+ * i.e., an input that is explicitly used for the key value.
975+ * This value should correspond to the value returned by `getKeyValueConsumer()`.
976+ */
977+ abstract predicate hasKeyValueConsumer ( ) ;
966978 }
967979
968980 abstract class KeyLoadOperationInstance extends KeyCreationOperationInstance {
@@ -1708,10 +1720,8 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
17081720 node instanceof KeyCreationCandidateAlgorithmNode
17091721 }
17101722
1711- NodeBase getARawValueSource ( ) {
1712- result = keyGenInstance .getRawKeyValueConsumer ( ) .getConsumer ( ) .getAGenericSourceNode ( )
1713- or
1714- result = keyGenInstance .getRawKeyValueConsumer ( ) .getConsumer ( ) .getAKnownSourceNode ( )
1723+ KeyArtifactNode getKeyArtifact ( ) {
1724+ result .asElement ( ) = keyGenInstance .getKeyValueConsumer ( ) .getConsumer ( )
17151725 }
17161726
17171727 override NodeBase getChild ( string key ) {
@@ -1720,7 +1730,11 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
17201730 // [ALWAYS_KNOWN]
17211731 key = "Output" and
17221732 result = this .getOutputKeyArtifact ( )
1723- //TODO: how do I output the raw key if known? If not known, it may not require/have a raw value consumer, don't output
1733+ or
1734+ // [KnOWN_OR_UNKNOWN] only if a raw key is a known input
1735+ key = "KeyInput" and
1736+ keyGenInstance .hasKeyValueConsumer ( ) and
1737+ result = this .getKeyArtifact ( )
17241738 }
17251739 }
17261740
0 commit comments