Skip to content

docs: add example to replicate AWS KMS MKP behavior with AWS KMS keyring #255

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

Merged
merged 18 commits into from
Apr 24, 2020
Merged

docs: add example to replicate AWS KMS MKP behavior with AWS KMS keyring #255

merged 18 commits into from
Apr 24, 2020

Conversation

mattsb42-aws
Copy link
Member

Issue #, if available:

resolves: #248

Description of changes:

In addition to using the configured AWS KMS CMKs, the AWS KMS master key provider attempts to decrypt any data keys that were encrypted under an AWS KMS CMK. This behavior is not always obvious, and when we designed the AWS KMS keyring, we decided that it was best to separate these behaviors, but as customers migrate from master key providers to keyrings, it will be helpful to have an example of how to replicate the exact behavior of the AWS KMS master key provider using keyrings.

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

Check any applicable:

  • Were any files moved? Moving files changes their URL, which breaks all hyperlinks to the files.

@mattsb42-aws mattsb42-aws added this to the keyrings milestone Apr 16, 2020
Comment on lines 14 to 15
We have found that separating these two behaviors out,
as we did in the AWS KMS keyring,
Copy link
Contributor

Choose a reason for hiding this comment

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

how about "We have found that separating these two behaviors into the AWS KMS Keyring and the AWS KMS discovery keyring"

@@ -44,6 +44,8 @@ We start with AWS KMS examples, then show how to use other wrapping keys.
* [with keyrings](./src/keyring/aws_kms/discovery_decrypt_in_region_only.py)
* How to decrypt with a preferred region but failover to others
* [with keyrings](./src/keyring/aws_kms/discovery_decrypt_with_preferred_regions.py)
* How to replicate the behavior of an AWS KMS master key provider
Copy link
Contributor

@juneb juneb Apr 17, 2020

Choose a reason for hiding this comment

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

Can we use "reproduce" instead of "replicate?" The KMS is using "replicate" and "replica" for other purposes. Although most people won't notice, I can envisions someone with limited English language skills googling this and becoming hopelessly confused.

# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
"""
Before there were keyrings, there were master key providers.
Copy link
Contributor

Choose a reason for hiding this comment

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

Once upon a time ... :)

Comment on lines 12 to 13
the AWS KMS master key provider always attempts to decrypt
*any* data keys that were encrypted under an AWS KMS CMK.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
the AWS KMS master key provider always attempts to decrypt
*any* data keys that were encrypted under an AWS KMS CMK.
the AWS KMS master key provider can decrypt
*any* data key that was encrypted under an AWS KMS CMK.

-or-

the AWS KMS master key provider can use any AWS KMS CMK that encrypted
a data key to decrypt it. 

Copy link
Member Author

Choose a reason for hiding this comment

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

That's not quite what I was getting at. Whether or not it can decrypt depends on the KMS/IAM permissions. Just like the discovery keyring, the point I was trying to make is that it does in fact reach out to the KMS service for every KMS-encrypted EDK whether or not it succeeds.

Copy link
Contributor

Choose a reason for hiding this comment

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

The difficulty here is the combination of "always" and "any." Does the ESDK always attempt to decrypt all of the encrypted data keys in an encrypted message? Or, it can attempt to decrypt any of them?

Co-Authored-By: June Blender <juneb@users.noreply.github.com>
Comment on lines 4 to 5
In earlier versions of the AWS Encryption SDK,
you used master key providers to determine how your data keys are protected.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In earlier versions of the AWS Encryption SDK,
you used master key providers to determine how your data keys are protected.
You might have used master key providers to protect your data keys in an earlier versions of the AWS Encryption SDK. This example shows how to replace a master key provider with a keyring that behaves the same way.

I might never have used the ESDK before.

Comment on lines 12 to 13
the AWS KMS master key provider always attempts to decrypt
*any* data keys that were encrypted under an AWS KMS CMK.
Copy link
Contributor

Choose a reason for hiding this comment

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

The difficulty here is the combination of "always" and "any." Does the ESDK always attempt to decrypt all of the encrypted data keys in an encrypted message? Or, it can attempt to decrypt any of them?

* show using multiple CMKs
* demonstrate how the generating CMK is defined in both
* explain that it does not matter if the CMK keyring fails
Comment on lines 86 to 90
# This also means that it does not matter if the CMK keyring fails on decrypt,
# for example if you configured it with aliases which would work on encrypt
# but fail to match any encrypted data keys on decrypt,
# because the discovery keyring attempts to decrypt any AWS KMS-encrypted
# data keys that it finds.
Copy link
Contributor

Choose a reason for hiding this comment

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

This sentence is really long, can you break it up?

…_provider.py

Co-Authored-By: Wesley Rosenblum <55108558+WesleyRosenblum@users.noreply.github.com>
@mattsb42-aws mattsb42-aws merged commit 027b127 into aws:master Apr 24, 2020
@mattsb42-aws mattsb42-aws deleted the mkp-keyring-example branch April 24, 2020 16:53
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.

[keyring] add example that replicates the behavior of a KMS master key provider
3 participants