Plug.Crypto

Namespace and module for crypto functionality.

Summary

Functions

Masks the token on the left with the token on the right

Compares the two binaries (one being masked) in constant-time to avoid timing attacks

A restricted version a :erlang.binary_to_term/1 that forbids possibly unsafe terms

Compares the two binaries in constant-time to avoid timing attacks

Functions

mask(left, right)

Masks the token on the left with the token on the right.

Both tokens are required to have the same size.

masked_compare(left, right, mask)

Compares the two binaries (one being masked) in constant-time to avoid timing attacks.

It is assumed the right token is masked according to the given mask.

safe_binary_to_term(binary)

A restricted version a :erlang.binary_to_term/1 that forbids possibly unsafe terms.

secure_compare(left, right)

Compares the two binaries in constant-time to avoid timing attacks.

See: http://codahale.com/a-lesson-in-timing-attacks/