Skip to content

Commit 35333e1

Browse files
rename AttemptKmsOperation? to AttemptKmsOperationForHV1?
1 parent 1aa9758 commit 35333e1

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStore/src/GetKeys.dfy

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ module GetKeys {
9898
//= aws-encryption-sdk-specification/framework/branch-key-store.md#getactivebranchkey
9999
//= type=implication
100100
//# The operation MUST decrypt the EncryptedHierarchicalKey according to the [AWS KMS Branch Key Decryption](#aws-kms-branch-key-decryption) section.
101-
&& KMSKeystoreOperations.AwsKmsBranchKeyDecryption?(
101+
&& KMSKeystoreOperations.AwsKmsBranchKeyDecryptionForHV1?(
102102
activeItem,
103103
kmsConfiguration,
104104
grantTokens,
@@ -335,7 +335,7 @@ module GetKeys {
335335
//= aws-encryption-sdk-specification/framework/branch-key-store.md#getbranchkeyversion
336336
//= type=implication
337337
//# The operation MUST decrypt the branch key according to the [AWS KMS Branch Key Decryption](#aws-kms-branch-key-decryption) section.
338-
&& KMSKeystoreOperations.AwsKmsBranchKeyDecryption?(
338+
&& KMSKeystoreOperations.AwsKmsBranchKeyDecryptionForHV1?(
339339
versionItem,
340340
kmsConfiguration,
341341
grantTokens,
@@ -514,7 +514,7 @@ module GetKeys {
514514
//= aws-encryption-sdk-specification/framework/branch-key-store.md#getbeaconkey
515515
//= type=implication
516516
//# The operation MUST decrypt the beacon key according to the [AWS KMS Branch Key Decryption](#aws-kms-branch-key-decryption) section.
517-
&& KMSKeystoreOperations.AwsKmsBranchKeyDecryption?(
517+
&& KMSKeystoreOperations.AwsKmsBranchKeyDecryptionForHV1?(
518518
beaconItem,
519519
kmsConfiguration,
520520
grantTokens,

AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStore/src/KMSKeystoreOperations.dfy

+16-4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ module {:options "/functionSyntax:4" } KMSKeystoreOperations {
5959
case mrDiscovery(obj) => KmsArn.ValidKmsArn?(encryptionContext[Structure.KMS_FIELD])
6060
}
6161

62+
// The input KeyID MUST be from Dynamodb item of keystore
63+
predicate AttemptKmsOperationForHV2?(kmsConfiguration: Types.KMSConfiguration, keyID: string)
64+
ensures AttemptKmsOperationForHV2?(kmsConfiguration, keyID) && HasKeyId(kmsConfiguration)
65+
==> Compatible?(kmsConfiguration, keyID)
66+
{
67+
match kmsConfiguration
68+
case kmsKeyArn(arn) => (arn == keyID) && KmsArn.ValidKmsArn?(arn)
69+
case kmsMRKeyArn(arn) => MrkMatch(arn, keyID) && KmsArn.ValidKmsArn?(arn)
70+
case discovery(obj) => KmsArn.ValidKmsArn?(keyID)
71+
case mrDiscovery(obj) => KmsArn.ValidKmsArn?(keyID)
72+
}
73+
6274
predicate Compatible?(kmsConfiguration: Types.KMSConfiguration, keyId : string)
6375
requires(HasKeyId(kmsConfiguration))
6476
{
@@ -576,7 +588,7 @@ module {:options "/functionSyntax:4" } KMSKeystoreOperations {
576588
ensures output.Success?
577589
==>
578590
&& |kmsClient.History.Decrypt| == |old(kmsClient.History.Decrypt)| + 1
579-
&& AwsKmsBranchKeyDecryption?(
591+
&& AwsKmsBranchKeyDecryptionForHV1?(
580592
encryptedKey,
581593
kmsConfiguration,
582594
grantTokens,
@@ -643,12 +655,12 @@ module {:options "/functionSyntax:4" } KMSKeystoreOperations {
643655
ensures kmsClient.ValidState()
644656

645657
ensures !KmsArn.ValidKmsArn?(encryptedKey.KmsArn) ==> output.Failure?
646-
ensures !AttemptKmsOperationForHV1?(kmsConfiguration, encryptedKey.EncryptionContext) ==> output.Failure?
658+
ensures !AttemptKmsOperationForHV2?(kmsConfiguration, encryptedKey.KmsArn) ==> output.Failure?
647659

648660
ensures output.Success?
649661
==>
650662
&& |kmsClient.History.Decrypt| == |old(kmsClient.History.Decrypt)| + 1
651-
&& AwsKmsBranchKeyDecryption?(
663+
&& AwsKmsBranchKeyDecryptionForHV1?(
652664
encryptedKey,
653665
kmsConfiguration,
654666
grantTokens,
@@ -702,7 +714,7 @@ module {:options "/functionSyntax:4" } KMSKeystoreOperations {
702714
}
703715

704716

705-
ghost predicate AwsKmsBranchKeyDecryption?(
717+
ghost predicate AwsKmsBranchKeyDecryptionForHV1?(
706718
versionItem: Types.EncryptedHierarchicalKey,
707719
kmsConfiguration: Types.KMSConfiguration,
708720
grantTokens: KMS.GrantTokenList,

0 commit comments

Comments
 (0)