Repository navigation
Conversation
Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I added a custom master key provider sample under examples/custom_master_key_provider and linked it from two READMEs; following the walkthrough in a clean Python 3.11 venv, the encrypt and decrypt round trip works, but I didn't run tox.
Issue #, if available: #124
Description of changes:
Adds a runnable sample of a custom master key provider, as requested in #124.
examples/custom_master_key_provider/src/example_master_key_provider.py: aRawMasterKeyProvidersubclass that wraps data keys with AES-256-GCM using a 32-byte key read from a file (thekeyvalue is the file path), and a factory function that is used as the CLI entry point. The factory shows how the CLI hands over parameters (lists keyed by name, pluskey_ids) and how to reject bad input withBadUserArgumentError.examples/custom_master_key_provider/setup.py: registers the factory in theaws_encryption_sdk_cli.master_key_providersentry point group.examples/custom_master_key_provider/README.rst: explains the three pieces and gives an encrypt and decrypt walkthrough usingprovider=example-file-key.README.rst(External Master Key Providers) andexamples/README.rstlink to the sample.The sample is clearly marked as illustrative, since a wrapping key stored unprotected on disk is not suitable for production. It does not need AWS credentials, so it is not part of the KMS-based example tests and no tests were added.
Testing: in a clean Python 3.11 virtualenv with this checkout (4.3.0) and aws-encryption-sdk 3.3.1, I installed the sample package and ran the README commands as written (including the
mkdir). Encrypt withprovider=example-file-key key=<path>succeeded, decrypt with the same key returned the original plaintext, decrypt with a different 32-byte key failed withDecryptKeyError("Unable to decrypt any data key")(exit 1), and passing an unknown parameter (foo=bar) failed with theBadUserArgumentErrormessage. The sample importsWrappingKeyfromaws_encryption_sdk.internal, since I found no public re-export; the README says so. I did not run the repository's tox suites or the example integration tests (they require KMS keys), and I did not render the READMEs on GitHub, so the relative links are unchecked there.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.