-
Couldn't load subscription status.
- Fork 18
feat: Enforce Rotation Functionality for ReEncrypt-feature #474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Enforce Rotation Functionality for ReEncrypt-feature #474
Conversation
…file implementation
…stom instruction file suffix if specified
…on files with AES + RSA keyrings and both of these tests pass
… third-party client is unable toretrieve the encrypted object in s3 if they do not include the overrideConfiguration with their custom instruction file suffix since it will by default use the original instruction file, not theirs.:
…ion object, not the object itself. Also reworded one of the exception messages to be clearer for when instruction file suffix request is specified for AES keyring (which should not happen)
…MaterialsDescription class
…ataKeyMatDescOrContext()
… support both the default and custom instruction file suffixes
… since secureRandom should now be initialized by default. I also removed all the unused imports
…SA keyrings in all of the test cases
….encryptedDataKeyMatDescOrContext()
…r enforceRotation in javadoc
…file suffix + legacy wrapping algorithm upgrades from V1/V2 to V3
…eSuffix to mention that the . prefix is automatically added to the suffix + in reEncryptInstructionFileResponse, the . prefix will be removed from the suffix and return what the user requested the suffix be
…odified test cases to illustrate this
| DecryptionMaterials decryptedMaterials = this._cryptoMaterialsManager.decryptMaterials( | ||
| DecryptMaterialsRequest.builder() | ||
| .algorithmSuite(newEncryptionMaterials.algorithmSuite()) | ||
| .encryptedDataKeys(Collections.singletonList(newEncryptionMaterials.encryptedDataKeys()).get(0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .encryptedDataKeys(Collections.singletonList(newEncryptionMaterials.encryptedDataKeys()).get(0)) | |
| .encryptedDataKeys(newEncryptionMaterials.encryptedDataKeys()) |
| } catch (S3EncryptionClientException e) { | ||
| return; | ||
| } | ||
| throw new S3EncryptionClientException("Key rotation is not enforced! Old keyring is still able to decrypt the newly encrypted data key"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change this a bit. Instead of Key rotation is not enforced! (this kind of implies that enforceRotation is not set), maybe say Re-encryption failed due to enforced rotation! (then the second sentence).
| } | ||
| | ||
| /** | ||
| * Sets whether to enforce rotation for the re-encrypted instruction file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's give a bit more info here:
When enabled, the client will attempt to decrypt the re-encrypted instruction file with the old key material and throw an exception when decryption succeeds. This is a stronger level of validation that the wrapping key has been rotated than the standard assertion that the materials descriptions are different.
| ReEncryptInstructionFileResponse response = client.reEncryptInstructionFile(reEncryptInstructionFileRequest); | ||
| assertTrue(response.enforceRotation()); | ||
| } catch (S3EncryptionClientException e) { | ||
| throw new RuntimeException("Enforce rotation should not throw exception"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| throw new RuntimeException("Enforce rotation should not throw exception"); | |
| fail("Enforce rotation should not throw exception"); |
| | ||
| try { | ||
| ReEncryptInstructionFileResponse response = client.reEncryptInstructionFile(reEncryptInstructionFileRequest); | ||
| throw new RuntimeException("Enforce rotation should throw exception"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| throw new RuntimeException("Enforce rotation should throw exception"); | |
| fail("Enforce rotation should throw exception"); |
| ReEncryptInstructionFileResponse response = v3OriginalClient.reEncryptInstructionFile(reEncryptInstructionFileRequest); | ||
| assertTrue(response.enforceRotation()); | ||
| } catch (S3EncryptionClientException e) { | ||
| throw new RuntimeException("Enforce rotation should not throw exception"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| throw new RuntimeException("Enforce rotation should not throw exception"); | |
| fail("Enforce rotation should not throw exception"); |
| | ||
| try { | ||
| ReEncryptInstructionFileResponse response = v3OriginalClient.reEncryptInstructionFile(reEncryptInstructionFileRequest); | ||
| throw new RuntimeException("Enforce rotation should throw exception"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| throw new RuntimeException("Enforce rotation should throw exception"); | |
| fail("Enforce rotation should throw exception"); |
| ReEncryptInstructionFileResponse response = v3OriginalClient.reEncryptInstructionFile(reEncryptInstructionFileRequest); | ||
| assertTrue(response.enforceRotation()); | ||
| } catch (S3EncryptionClientException e) { | ||
| throw new RuntimeException("Enforce rotation should not throw exception"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| throw new RuntimeException("Enforce rotation should not throw exception"); | |
| fail("Enforce rotation should not throw exception"); |
| ReEncryptInstructionFileResponse response = v3OriginalClient.reEncryptInstructionFile(reEncryptInstructionFileRequest); | ||
| assertTrue(response.enforceRotation()); | ||
| } catch (S3EncryptionClientException e) { | ||
| throw new RuntimeException("Enforce rotation should not throw exception"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| throw new RuntimeException("Enforce rotation should not throw exception"); | |
| fail("Enforce rotation should not throw exception"); |
| | ||
| try { | ||
| ReEncryptInstructionFileResponse response = v3OriginalClient.reEncryptInstructionFile(reEncryptInstructionFileRequest); | ||
| throw new RuntimeException("Enforce rotation should throw exception"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| throw new RuntimeException("Enforce rotation should throw exception"); | |
| fail("Enforce rotation should throw exception"); |
…ation only (not for custom instruction file suffix since it does not make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Description of changes:
I implemented the Enforce Rotation check for the ReEncrypt feature and I also wrote some test cases to test this logic.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Check any applicable: