@@ -455,6 +455,12 @@ module AwsKmsKeyring {
455455 // # included in the input [decryption materials]
456456 // # (../structures.md#decryption-materials).
457457 && AlgorithmSuites. GetEncryptKeyLength (input.materials.algorithmSuite) as nat == |res. value. materials. plaintextDataKey. value|
458+ // = aws-encryption-sdk-specification/framework/aws-kms/aws-kms-keyring.md#ondecrypt
459+ // = type=implication
460+ // # To attempt to decrypt a particular [encrypted data key]
461+ // # (../structures.md#encrypted-data-key), OnDecrypt MUST call [AWS KMS
462+ // # Decrypt](https://docs.aws.amazon.com/kms/latest/APIReference/API_Decrypt.html)
463+ // # with the configured AWS KMS client.
458464 && var LastDecrypt := Last (client.History.Decrypt);
459465 && LastDecrypt. output. Success?
460466 && OkForDecrypt (awsKmsArn, awsKmsKey). Pass?
@@ -476,36 +482,26 @@ module AwsKmsKeyring {
476482 // # (https://docs.aws.amazon.com/kms/latest/APIReference/API_Decrypt.html),
477483 // # the keyring MUST call with a request constructed
478484 // # as follows:
479- && KMS. DecryptRequest (
480- //= aws-encryption-sdk-specification/framework/aws-kms/aws-kms-keyring.md#ondecrypt
481- //= type=implication
482- //# - `KeyId` MUST be the configured AWS KMS key identifier.
483- KeyId := Some(awsKmsKey),
484- // = aws-encryption-sdk-specification/framework/aws-kms/aws-kms-keyring.md#ondecrypt
485- // = type=implication
486- // # - `CiphertextBlob` MUST be the [encrypted data key ciphertext]
487- // # (../structures.md#ciphertext).
488- CiphertextBlob := maybeWrappedMaterial. value,
489- // = aws-encryption-sdk-specification/framework/aws-kms/aws-kms-keyring.md#ondecrypt
490- // = type=implication
491- // # - `EncryptionContext` MUST be the [encryption context]
492- // # (../structures.md#encryption-context) included in the input
493- // # [decryption materials](../structures.md#decryption-materials).
494- EncryptionContext := Some (maybeStringifiedEncCtx.value),
495- // = aws-encryption-sdk-specification/framework/aws-kms/aws-kms-keyring.md#ondecrypt
496- // = type=implication
497- // # - `GrantTokens` MUST be this keyring's [grant tokens]
498- // # (https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#grant_token).
499- GrantTokens := Some (grantTokens),
500- EncryptionAlgorithm := None
501- )
502485 // = aws-encryption-sdk-specification/framework/aws-kms/aws-kms-keyring.md#ondecrypt
503486 // = type=implication
504- // # To attempt to decrypt a particular [encrypted data key]
505- // # (../structures.md#encrypted-data-key), OnDecrypt MUST call [AWS KMS
506- // # Decrypt](https://docs.aws.amazon.com/kms/latest/APIReference/API_Decrypt.html)
507- // # with the configured AWS KMS client.
508- == LastDecrypt. input
487+ // # - `KeyId` MUST be the configured AWS KMS key identifier.
488+ && LastDecrypt. input. KeyId == Some (awsKmsKey)
489+ // = aws-encryption-sdk-specification/framework/aws-kms/aws-kms-keyring.md#ondecrypt
490+ // = type=implication
491+ // # - `CiphertextBlob` MUST be the [encrypted data key ciphertext]
492+ // # (../structures.md#ciphertext).
493+ && LastDecrypt. input. CiphertextBlob == maybeWrappedMaterial. value
494+ // = aws-encryption-sdk-specification/framework/aws-kms/aws-kms-keyring.md#ondecrypt
495+ // = type=implication
496+ // # - `EncryptionContext` MUST be the [encryption context]
497+ // # (../structures.md#encryption-context) included in the input
498+ // # [decryption materials](../structures.md#decryption-materials).
499+ && LastDecrypt. input. EncryptionContext == Some (maybeStringifiedEncCtx.value)
500+ // = aws-encryption-sdk-specification/framework/aws-kms/aws-kms-keyring.md#ondecrypt
501+ // = type=implication
502+ // # - `GrantTokens` MUST be this keyring's [grant tokens]
503+ // # (https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#grant_token).
504+ && LastDecrypt. input. GrantTokens == Some (grantTokens)
509505 // = aws-encryption-sdk-specification/framework/aws-kms/aws-kms-keyring.md#ondecrypt
510506 // = type=implication
511507 // # - The `KeyId` field in the response MUST equal the configured AWS
@@ -592,7 +588,13 @@ module AwsKmsKeyring {
592588 && var maybeWrappedMaterial :=
593589 EdkWrapping. GetProviderWrappedMaterial (edk.ciphertext, input.materials.algorithmSuite);
594590 && maybeWrappedMaterial. Success?
595- && KMS. IsValid_CiphertextType (maybeWrappedMaterial.value);
591+ && KMS. IsValid_CiphertextType (maybeWrappedMaterial.value)
592+ && LastDecrypt. input. KeyId == Some (awsKmsKey)
593+ && LastDecrypt. input. CiphertextBlob == maybeWrappedMaterial. value
594+ && LastDecrypt. input. GrantTokens == Some (grantTokens)
595+ && var maybeStringifiedEncCtx := StringifyEncryptionContext (materials.encryptionContext);
596+ && maybeStringifiedEncCtx. Success?
597+ && LastDecrypt. input. EncryptionContext == Some (maybeStringifiedEncCtx.value);
596598
597599 assert decryptClosure. Ensures (Last(attempts). input, Success (SealedDecryptionMaterials), DropLast (attempts));
598600 return Success (Types.OnDecryptOutput(
0 commit comments