Skip to content

docs: add CMM examples #239

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 12 commits into from
Apr 9, 2020
Merged

docs: add CMM examples #239

merged 12 commits into from
Apr 9, 2020

Conversation

mattsb42-aws
Copy link
Member

@mattsb42-aws mattsb42-aws commented Apr 7, 2020

Issue #, if available:
#156

Description of changes:
Adds examples for using and creating CMMs.

As always, everyone is welcome to review anything, but what I'm specifically looking for from each reviewer:

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 7, 2020
@ttjsu-aws ttjsu-aws mentioned this pull request Apr 7, 2020
15 tasks
@mattsb42-aws
Copy link
Member Author

Note for the record: all failing checks are expected. They are all from the test vector handler workflow. The tests from that workflow actually should not be running on pull request events, but I'll figure that out in a different PR.

def get_encryption_materials(self, request):
# type: (EncryptionMaterialsRequest) -> EncryptionMaterials
"""Block any requests that include an algorithm suite without a KDF."""
if request.algorithm is not None and request.algorithm.kdf is KDFSuite.NONE:
Copy link
Contributor

Choose a reason for hiding this comment

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

There isn't a particularly elegant way to do this in the Java ESDK. It would be something like:

if(!request.getRequestedAlgorithm().getDataKeyAlgo().contains("Hkdf"))

I wouldn't normally recommend someone write code that depends on a string in that way. Alternatively, both Java and Python both have the isSafeToCache parameter, could this make use of that instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe. If we want to go that route I want to re-frame what the example is about: changing it from specifically barring non-KDF suites to instead making sure that you can cache the request.

Another option would be changing the requirement to be one of our two recommended (default or default - signing).

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, I'd say let's do the second option. The example doesn't have to do anything particularly interesting or innovative to serve its purpose, that would show a basic validation so the user can get a sense of whats possible.


def run(aws_kms_cmk, source_plaintext):
# type: (str, bytes) -> None
"""Demonstrate an encrypt/decrypt cycle using a KMS keyring with a single CMK.
Copy link
Contributor

Choose a reason for hiding this comment

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

Update

# Create the keyring that determines how your data keys are protected.
keyring = KmsKeyring(generator_key_id=aws_kms_cmk)

# Create the filtering cryptographic materials manager using your keyring.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the first time you used the terminology "filtering CMM". Do you want to introduce that at the top?

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 was just shorthand I was using, but you're right; I'll just replace these with references back to the actual custom CMM.


def run(aws_kms_cmk, source_plaintext):
# type: (str, bytes) -> None
"""Demonstrate an encrypt/decrypt cycle using a KMS keyring with a single CMK.
Copy link
Contributor

Choose a reason for hiding this comment

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

update

# Create the keyring that determines how your data keys are protected.
keyring = KmsKeyring(generator_key_id=aws_kms_cmk)

# Create the filtering cryptographic materials manager using your keyring.
Copy link
Contributor

Choose a reason for hiding this comment

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

same as algorithm_suite_enforcement, this is the first time you mention filtering cmm. Might be worth introducing the term at the top


def run(aws_kms_cmk, source_plaintext):
# type: (str, bytes) -> None
"""Demonstrate an encrypt/decrypt cycle using a KMS keyring with a single CMK.
Copy link
Contributor

Choose a reason for hiding this comment

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

update

If you supply a keyring or master key provider
those components will automatically wrap it in a default CMM.

This example shows how you could do this manually if you wanted to.
Copy link
Contributor

Choose a reason for hiding this comment

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

This example I'm a little unsure is necessary. It is useful in terms of educating the user about the default CMM, but practically, without any additional functionality, it is pointless. Would it be enough to include the description of the default CMM in one of the other examples?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe. What I was going for is demonstrating how to use the default CMM if you need it, such as if you're making a custom CMM that you configure using keyrings. More explanation in the other examples might be sufficient, yeah.

Copy link
Contributor

@WesleyRosenblum WesleyRosenblum left a comment

Choose a reason for hiding this comment

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

Nice job making all these examples :-)

@mattsb42-aws mattsb42-aws merged commit cd2a171 into aws:keyring Apr 9, 2020
@mattsb42-aws mattsb42-aws deleted the cmm-examples branch April 9, 2020 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants