Skip to content

Commit 4734c56

Browse files
committed
fix: validate encryption materials from cmm are compatible with commitment policy
1 parent 4522fae commit 4734c56

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/aws_encryption_sdk/streaming_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,8 @@ def _prep_message(self):
553553
request=encryption_materials_request
554554
)
555555

556+
validate_commitment_policy_on_encrypt(self.config.commitment_policy, self._encryption_materials.algorithm)
557+
556558
if self.config.algorithm is not None and self._encryption_materials.algorithm != self.config.algorithm:
557559
raise ActionNotAllowedError(
558560
(

test/functional/test_f_commitment.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def test_encrypt_with_different_kc_clients_sharing_materials_yield_error():
234234
commitment_policy=CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT
235235
)
236236
required_encrypting_client = aws_encryption_sdk.EncryptionSDKClient(
237-
commitment_policy=CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT
237+
commitment_policy=CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT
238238
)
239239

240240
provider = StaticRawMasterKeyProvider(
@@ -250,7 +250,6 @@ def test_encrypt_with_different_kc_clients_sharing_materials_yield_error():
250250
plaintext = b"Yellow Submarine"
251251

252252
ciphertext, _ = forbid_encrypting_client.encrypt(source=plaintext, materials_manager=ccmm)
253-
ciphertext2, _ = required_encrypting_client.encrypt(source=plaintext, materials_manager=ccmm)
254253
with pytest.raises(ActionNotAllowedError) as excinfo:
255254
required_encrypting_client.encrypt(source=plaintext, materials_manager=ccmm)
256255
excinfo.match("Configuration conflict. Cannot encrypt due to .* requiring only committed messages")

0 commit comments

Comments
 (0)