Skip to content

Commit 5f29be9

Browse files
fix: Handle errors when decrypting multiple EDKs with raw RSA MKPs (#672)
1 parent e28d146 commit 5f29be9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/aws_encryption_sdk/internal/crypto/wrapping_keys.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,12 @@ def decrypt(self, encrypted_wrapped_data_key, encryption_context):
9898
if self.wrapping_key_type is EncryptionKeyType.PUBLIC:
9999
raise IncorrectMasterKeyError("Public key cannot decrypt")
100100
if self.wrapping_key_type is EncryptionKeyType.PRIVATE:
101-
return self._wrapping_key.decrypt(
102-
ciphertext=encrypted_wrapped_data_key.ciphertext, padding=self.wrapping_algorithm.padding
103-
)
101+
try:
102+
return self._wrapping_key.decrypt(
103+
ciphertext=encrypted_wrapped_data_key.ciphertext, padding=self.wrapping_algorithm.padding
104+
)
105+
except ValueError:
106+
raise IncorrectMasterKeyError("_wrapping_key cannot decrypt provided ciphertext")
104107
serialized_encryption_context = serialize_encryption_context(encryption_context=encryption_context)
105108
return decrypt(
106109
algorithm=self.wrapping_algorithm.algorithm,

0 commit comments

Comments
 (0)