@@ -70,22 +70,22 @@ public static void main(final String[] args) throws Exception {
70
70
71
71
private static void standardEncrypt (final String kmsArn , final String fileName ) throws Exception {
72
72
// Encrypt with the KMS CMK and the escrowed public key
73
- // 1. Instantiate the AWS Encryption SDK
73
+ // 1. Instantiate the AWS Encryption SDK.
74
74
final AwsCrypto crypto = new AwsCrypto ();
75
75
76
- // 2. Instantiate a KMS master key provider
76
+ // 2. Instantiate a KMS master key provider.
77
77
final KmsMasterKeyProvider kms = new KmsMasterKeyProvider (kmsArn );
78
78
79
- // 3. Instantiate a JCE master key provider
79
+ // 3. Instantiate a JCE master key provider.
80
80
// Because the user does not have access to the private escrow key,
81
81
// they pass in "null" for the private key parameter.
82
82
final JceMasterKey escrowPub = JceMasterKey .getInstance (publicEscrowKey , null , "Escrow" , "Escrow" ,
83
83
"RSA/ECB/OAEPWithSHA-512AndMGF1Padding" );
84
84
85
- // 4. Combine the providers into a single master key provider
85
+ // 4. Combine the providers into a single master key provider.
86
86
final MasterKeyProvider <?> provider = MultipleProviderFactory .buildMultiProvider (kms , escrowPub );
87
87
88
- // 5. Encrypt the file
88
+ // 5. Encrypt the file.
89
89
// To simplify the code, we omit the encryption context. Production code should always
90
90
// use an encryption context. For an example, see the other SDK samples.
91
91
final FileInputStream in = new FileInputStream (fileName );
@@ -101,22 +101,22 @@ private static void standardDecrypt(final String kmsArn, final String fileName)
101
101
// Decrypt with the KMS CMK and the escrow public key. You can use a combined provider,
102
102
// as shown here, or just the KMS master key provider.
103
103
104
- // 1. Instantiate the AWS Encryption SDK
104
+ // 1. Instantiate the AWS Encryption SDK.
105
105
final AwsCrypto crypto = new AwsCrypto ();
106
106
107
- // 2. Instantiate a KMS master key provider
107
+ // 2. Instantiate a KMS master key provider.
108
108
final KmsMasterKeyProvider kms = new KmsMasterKeyProvider (kmsArn );
109
109
110
- // 3. Instantiate a JCE master key provider
110
+ // 3. Instantiate a JCE master key provider.
111
111
// Because the user does not have access to the private
112
112
// escrow key, they pass in "null" for the private key parameter.
113
113
final JceMasterKey escrowPub = JceMasterKey .getInstance (publicEscrowKey , null , "Escrow" , "Escrow" ,
114
114
"RSA/ECB/OAEPWithSHA-512AndMGF1Padding" );
115
115
116
- // 4. Combine the providers into a single master key provider
116
+ // 4. Combine the providers into a single master key provider.
117
117
final MasterKeyProvider <?> provider = MultipleProviderFactory .buildMultiProvider (kms , escrowPub );
118
118
119
- // 5. Decrypt the file
119
+ // 5. Decrypt the file.
120
120
// To simplify the code, we omit the encryption context. Production code should always
121
121
// use an encryption context. For an example, see the other SDK samples.
122
122
final FileInputStream in = new FileInputStream (fileName + ".encrypted" );
@@ -131,15 +131,15 @@ private static void escrowDecrypt(final String fileName) throws Exception {
131
131
// You can decrypt the stream using only the private key.
132
132
// This method does not call KMS.
133
133
134
- // 1. Instantiate the AWS Encryption SDK
134
+ // 1. Instantiate the AWS Encryption SDK.
135
135
final AwsCrypto crypto = new AwsCrypto ();
136
136
137
- // 2. Instantiate a JCE master key provider
138
- // This method call uses the escrowed private key, not null
137
+ // 2. Instantiate a JCE master key provider.
138
+ // This method call uses the escrowed private key, not null.
139
139
final JceMasterKey escrowPriv = JceMasterKey .getInstance (publicEscrowKey , privateEscrowKey , "Escrow" , "Escrow" ,
140
140
"RSA/ECB/OAEPWithSHA-512AndMGF1Padding" );
141
141
142
- // 3. Decrypt the file
142
+ // 3. Decrypt the file.
143
143
// To simplify the code, we omit the encryption context. Production code should always
144
144
// use an encryption context. For an example, see the other SDK samples.
145
145
final FileInputStream in = new FileInputStream (fileName + ".encrypted" );
0 commit comments