Skip to content

Commit 81215b1

Browse files
author
Anirav Kareddy
committed
Added MaterialsDescription to Encryption Materials (note: encryption context and materials description will be treated as different
1 parent 674053d commit 81215b1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ final public class EncryptionMaterials implements CryptographicMaterials {
2727
// Additional information passed into encrypted that is required on decryption as well
2828
// Should NOT contain sensitive information
2929
private final Map<String, String> _encryptionContext;
30+
private final MaterialsDescription _materialsDescription;
3031

3132
private final List<EncryptedDataKey> _encryptedDataKeys;
3233
private final byte[] _plaintextDataKey;
@@ -43,6 +44,7 @@ private EncryptionMaterials(Builder builder) {
4344
this._cryptoProvider = builder._cryptoProvider;
4445
this._plaintextLength = builder._plaintextLength;
4546
this._ciphertextLength = _plaintextLength + _algorithmSuite.cipherTagLengthBytes();
47+
this._materialsDescription = builder._materialsDescription;
4648
}
4749

4850
static public Builder builder() {
@@ -101,6 +103,9 @@ public Provider cryptoProvider() {
101103
return _cryptoProvider;
102104
}
103105

106+
public MaterialsDescription materialsDescription() {
107+
return _materialsDescription;
108+
}
104109
@Override
105110
public CipherMode cipherMode() {
106111
return CipherMode.ENCRYPT;
@@ -119,6 +124,7 @@ public Builder toBuilder() {
119124
.encryptedDataKeys(_encryptedDataKeys)
120125
.plaintextDataKey(_plaintextDataKey)
121126
.cryptoProvider(_cryptoProvider)
127+
.materialsDescription(_materialsDescription)
122128
.plaintextLength(_plaintextLength);
123129
}
124130

@@ -132,6 +138,7 @@ static public class Builder {
132138
private byte[] _plaintextDataKey = null;
133139
private long _plaintextLength = -1;
134140
private Provider _cryptoProvider = null;
141+
private MaterialsDescription _materialsDescription;
135142

136143
private Builder() {
137144
}
@@ -145,7 +152,10 @@ public Builder algorithmSuite(AlgorithmSuite algorithmSuite) {
145152
_algorithmSuite = algorithmSuite;
146153
return this;
147154
}
148-
155+
public Builder materialsDescription(MaterialsDescription materialsDescription) {
156+
_materialsDescription = materialsDescription;
157+
return this;
158+
}
149159
public Builder encryptionContext(Map<String, String> encryptionContext) {
150160
_encryptionContext = encryptionContext == null
151161
? Collections.emptyMap()

0 commit comments

Comments
 (0)