ntrepid8 / ex_crypto

Wrapper around the Erlang crypto module for Elixir.
MIT License
150 stars 48 forks source link

Decrypting can return {:ok, :error} #28

Closed intentionally-left-nil closed 5 years ago

intentionally-left-nil commented 5 years ago

For example, if you provide a different Auth data for decryption:

  iex> clear_text = "my-clear-text"
  iex> auth_data = "my-auth-data"
  iex> bad_auth_data = "bad-auth-data"
  iex> {:ok, aes_256_key} = ExCrypto.generate_aes_key(:aes_256, :bytes)
  iex> {:ok, {_ad, payload}} = ExCrypto.encrypt(aes_256_key, auth_data, clear_text)
  iex> {init_vec, cipher_text, cipher_tag} = payload
  iex> {:ok, :error} = ExCrypto.decrypt(aes_256_key, bad_auth_data, init_vec, cipher_text, cipher_tag)
ntrepid8 commented 5 years ago

I see what you mean, thanks for submitting the PR to fix it!