Skip to content

Example for using multiple keys in multiple regions #177

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

Closed
wants to merge 24 commits into from
Closed

Example for using multiple keys in multiple regions #177

wants to merge 24 commits into from

Conversation

caitlin-tibbetts
Copy link
Contributor

@caitlin-tibbetts caitlin-tibbetts commented Jul 24, 2019

Issue #156, example A2.B1.C1

Added an example and a test for when multiple keys in multiple regions are used to encrypt and decrypt a passed-in message.

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

@mattsb42-aws
Copy link
Member

mattsb42-aws commented Jul 24, 2019

Please run:

tox -re autoformat
tox -re "{flake8,pylint}-examples"

@ttjsu-aws ttjsu-aws mentioned this pull request Jul 24, 2019
15 tasks
Copy link
Member

@mattsb42-aws mattsb42-aws left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

In addition to the comments below, please make sure you run tox -re autoformat.

Copy link

@ttjsu-aws ttjsu-aws left a comment

Choose a reason for hiding this comment

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

Great start, let me know if you need help in identifying the different scenarios to test.

… still working on populating the tests correctly, so the CI will fail, but I tested the code with my own KMS CMK ARNs, so I know it will work once the tests are populated (working with Tejeswini on this)
)

# Check that the original message and the decrypted message are the same
assert source_plaintext == plaintext1
Copy link
Member

Choose a reason for hiding this comment

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

The output of the decrypt function will always be bytes.
source_plaintext might not be bytes.

Before this check, let's add a decoding if necessary:

if not isinstance(source_plaintext, bytes):
    plaintext1 = plaintext1.decode("utf-8")
    plaintext2 = plaintext2.decode("utf-8")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this make the assumption that source_plaintext is either bytes or str?

@mattsb42-aws mattsb42-aws changed the base branch from master to keyring March 8, 2020 22:33
@mattsb42-aws mattsb42-aws changed the base branch from keyring to master March 8, 2020 22:54
@mattsb42-aws
Copy link
Member

:/ I think I may have broken this PR by changing it to point at keyring. I was trying to get this merged before I started working through the the #156 work for the keyring release, but that doesn't look like it'll work now.

I'll see if I can merge this into my examples branch and still retain the authorship.

@mattsb42-aws
Copy link
Member

That does appear to have worked. :)

I'll fix up the things that were blocking this merging and incorporate it into my examples revamp. I'll close this PR once I cut that one.

@mattsb42-aws mattsb42-aws mentioned this pull request Mar 9, 2020
1 task
@mattsb42-aws
Copy link
Member

This is now merged in #219.

Thanks @caitlin-tibbetts and sorry this took so long. :)

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.

4 participants