Skip to content

Commit 8b8f163

Browse files
committed
verify that no raw master key wrapping keys are logged
1 parent 6c3694d commit 8b8f163

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/functional/test_f_aws_encryption_sdk_client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,9 @@ def test_encrypt_ciphertext_message(frame_length, algorithm, encryption_context)
324324
(WrappingAlgorithm.RSA_OAEP_SHA1_MGF1, EncryptionKeyType.PUBLIC, EncryptionKeyType.PRIVATE),
325325
),
326326
)
327-
def test_encryption_cycle_raw_mkp(wrapping_algorithm, encryption_key_type, decryption_key_type):
327+
def test_encryption_cycle_raw_mkp(caplog, wrapping_algorithm, encryption_key_type, decryption_key_type):
328+
caplog.set_level(logging.DEBUG)
329+
328330
encrypting_key_provider = build_fake_raw_key_provider(wrapping_algorithm, encryption_key_type)
329331
decrypting_key_provider = build_fake_raw_key_provider(wrapping_algorithm, decryption_key_type)
330332
ciphertext, _ = aws_encryption_sdk.encrypt(
@@ -334,7 +336,10 @@ def test_encryption_cycle_raw_mkp(wrapping_algorithm, encryption_key_type, decry
334336
frame_length=0,
335337
)
336338
plaintext, _ = aws_encryption_sdk.decrypt(source=ciphertext, key_provider=decrypting_key_provider)
339+
337340
assert plaintext == VALUES["plaintext_128"]
341+
for member in encrypting_key_provider._members:
342+
assert repr(member.config.wrapping_key._wrapping_key)[2:-1] not in caplog.text
338343

339344

340345
@pytest.mark.skipif(
@@ -687,6 +692,9 @@ def _prep_plaintext_and_logs(log_catcher, plaintext_length):
687692
def _look_in_logs(log_catcher, plaintext):
688693
# Verify that no plaintext chunks are in the logs
689694
logs = log_catcher.text
695+
# look for all fake KMS data keys
696+
for keysize, args in VALUES["data_keys"].items():
697+
assert repr(args["plaintext"])[2:-1] not in logs
690698
# look for every possible 32-byte chunk
691699
start = 0
692700
end = 32

0 commit comments

Comments
 (0)