Skip to content

Commit 66e8dab

Browse files
Adding NIST recommendation for RSA
1 parent 619ad06 commit 66e8dab

File tree

6 files changed

+15
-7
lines changed

6 files changed

+15
-7
lines changed

src/examples/java/com/amazonaws/crypto/examples/keyring/awskms/DiscoveryDecryptWithPreferredRegions.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static void run(final AwsKmsCmkId awsKmsCmk, final byte[] sourcePlaintext
9292

9393
// Finally, combine those two keyrings into a multi-keyring.
9494
//
95-
// The multi-keyring steps through its member keyrings in the order that you provider them,
95+
// The multi-keyring steps through its member keyrings in the order that you provide them,
9696
// attempting to decrypt every encrypted data key with each keyring before moving on to the next keyring.
9797
// Because of this, otherRegionsDecryptKeyring will not be called
9898
// unless localRegionDecryptKeyring fails to decrypt every encrypted data key.
@@ -109,7 +109,7 @@ public static void run(final AwsKmsCmkId awsKmsCmk, final byte[] sourcePlaintext
109109
// Demonstrate that the ciphertext and plaintext are different.
110110
assert !Arrays.equals(ciphertext, sourcePlaintext);
111111

112-
// Decrypt your encrypted data using the multi keyring.
112+
// Decrypt your encrypted data using the multi-keyring.
113113
//
114114
// We do not need to specify the encryption context on decrypt
115115
// because the header message includes the encryption context.

src/examples/java/com/amazonaws/crypto/examples/keyring/awskms/MultipleRegions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
public class MultipleRegions {
3838

3939
/**
40-
* Demonstrate an encrypt/decrypt cycle using a KMS keyring with a single CMK.
40+
* Demonstrate an encrypt/decrypt cycle using a KMS keyring with CMKs in multiple regions.
4141
*
4242
* @param awsKmsGeneratorCmk The ARN of an AWS KMS CMK that protects data keys
4343
* @param awsKmsAdditionalCmks Additional ARNs of secondary KMS CMKs

src/examples/java/com/amazonaws/crypto/examples/keyring/multi/AwsKmsWithEscrow.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ public static void run(final AwsKmsCmkId awsKmsCmk, final byte[] sourcePlaintext
6262
// Generate an RSA key pair to use with your keyring.
6363
// In practice, you should get this key from a secure key management system such as an HSM.
6464
final KeyPairGenerator kg = KeyPairGenerator.getInstance("RSA");
65-
kg.initialize(4096); // Escrow keys should be very strong
65+
// The National Institute of Standards and Technology (NIST) recommends a minimum of 2048-bit keys for RSA.
66+
// https://www.nist.gov/publications/transitioning-use-cryptographic-algorithms-and-key-lengths
67+
kg.initialize(4096);
6668
final KeyPair keyPair = kg.generateKeyPair();
6769

6870
// Create the encrypt keyring that only has access to the public key.

src/examples/java/com/amazonaws/crypto/examples/keyring/rawrsa/PublicPrivateKeySeparate.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ public static void run(final byte[] sourcePlaintext) throws GeneralSecurityExcep
5858
// Generate an RSA key pair to use with your keyring.
5959
// In practice, you should get this key from a secure key management system such as an HSM.
6060
final KeyPairGenerator kg = KeyPairGenerator.getInstance("RSA");
61-
kg.initialize(4096); // Escrow keys should be very strong
61+
// The National Institute of Standards and Technology (NIST) recommends a minimum of 2048-bit keys for RSA.
62+
// https://www.nist.gov/publications/transitioning-use-cryptographic-algorithms-and-key-lengths
63+
kg.initialize(4096);
6264
final KeyPair keyPair = kg.generateKeyPair();
6365

6466
// Create the keyring that determines how your data keys are protected.

src/examples/java/com/amazonaws/crypto/examples/keyring/rawrsa/RawRsa.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ public static void run(final byte[] sourcePlaintext) throws GeneralSecurityExcep
4848
// Generate an RSA key pair to use with your keyring.
4949
// In practice, you should get this key from a secure key management system such as an HSM.
5050
final KeyPairGenerator kg = KeyPairGenerator.getInstance("RSA");
51-
kg.initialize(4096); // Escrow keys should be very strong
51+
// The National Institute of Standards and Technology (NIST) recommends a minimum of 2048-bit keys for RSA.
52+
// https://www.nist.gov/publications/transitioning-use-cryptographic-algorithms-and-key-lengths
53+
kg.initialize(4096);
5254
final KeyPair keyPair = kg.generateKeyPair();
5355

5456
// Create the keyring that determines how your data keys are protected.

src/examples/java/com/amazonaws/crypto/examples/legacy/EscrowedEncryptExample.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ private static void escrowDecrypt(final String fileName) throws Exception {
153153

154154
private static void generateEscrowKeyPair() throws GeneralSecurityException {
155155
final KeyPairGenerator kg = KeyPairGenerator.getInstance("RSA");
156-
kg.initialize(4096); // Escrow keys should be very strong
156+
// The National Institute of Standards and Technology (NIST) recommends a minimum of 2048-bit keys for RSA.
157+
// https://www.nist.gov/publications/transitioning-use-cryptographic-algorithms-and-key-lengths
158+
kg.initialize(4096);
157159
final KeyPair keyPair = kg.generateKeyPair();
158160
publicEscrowKey = keyPair.getPublic();
159161
privateEscrowKey = keyPair.getPrivate();

0 commit comments

Comments
 (0)