@@ -963,13 +963,18 @@ def _create_decrypt_materials_request(self, header):
963
963
# If encryption_context is provided on decrypt,
964
964
# pass it to the DecryptionMaterialsRequest as reproduced_encryption_context
965
965
if hasattr (self .config , "encryption_context" ):
966
- return DecryptionMaterialsRequest (
967
- encrypted_data_keys = header .encrypted_data_keys ,
968
- algorithm = header .algorithm ,
969
- encryption_context = header .encryption_context ,
970
- commitment_policy = self .config .commitment_policy ,
971
- reproduced_encryption_context = self .config .encryption_context
972
- )
966
+ if (_HAS_MPL
967
+ and isinstance (self .config .materials_manager , CryptoMaterialsManagerFromMPL )):
968
+ return DecryptionMaterialsRequest (
969
+ encrypted_data_keys = header .encrypted_data_keys ,
970
+ algorithm = header .algorithm ,
971
+ encryption_context = header .encryption_context ,
972
+ commitment_policy = self .config .commitment_policy ,
973
+ reproduced_encryption_context = self .config .encryption_context
974
+ )
975
+ else :
976
+ raise TypeError ("encryption_context on decrypt is only supported for CMMs and keyrings " \
977
+ "from the aws-cryptographic-material-providers library." )
973
978
return DecryptionMaterialsRequest (
974
979
encrypted_data_keys = header .encrypted_data_keys ,
975
980
algorithm = header .algorithm ,
0 commit comments