Exmbus.Crypto (Exmbus v0.3.0)

View Source

Wraps the crypto functions used in the Exmbus library.

Summary

Functions

Wraps the crypto_one_time function from the crypto module, just like crypto_one_time/5, but without the IV.

Wraps the crypto_one_time function from the crypto module, catching errors and returning them as {:error, {:crypto_error, e}} tuples. We do this to prevent a bad key from crashing the parse.

Types

cipher_iv()

@type cipher_iv() :: atom()

cipher_no_iv()

@type cipher_no_iv() :: atom()

crypto_error()

crypto_error_c_fileinfo()

@type crypto_error_c_fileinfo() :: term()

crypto_error_description()

@type crypto_error_description() :: String.t()

crypto_error_tag()

@type crypto_error_tag() :: :badarg | :notsup | :error

crypto_opts()

@type crypto_opts() :: [any()]

Functions

crypto_one_time(cipher, key, data, flag_or_options)

@spec crypto_one_time(
  cipher :: cipher_no_iv(),
  key :: iodata(),
  data :: iodata(),
  flag_or_options :: crypto_opts() | boolean()
) :: {:ok, binary()} | {:error, crypto_error()}

Wraps the crypto_one_time function from the crypto module, just like crypto_one_time/5, but without the IV.

crypto_one_time(cipher, key, iv, data, flag_or_options)

@spec crypto_one_time(
  cipher :: cipher_iv(),
  key :: iodata(),
  iv :: iodata(),
  data :: iodata(),
  flag_or_options :: crypto_opts() | boolean()
) :: {:ok, binary()} | {:error, crypto_error()}

Wraps the crypto_one_time function from the crypto module, catching errors and returning them as {:error, {:crypto_error, e}} tuples. We do this to prevent a bad key from crashing the parse.