Make ArtifactConsumers instances of some Artifacts

TODO: refactor the interfaces
This commit is contained in:
Nicolas Will
2025-02-27 15:54:38 +01:00
parent ef0614ad45
commit 0354afc365
3 changed files with 69 additions and 41 deletions

View File

@@ -205,12 +205,16 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
abstract AlgorithmElement getAKnownAlgorithmSource();
}
abstract class ArtifactConsumer extends ConsumerElement {
abstract class ArtifactConsumer extends ConsumerElement, ArtifactElement {
final override KnownElement getAKnownSource() { result = this.getAKnownArtifactSource() }
final ArtifactElement getAKnownArtifactSource() { result.flowsTo(this) }
}
abstract class NonceArtifactConsumer extends ArtifactConsumer {
NonceArtifactInstance asNonce() { result = this }
}
abstract class CipherOperationInstance extends OperationElement {
/**
* Gets the subtype of this cipher operation, distinguishing encryption, decryption, key wrapping, and key unwrapping.
@@ -220,7 +224,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
/**
* Gets the consumer of nonces/IVs associated with this cipher operation.
*/
abstract ArtifactConsumer getNonceConsumer();
abstract NonceArtifactConsumer getNonceConsumer();
/**
* Gets the consumer of plaintext or ciphertext input associated with this cipher operation.
@@ -586,13 +590,8 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
result = instance.getCipherOperationSubtype()
}
NodeBase getANonceOrUnknown() {
result =
this.asElement().(CipherOperationInstance).getNonceConsumer().getAKnownOrUnknownSourceNode()
}
NonceNode getANonce() {
result = this.asElement().(CipherOperationInstance).getNonceConsumer().getAKnownSourceNode()
result.asElement() = this.asElement().(CipherOperationInstance).getNonceConsumer().asNonce()
}
NodeBase getAMessageOrUnknown() {
@@ -614,9 +613,7 @@ module CryptographyBase<LocationSig Location, InputSig<Location> Input> {
or
// [KNOWN_OR_UNKNOWN]
key = "Nonce" and
if exists(this.getANonceOrUnknown())
then result = this.getANonceOrUnknown()
else result = this
if exists(this.getANonce()) then result = this.getANonce() else result = this
or
// [KNOWN_OR_UNKNOWN]
key = "Message" and