diff --git a/pom.xml b/pom.xml
index 57a5d1812..49ffe78e2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,7 +56,7 @@
software.amazon.awssdk
bom
- 2.30.38
+ 2.31.14
true
pom
import
@@ -68,13 +68,13 @@
software.amazon.awssdk
s3
- 2.30.38
+ 2.31.14
software.amazon.awssdk
kms
- 2.30.38
+ 2.31.14
@@ -82,7 +82,7 @@
software.amazon.awssdk.crt
aws-crt
true
- 0.36.3
+ 0.37.0
@@ -163,7 +163,7 @@
software.amazon.awssdk
sts
- 2.30.38
+ 2.31.14
true
test
diff --git a/src/examples/java/software/amazon/encryption/s3/examples/MultipartUploadExample.java b/src/examples/java/software/amazon/encryption/s3/examples/MultipartUploadExample.java
index d08a698b2..e2e61859d 100644
--- a/src/examples/java/software/amazon/encryption/s3/examples/MultipartUploadExample.java
+++ b/src/examples/java/software/amazon/encryption/s3/examples/MultipartUploadExample.java
@@ -1,10 +1,6 @@
package software.amazon.encryption.s3.examples;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static software.amazon.encryption.s3.S3EncryptionClient.withAdditionalConfiguration;
-import static software.amazon.encryption.s3.utils.S3EncryptionClientTestResources.KMS_KEY_ID;
-import static software.amazon.encryption.s3.utils.S3EncryptionClientTestResources.appendTestSuffix;
-
+import org.apache.commons.io.IOUtils;
import software.amazon.awssdk.core.ResponseInputStream;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.services.s3.S3Client;
@@ -26,7 +22,10 @@
import java.util.List;
import java.util.Map;
-import org.apache.commons.io.IOUtils;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static software.amazon.encryption.s3.S3EncryptionClient.withAdditionalConfiguration;
+import static software.amazon.encryption.s3.utils.S3EncryptionClientTestResources.KMS_KEY_ID;
+import static software.amazon.encryption.s3.utils.S3EncryptionClientTestResources.appendTestSuffix;
public class MultipartUploadExample {
public static String BUCKET;
diff --git a/src/main/java/software/amazon/encryption/s3/internal/CipherAsyncRequestBody.java b/src/main/java/software/amazon/encryption/s3/internal/CipherAsyncRequestBody.java
index dc3afa9a4..17a3bf8ee 100644
--- a/src/main/java/software/amazon/encryption/s3/internal/CipherAsyncRequestBody.java
+++ b/src/main/java/software/amazon/encryption/s3/internal/CipherAsyncRequestBody.java
@@ -20,12 +20,14 @@ public class CipherAsyncRequestBody implements AsyncRequestBody {
private final Long ciphertextLength;
private final CryptographicMaterials materials;
private final byte[] iv;
+ private final boolean isLastPart;
public CipherAsyncRequestBody(final AsyncRequestBody wrappedAsyncRequestBody, final Long ciphertextLength, final CryptographicMaterials materials, final byte[] iv, final boolean isLastPart) {
this.wrappedAsyncRequestBody = wrappedAsyncRequestBody;
this.ciphertextLength = ciphertextLength;
this.materials = materials;
this.iv = iv;
+ this.isLastPart = isLastPart;
}
public CipherAsyncRequestBody(final AsyncRequestBody wrappedAsyncRequestBody, final Long ciphertextLength, final CryptographicMaterials materials, final byte[] iv) {
@@ -38,7 +40,7 @@ public CipherAsyncRequestBody(final AsyncRequestBody wrappedAsyncRequestBody, fi
public void subscribe(Subscriber super ByteBuffer> subscriber) {
wrappedAsyncRequestBody.subscribe(new CipherSubscriber(subscriber,
contentLength().orElseThrow(() -> new S3EncryptionClientException("Unbounded streams are currently not supported.")),
- materials, iv));
+ materials, iv, isLastPart));
}
@Override
diff --git a/src/main/java/software/amazon/encryption/s3/internal/CipherSubscriber.java b/src/main/java/software/amazon/encryption/s3/internal/CipherSubscriber.java
index dcb9ca361..628798572 100644
--- a/src/main/java/software/amazon/encryption/s3/internal/CipherSubscriber.java
+++ b/src/main/java/software/amazon/encryption/s3/internal/CipherSubscriber.java
@@ -18,8 +18,6 @@ public class CipherSubscriber implements Subscriber {
private final Subscriber super ByteBuffer> wrappedSubscriber;
private Cipher cipher;
private final Long contentLength;
- private final CryptographicMaterials materials;
- private byte[] iv;
private boolean isLastPart;
private byte[] outputBuffer;
@@ -27,8 +25,6 @@ public class CipherSubscriber implements Subscriber {
CipherSubscriber(Subscriber super ByteBuffer> wrappedSubscriber, Long contentLength, CryptographicMaterials materials, byte[] iv, boolean isLastPart) {
this.wrappedSubscriber = wrappedSubscriber;
this.contentLength = contentLength;
- this.materials = materials;
- this.iv = iv;
cipher = materials.getCipher(iv);
this.isLastPart = isLastPart;
}
diff --git a/src/main/java/software/amazon/encryption/s3/internal/GetEncryptedObjectPipeline.java b/src/main/java/software/amazon/encryption/s3/internal/GetEncryptedObjectPipeline.java
index 2ca73db60..b0805a6ac 100644
--- a/src/main/java/software/amazon/encryption/s3/internal/GetEncryptedObjectPipeline.java
+++ b/src/main/java/software/amazon/encryption/s3/internal/GetEncryptedObjectPipeline.java
@@ -17,12 +17,7 @@
import software.amazon.encryption.s3.materials.DecryptionMaterials;
import software.amazon.encryption.s3.materials.EncryptedDataKey;
-import javax.crypto.Cipher;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.GCMParameterSpec;
-import javax.crypto.spec.IvParameterSpec;
import java.nio.ByteBuffer;
-import java.security.GeneralSecurityException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@@ -143,42 +138,23 @@ public void onStream(SdkPublisher ciphertextPublisher) {
long[] desiredRange = RangedGetUtils.getRange(materials.getContentRange());
long[] cryptoRange = RangedGetUtils.getCryptoRange(materials.getContentRange());
AlgorithmSuite algorithmSuite = materials.algorithmSuite();
- SecretKey contentKey = materials.dataKey();
- final int tagLength = algorithmSuite.cipherTagLengthBits();
byte[] iv = contentMetadata.contentIv();
if (algorithmSuite == AlgorithmSuite.ALG_AES_256_CTR_IV16_TAG16_NO_KDF) {
iv = AesCtrUtils.adjustIV(iv, cryptoRange[0]);
}
- try {
- final Cipher cipher = CryptoFactory.createCipher(algorithmSuite.cipherName(), materials.cryptoProvider());
- switch (algorithmSuite) {
- case ALG_AES_256_GCM_IV12_TAG16_NO_KDF:
- cipher.init(Cipher.DECRYPT_MODE, contentKey, new GCMParameterSpec(tagLength, iv));
- break;
- case ALG_AES_256_CTR_IV16_TAG16_NO_KDF:
- case ALG_AES_256_CBC_IV16_NO_KDF:
- cipher.init(Cipher.DECRYPT_MODE, contentKey, new IvParameterSpec(iv));
- break;
- default:
- throw new S3EncryptionClientException("Unknown algorithm: " + algorithmSuite.cipherName());
- }
-
- if (algorithmSuite.equals(AlgorithmSuite.ALG_AES_256_CBC_IV16_NO_KDF)
- || algorithmSuite.equals(AlgorithmSuite.ALG_AES_256_CTR_IV16_TAG16_NO_KDF)
- || _enableDelayedAuthentication) {
- // CBC and GCM with delayed auth enabled use a standard publisher
- CipherPublisher plaintextPublisher = new CipherPublisher(ciphertextPublisher,
- getObjectResponse.contentLength(), desiredRange, contentMetadata.contentRange(), algorithmSuite.cipherTagLengthBits(), materials, iv);
- wrappedAsyncResponseTransformer.onStream(plaintextPublisher);
- } else {
- // Use buffered publisher for GCM when delayed auth is not enabled
- BufferedCipherPublisher plaintextPublisher = new BufferedCipherPublisher(ciphertextPublisher,
- getObjectResponse.contentLength(), materials, iv, _bufferSize);
- wrappedAsyncResponseTransformer.onStream(plaintextPublisher);
- }
-
- } catch (GeneralSecurityException e) {
- throw new S3EncryptionClientException("Unable to " + algorithmSuite.cipherName() + " content decrypt.", e);
+
+ if (algorithmSuite.equals(AlgorithmSuite.ALG_AES_256_CBC_IV16_NO_KDF)
+ || algorithmSuite.equals(AlgorithmSuite.ALG_AES_256_CTR_IV16_TAG16_NO_KDF)
+ || _enableDelayedAuthentication) {
+ // CBC and GCM with delayed auth enabled use a standard publisher
+ CipherPublisher plaintextPublisher = new CipherPublisher(ciphertextPublisher,
+ getObjectResponse.contentLength(), desiredRange, contentMetadata.contentRange(), algorithmSuite.cipherTagLengthBits(), materials, iv);
+ wrappedAsyncResponseTransformer.onStream(plaintextPublisher);
+ } else {
+ // Use buffered publisher for GCM when delayed auth is not enabled
+ BufferedCipherPublisher plaintextPublisher = new BufferedCipherPublisher(ciphertextPublisher,
+ getObjectResponse.contentLength(), materials, iv, _bufferSize);
+ wrappedAsyncResponseTransformer.onStream(plaintextPublisher);
}
}
}
diff --git a/src/test/java/software/amazon/encryption/s3/examples/AsyncClientExampleTest.java b/src/test/java/software/amazon/encryption/s3/examples/AsyncClientExampleTest.java
index fa0c6506c..1005086d7 100644
--- a/src/test/java/software/amazon/encryption/s3/examples/AsyncClientExampleTest.java
+++ b/src/test/java/software/amazon/encryption/s3/examples/AsyncClientExampleTest.java
@@ -3,11 +3,18 @@
import org.junit.jupiter.api.Test;
import software.amazon.encryption.s3.utils.S3EncryptionClientTestResources;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class AsyncClientExampleTest {
@Test
public void testAsyncClientExamples() {
final String bucket = S3EncryptionClientTestResources.BUCKET;
- AsyncClientExample.main(new String[]{bucket});
+ try {
+ AsyncClientExample.main(new String[]{bucket});
+ } catch (Throwable exception) {
+ exception.printStackTrace();
+ fail("Async Example Test Failed!!", exception);
+ }
}
}
diff --git a/src/test/java/software/amazon/encryption/s3/examples/ClientConfigurationExampleTest.java b/src/test/java/software/amazon/encryption/s3/examples/ClientConfigurationExampleTest.java
index 91077c643..7dc06eb33 100644
--- a/src/test/java/software/amazon/encryption/s3/examples/ClientConfigurationExampleTest.java
+++ b/src/test/java/software/amazon/encryption/s3/examples/ClientConfigurationExampleTest.java
@@ -2,9 +2,16 @@
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class ClientConfigurationExampleTest {
@Test
public void testClientConfigurationExamples() {
- ClientConfigurationExample.main(new String[0]);
+ try {
+ ClientConfigurationExample.main(new String[0]);
+ } catch (Throwable exception) {
+ exception.printStackTrace();
+ fail("Client Configuration Example Test Failed!!", exception);
+ }
}
}
diff --git a/src/test/java/software/amazon/encryption/s3/examples/MultipartUploadExampleTest.java b/src/test/java/software/amazon/encryption/s3/examples/MultipartUploadExampleTest.java
index 89e03ea5c..f037f640d 100644
--- a/src/test/java/software/amazon/encryption/s3/examples/MultipartUploadExampleTest.java
+++ b/src/test/java/software/amazon/encryption/s3/examples/MultipartUploadExampleTest.java
@@ -3,13 +3,18 @@
import org.junit.jupiter.api.Test;
import software.amazon.encryption.s3.utils.S3EncryptionClientTestResources;
-import java.io.IOException;
+import static org.junit.jupiter.api.Assertions.fail;
public class MultipartUploadExampleTest {
@Test
- public void testMultipartUploadExamples() throws IOException {
+ public void testMultipartUploadExamples() {
final String bucket = S3EncryptionClientTestResources.BUCKET;
- MultipartUploadExample.main(new String[]{bucket});
+ try {
+ MultipartUploadExample.main(new String[]{bucket});
+ } catch (Throwable exception) {
+ exception.printStackTrace();
+ fail("Multipart Example Test Failed!!", exception);
+ }
}
}
diff --git a/src/test/java/software/amazon/encryption/s3/examples/PartialKeyPairExampleTest.java b/src/test/java/software/amazon/encryption/s3/examples/PartialKeyPairExampleTest.java
index f425619d0..df0babad1 100644
--- a/src/test/java/software/amazon/encryption/s3/examples/PartialKeyPairExampleTest.java
+++ b/src/test/java/software/amazon/encryption/s3/examples/PartialKeyPairExampleTest.java
@@ -5,12 +5,18 @@
import org.junit.jupiter.api.Test;
import software.amazon.encryption.s3.utils.S3EncryptionClientTestResources;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class PartialKeyPairExampleTest {
@Test
public void testPartialKeyPairExamples() {
final String bucket = S3EncryptionClientTestResources.BUCKET;
-
- PartialKeyPairExample.main(new String[]{bucket});
+ try {
+ PartialKeyPairExample.main(new String[]{bucket});
+ } catch (Throwable exception) {
+ exception.printStackTrace();
+ fail("Partial Key Pair Example Test Failed!!", exception);
+ }
}
}
diff --git a/src/test/java/software/amazon/encryption/s3/examples/RangedGetExampleTest.java b/src/test/java/software/amazon/encryption/s3/examples/RangedGetExampleTest.java
index 24e0a0357..ec4b24541 100644
--- a/src/test/java/software/amazon/encryption/s3/examples/RangedGetExampleTest.java
+++ b/src/test/java/software/amazon/encryption/s3/examples/RangedGetExampleTest.java
@@ -3,11 +3,18 @@
import org.junit.jupiter.api.Test;
import software.amazon.encryption.s3.utils.S3EncryptionClientTestResources;
+import static org.junit.jupiter.api.Assertions.fail;
+
public class RangedGetExampleTest {
@Test
public void testRangedGetExamples() {
final String bucket = S3EncryptionClientTestResources.BUCKET;
- RangedGetExample.main(new String[]{bucket});
+ try {
+ RangedGetExample.main(new String[]{bucket});
+ } catch (Throwable exception) {
+ exception.printStackTrace();
+ fail("Ranged Get Test Failed!!", exception);
+ }
}
}