Skip to content

Commit b681bd9

Browse files
committed
Throw exception on decrypt if plaintext data key already present.
1 parent 05cfffd commit b681bd9

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/main/java/software/amazon/encryption/s3/materials/AesGcmKeyring.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public EncryptionMaterials onEncrypt(EncryptionMaterials materials) {
8181
@Override
8282
public DecryptionMaterials onDecrypt(final DecryptionMaterials materials, List<EncryptedDataKey> encryptedDataKeys) {
8383
if (materials.plaintextDataKey() != null) {
84-
return materials;
84+
throw new S3EncryptionClientException("Decryption materials already contains a plaintext data key.");
8585
}
8686

8787
for (EncryptedDataKey encryptedDataKey : encryptedDataKeys) {

src/main/java/software/amazon/encryption/s3/materials/KmsContextKeyring.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public EncryptionMaterials onEncrypt(EncryptionMaterials materials) {
8686
@Override
8787
public DecryptionMaterials onDecrypt(final DecryptionMaterials materials, List<EncryptedDataKey> encryptedDataKeys) {
8888
if (materials.plaintextDataKey() != null) {
89-
return materials;
89+
throw new S3EncryptionClientException("Decryption materials already contains a plaintext data key.");
9090
}
9191

9292
for (EncryptedDataKey encryptedDataKey : encryptedDataKeys) {

src/main/java/software/amazon/encryption/s3/materials/RsaOaepKeyring.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public EncryptionMaterials onEncrypt(EncryptionMaterials materials) {
8686
@Override
8787
public DecryptionMaterials onDecrypt(final DecryptionMaterials materials, List<EncryptedDataKey> encryptedDataKeys) {
8888
if (materials.plaintextDataKey() != null) {
89-
return materials;
89+
throw new S3EncryptionClientException("Decryption materials already contains a plaintext data key.");
9090
}
9191

9292
for (EncryptedDataKey encryptedDataKey : encryptedDataKeys) {

0 commit comments

Comments
 (0)