Skip to content

Conversation

@rishav-karanjit
Copy link
Member

@rishav-karanjit rishav-karanjit commented Apr 21, 2025

Issue #, if available:

Description of changes:

Squash/merge commit message, if applicable:

chore(dafny): Test hv1 to hv2 mutation 

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

const KmsSrkConfigWest : Types.KMSConfiguration := Types.KMSConfiguration.kmsKeyArn(MrkArnWest)
const KmsMrkConfigAP : Types.KMSConfiguration := Types.KMSConfiguration.kmsMRKeyArn(MrkArnAP)
const KmsMrkEC : Types.EncryptionContext := map[UTF8.EncodeAscii("abc") := UTF8.EncodeAscii("123")]
const RobbieEC : Types.EncryptionContext := map[UTF8.EncodeAscii("Robbie") := UTF8.EncodeAscii("is a dog.")]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This did not break any test because this was only used in create keys

var encryptRes :- expect KMSKeystoreOperations.EncryptKey(
plainTextTuple,
HVUtils.SelectKmsEncryptionContextForHv2(terminalBKC),
item.EncryptionContext[Structure.KMS_FIELD],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

item will be overwritten with new mutation properties on Structure.ConstructEncryptedHierarchicalKey (line 605). So, using item.* won't work

expect "type" in item.EncryptionContext, "Decrypt Only item is missing 'type' from EC!!";
verifyTerminalProperties(item.EncryptionContext, expectedEncryptionContext, expectedKmsArn);

// Get branchKeyVersion from storage
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keystore returns EC send to KMS (customer send EC without transformation) but storage returns a "actual" EC (with transformation)

@rishav-karanjit rishav-karanjit marked this pull request as ready for review April 22, 2025 20:22
@rishav-karanjit rishav-karanjit requested a review from a team as a code owner April 22, 2025 20:22
@rishav-karanjit rishav-karanjit changed the title chore(dafny): WIP hv1 to hv2 chore(dafny): Test hv1 to hv2 mutation Apr 22, 2025
include "AdminFixtures.dfy"
include "Mutations/TestMutationHappyPath.dfy"

// TODO-HV-2-M2: Move this to ./Mutations
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did it in this PR but the Github was showing diff as whole file which makes reviewer's life hard. So, doing this right after this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yay removing dead code

HVUtils.SelectKmsEncryptionContextForHv2(terminalBKC),
item.EncryptionContext[Structure.KMS_FIELD],
KmsUtils.KmsSymmetricKeyArnToKMSConfiguration(Types.KmsSymmetricKeyArn.KmsKeyArn(item.KmsArn)),
terminalBKC[Structure.KMS_FIELD],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would move
terminalBKC[Structure.KMS_FIELD] to a variable above
and call it
var terminalBKCKmsArn := terminalBKC[Structure.KMS_FIELD]

Copy link
Contributor

@josecorella josecorella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rishav-karanjit rishav-karanjit merged commit 4867143 into hv-2/hv-2 Apr 22, 2025
266 of 268 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants