Skip to content

Commit 6371f96

Browse files
authored
Merge pull request #50 from SalusaSecondus/tmpworking
Update documents to indicate that SaveBehavior.PUT is also safe
2 parents 913338f + 11c2673 commit 6371f96

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ The **[Amazon DynamoDB][ddb] Client-side Encryption in Java** supports encryptio
44

55
A typical use of this library is when you are using [DynamoDBMapper][ddbmapper], where transparent protection of all objects serialized through the mapper can be enabled via configuring an [AttributeEncryptor][attrencryptor].
66

7-
**Important: Use `SaveBehavior.CLOBBER` with `AttributeEncryptor`. If you do not do so you risk corrupting your signatures and encrypted data.**
8-
When CLOBBER is not specified, fields that are present in the record may not be passed down to the encryptor, which results in fields being left out of the record signature. This in turn can result in records failing to decrypt.
7+
**Important: Use `SaveBehavior.PUT` or `SaveBehavior.CLOBBER` with `AttributeEncryptor`. If you do not do so you risk corrupting your signatures and encrypted data.**
8+
When PUT or CLOBBER is not specified, fields that are present in the record may not be passed down to the encryptor, which results in fields being left out of the record signature. This in turn can result in records failing to decrypt.
99

1010
For more advanced use cases where tighter control over the encryption and signing process is necessary, the low-level [DynamoDBEncryptor][ddbencryptor] can be used directly.
1111

@@ -77,7 +77,7 @@ To enable transparent encryption and signing, simply specify the necessary encry
7777
SecretKey cek = ...; // Content encrypting key
7878
SecretKey macKey = ...; // Signing key
7979
EncryptionMaterialsProvider provider = new SymmetricStaticProvider(cek, macKey);
80-
mapper = new DynamoDBMapper(client, DynamoDBMapperConfig.builder().withSaveBehavior(SaveBehavior.CLOBBER).build(),
80+
mapper = new DynamoDBMapper(client, DynamoDBMapperConfig.builder().withSaveBehavior(SaveBehavior.PUT).build(),
8181
new AttributeEncryptor(provider));
8282
Book book = new Book();
8383
book.setId(123);

src/main/java/com/amazonaws/services/dynamodbv2/datamodeling/AttributeEncryptor.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
/**
4040
* Encrypts all non-key fields prior to storing them in DynamoDB.
41-
* <em>This must be used with @{link SaveBehavior#CLOBBER}. Use of
41+
* <em>This must be used with @{link SaveBehavior#PUT} or @{link SaveBehavior#CLOBBER}. Use of
4242
* any other @{code SaveBehavior} can result in data-corruption.</em>
4343
*
4444
* @author Greg Rubin
@@ -72,13 +72,14 @@ public Map<String, AttributeValue> transform(final Parameters<?> parameters) {
7272
return attributeValues;
7373
}
7474

75-
// When AttributeEncryptor is used without SaveBehavior.CLOBBER, it is trying to transform only a subset
75+
// When AttributeEncryptor is used without SaveBehavior.PUT or CLOBBER, it is trying to transform only a subset
7676
// of the actual fields stored in DynamoDB. This means that the generated signature will not cover any
7777
// unmodified fields. Thus, upon untransform, the signature verification will fail as it won't cover all
7878
// expected fields.
7979
if (parameters.isPartialUpdate()) {
80-
LOG.error("Use of AttributeEncryptor without SaveBehavior.CLOBBER is an error and can result in data-corruption. " +
81-
"This occured while trying to save " + parameters.getModelClass());
80+
LOG.error("Use of AttributeEncryptor without SaveBehavior.PUT or SaveBehavior.CLOBBER is an error " +
81+
"and can result in data-corruption. This occured while trying to save " +
82+
parameters.getModelClass());
8283
}
8384

8485
try {

0 commit comments

Comments
 (0)