extermit v0.1.0 ExTermit

Serialize an Elixir term to signed encrypted binary and deserialize it back ensuring it’s not been forged.

Some code extracted from https://github.com/mochi/mochiweb/blob/master/src/mochiweb_session.erl https://github.com/dvv/termit/blob/master/src/termit.erl

Summary

Functions

Given a result of encode/2, i.e. a signed encrypted binary, check the signature, uncrypt and deserialize into original term

Serialize Term, encrypt and sign the result with Secret. Return binary

‘Constant’ time =:= operator for binaries, to mitigate timing attacks

Functions

decode(bin, secret)
decode(binary, binary) ::
  {:ok, any} |
  {:error, :forged} |
  {:error, :badarg}

Given a result of encode/2, i.e. a signed encrypted binary, check the signature, uncrypt and deserialize into original term.

encode(term, secret)
encode(term :: any, secret :: binary) :: binary

Serialize Term, encrypt and sign the result with Secret. Return binary

equal(a, b)
equal(binary, binary) :: true | false

‘Constant’ time =:= operator for binaries, to mitigate timing attacks

equal(arg1, arg2, acc)
uncrypt(arg, key)
uncrypt(binary, binary) :: binary