Skip to content

feat: remove wrapping_algorithm input parameter from RawAESKeyring #247

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 3 commits into from
Apr 14, 2020
Merged

feat: remove wrapping_algorithm input parameter from RawAESKeyring #247

merged 3 commits into from
Apr 14, 2020

Conversation

mattsb42-aws
Copy link
Member

Issue #, if available:
resolves: #246

Description of changes:

This implements proposed solution number 2 detailed in #246, removing wrapping algorithm as an input parameter, restricting wrapping key material length to supported lengths, and deriving the wrapping algorithm suite from the wrapping key material length.

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.

#
# In practice, you should get this key from a secure key management system such as an HSM.
key = os.urandom(wrapping_algorithm.algorithm.kdf_input_len)
key = os.urandom(32)
Copy link
Contributor

Choose a reason for hiding this comment

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

The java version of this example has a comment here "256 bits" to draw the connection to AES-256

Copy link
Member Author

@mattsb42-aws mattsb42-aws Apr 14, 2020

Choose a reason for hiding this comment

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

line 32:

# Generate an AES-256 key to use with your keyring.

Do you think it would be clearer to say "a 256-bit AES key"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that sounds good, or maybe "a 256-bit (32 byte) AES key"

self._wrapping_algorithm = key_size_to_wrapping_algorithm[len(self._wrapping_key)]
except KeyError:
raise ValueError(
"Invalid wrapping key length. Must be one of {}".format(key_size_to_wrapping_algorithm.keys())
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this error message look like, would it print out "Must be one of AES_128_GCM_IV12_TAG16_NO_PADDING, AES_192_GCM_IV12_TAG16_NO_PADDING, etc" or just the key sizes?

Copy link
Member Author

Choose a reason for hiding this comment

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

It would print out the key sizes.

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated this to be deterministic (it already was for 3.6+ but not for 3.5 or 2.7) and updated the test to catch any changes to the set.

@mattsb42-aws mattsb42-aws merged commit a6433d4 into aws:keyring Apr 14, 2020
@mattsb42-aws mattsb42-aws deleted the dev-246-2 branch April 14, 2020 19:28
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.

2 participants