Skip to content

Adding new examples and example test runner #165

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 6 commits into from
Mar 31, 2020
Merged

Conversation

WesleyRosenblum
Copy link
Contributor

@WesleyRosenblum WesleyRosenblum commented Mar 20, 2020

This adds example code to match the format defined in
aws/aws-encryption-sdk-python#219. Legacy tests were reverted to how they are currently in the master branch and moved to the Legacy folder
All examples are tested using JUnit5 Dynamic tests.

Check any applicable:

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

Legacy example code was moved to the examples/legacy package

SalusaSecondus
SalusaSecondus previously approved these changes Mar 20, 2020
Copy link
Contributor

@SalusaSecondus SalusaSecondus left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Notes on the file streaming example that will apply to all.

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.

Comments on KMS and multi-keyring examples. Raw keyring comments coming soon.

// Generate an RSA key pair to use with your keyring.
// In practice, you should get this key from a secure key management system such as an HSM.
final KeyPairGenerator kg = KeyPairGenerator.getInstance("RSA");
kg.initialize(4096); // Escrow keys should be very strong
Copy link
Member

Choose a reason for hiding this comment

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

As a naive reader, what does that mean? How do I know that 4096 is strong?

I like actually mentioning the key size, but we should point to a reference for what key size we recommend and why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What if I just say “The National Institute of Standards and Technology (NIST) recommends a minimum of 2048-bit keys for RSA” and maybe link to https://www.nist.gov/publications/transitioning-use-cryptographic-algorithms-and-key-lengths or https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57Pt3r1.pdf

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually https://www.nist.gov/publications/transitioning-use-cryptographic-algorithms-and-key-lengths is a more readable reference and links to 56Br2 anyway

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.

A few more minor changes. Otherwise LGTM.

Very happy that we'll be running these examples in our test suite! :D

SecureRandom rnd = new SecureRandom();
byte[] rawKey = new byte[16]; // 128 bits
rnd.nextBytes(rawKey);
SecretKey key = new SecretKeySpec(rawKey, "AES");
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a note that the mode defined here (if any) does not affect the behavior of the keyring?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually it does have to be AES, the keyring fails if not

@mattsb42-aws
Copy link
Member

Oh, one other thing that I forgot: How different is the process for loading a RSA key/pair from PEM/DER? Does Java provide something for that in the standard JCE toolset?

mattsb42-aws
mattsb42-aws previously approved these changes Mar 24, 2020
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.

I'd like to hold off on merging until @juneb signs off on aws/aws-encryption-sdk-python#221, but other than that, this LGTM. :)

@WesleyRosenblum WesleyRosenblum merged commit 2d025a8 into keyring Mar 31, 2020
@WesleyRosenblum WesleyRosenblum deleted the examples branch April 2, 2020 18:31
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.

3 participants