Open mattsb42-aws opened 7 years ago
Would you consider throwing a subtype of NotSupportedError
/AWSEncryptionSDKClientError
for this exception? Maybe something like UncompressedKeyError
? Instead of checking for the string "Uncompressed points are not supported" I could handle that specific exception, and just let the other exceptions bubble up, keeping things a little neater:
try:
return super(MrcryptLegacyCompatibilityCryptoMaterialsManager, self).decrypt_materials(request)
except UncompressedKeyError:
# Uncompressed key handling logic (all other exceptions will just bubble up)
# ...
That sounds reasonable, yes. Likely it'll be raising an error that "we couldn't load a compressed key", as that's really the only thing we can reliably state.
Problem
In testing to verify what happens if a caller attempts to decrypt a file created by mrcrypt, I realized that if you attempt to decrypt a message that was written with an uncompressed EC point (note: this is not supported under the AWS Encryption SDK spec), you get a very unhelpful error.
Solution
Catch appropriate errors in
internal.crypto.elliptic_curve._ecc_decode_compressed_point
and raiseNotSupportedError('Uncompressed points are not supported')