Skip to content

Commit 5b7b3ae

Browse files
author
Anirav Kareddy
committed
verified in test case testRsaKeyringReEncryptInstructionFile that the third-party client is unable toretrieve the encrypted object in s3 if they do not include the overrideConfiguration with their custom instruction file suffix since it will by default use the original instruction file, not theirs.:
1 parent f6e43e5 commit 5b7b3ae

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/main/java/software/amazon/encryption/s3/S3EncryptionClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
import java.util.Collections;
8383
import java.util.List;
8484
import java.util.Map;
85-
import java.util.Objects;
8685
import java.util.Optional;
8786
import java.util.concurrent.CompletableFuture;
8887
import java.util.concurrent.CompletionException;
@@ -108,6 +107,7 @@ public class S3EncryptionClient extends DelegatingS3Client {
108107
// Used for request-scoped encryption contexts for supporting keys
109108
public static final ExecutionAttribute<Map<String, String>> ENCRYPTION_CONTEXT = new ExecutionAttribute<>("EncryptionContext");
110109
public static final ExecutionAttribute<MultipartConfiguration> CONFIGURATION = new ExecutionAttribute<>("MultipartConfiguration");
110+
111111
public static final ExecutionAttribute<String> CUSTOM_INSTRUCTION_FILE_SUFFIX = new ExecutionAttribute<>("CustomInstructionFileSuffix");
112112

113113
private final S3Client _wrappedClient;

src/test/java/software/amazon/encryption/s3/S3EncryptionClientReEncryptInstructionFileTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.junit.jupiter.api.BeforeAll;
44
import org.junit.jupiter.api.Test;
5-
import software.amazon.awssdk.core.Response;
65
import software.amazon.awssdk.core.ResponseBytes;
76
import software.amazon.awssdk.core.sync.RequestBody;
87
import software.amazon.awssdk.protocols.jsoncore.JsonNode;
@@ -268,6 +267,16 @@ public void testRsaKeyringReEncryptInstructionFile() {
268267
assertEquals(clientEncryptedDataKeyAlgorithm, thirdPartyEncryptedDataKeyAlgorithm);
269268
assertNotEquals(clientEncryptedDataKey, thirdPartyEncryptedDataKey);
270269

270+
try {
271+
ResponseBytes<GetObjectResponse> thirdPartyDecryptObject = thirdPartyClient.getObjectAsBytes(builder -> builder
272+
.bucket(BUCKET)
273+
.key(objectKey)
274+
.build());
275+
throw new RuntimeException("Expected exception");
276+
} catch (S3EncryptionClientException e) {
277+
assertTrue(e.getMessage().contains("Unable to RSA-OAEP-SHA1 unwrap"));
278+
}
279+
271280
ResponseBytes<GetObjectResponse> thirdPartyDecryptedObject = thirdPartyClient.getObjectAsBytes(builder -> builder
272281
.bucket(BUCKET)
273282
.key(objectKey)
@@ -285,5 +294,8 @@ public void testRsaKeyringReEncryptInstructionFile() {
285294
assertEquals(objectKey, reEncryptInstructionFileResponse.Key());
286295
assertEquals(".third-party-access-instruction-file", reEncryptInstructionFileResponse.InstructionFileSuffix());
287296

297+
deleteObject(BUCKET, objectKey, client);
298+
288299
}
300+
289301
}

0 commit comments

Comments
 (0)