When I pass arbitrary data to decrypt like: ExCrypto.decrypt(aes_256_key, iv, "asdasdasdads")
I receive the following error:
** (MatchError) no match of right hand side value: %MatchError{term: {:error, "argument error"}}
(ex_crypto) lib/ex_crypto.ex:28: ExCrypto.normalize_error/3
Now, I'm not completely sure if this is intended or if this is a bug (Elixir beginner) but it seems to me that Exception.normalize/3 doesn't map this particular error as expected.
My usecase is such that it might be possible that arbitrary data comes into the decrypt, which might not be best solution however I'd expect it to inform the caller with an error tuple and not throw.
In this PR I added a test to reproduce this. Also in ex_crypto.ex I added a cond clause to 'catch' and normalize this error.
I'm running on
When I pass arbitrary data to
decrypt
like:ExCrypto.decrypt(aes_256_key, iv, "asdasdasdads")
I receive the following error:
Now, I'm not completely sure if this is intended or if this is a bug (Elixir beginner) but it seems to me that Exception.normalize/3 doesn't map this particular error as expected. My usecase is such that it might be possible that arbitrary data comes into the decrypt, which might not be best solution however I'd expect it to inform the caller with an error tuple and not throw.
In this PR I added a test to reproduce this. Also in ex_crypto.ex I added a cond clause to 'catch' and normalize this error.