Skip to content

docs: add a sample custom master key provider - #445

Open
MaxonT wants to merge 1 commit into
aws:masterfrom
MaxonT:contrib/124-auto
Open

MaxonT wants to merge 1 commit into
aws:masterfrom
MaxonT:contrib/124-auto

Conversation

@MaxonT

@MaxonT MaxonT commented Nov 25, 2026

Copy link
Copy Markdown

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: a RawMasterKeyProvider subclass that wraps data keys with AES-256-GCM using a 32-byte key read from a file (the key value 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, plus key_ids) and how to reject bad input with BadUserArgumentError.
  • examples/custom_master_key_provider/setup.py: registers the factory in the aws_encryption_sdk_cli.master_key_providers entry point group.
  • examples/custom_master_key_provider/README.rst: explains the three pieces and gives an encrypt and decrypt walkthrough using provider=example-file-key.
  • README.rst (External Master Key Providers) and examples/README.rst link 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 with provider=example-file-key key=<path> succeeded, decrypt with the same key returned the original plaintext, decrypt with a different 32-byte key failed with DecryptKeyError("Unable to decrypt any data key") (exit 1), and passing an unknown parameter (foo=bar) failed with the BadUserArgumentError message. The sample imports WrappingKey from aws_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.

Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>
@MaxonT
MaxonT requested a review from a team as a code owner November 25, 2026 06:57

This branch has not been deployed

No deployments
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.

1 participant