scrypt-0.2.1: Stronger password hashing via sequential memory-hard functions.

Crypto.Scrypt

Contents

Description

Scrypt is a sequential memory-hard key derivation function. This module provides bindings to a fast C implementation of scrypt, written by Colin Percival. For more information see http://www.tarsnap.com/scrypt.html.

Synopsis

Parameters to the scrypt function

data ScryptParams Source

Encapsulates the three tuning parameters to the scrypt function: N, r and p. The parameters affect running time and memory usage:

Memory usage is approximately 128*r*N bytes. Note that the params function takes log_2(N) as a parameter. As an example, the default parameters used by scrypt'

   log_2(N) = 14, r = 8 and p = 1

lead to scrypt using 128 * 8 * 2^14 = 16M bytes of memory.

Running time is proportional to all of N, r and p. However p only as an insignificant influence on memory usage an can thus be used to tune the running time of scrypt.

Instances

paramsSource

Arguments

:: Integer

log_2(N). Scrypt's N parameter must be a power of two greater than one, thus it's logarithm to base two must be greater than zero.

-> Integer

The parameter r, must be greater than zero.

-> Integer

The parameter p, must be greater than zero. r and p must satisfy r*p < 2^30.

-> Maybe ScryptParams

Returns Just the parameter object for valid arguments, otherwise Nothing.

Constructor function for the ScryptParams data type

The scrypt key derivation function

newtype Pass Source

Constructors

Pass 

Fields

unPass :: ByteString
 

Instances

newtype Salt Source

Constructors

Salt 

Fields

unSalt :: ByteString
 

Instances

newtype PassHash Source

Constructors

PassHash 

Fields

unHash :: ByteString
 

Instances

scrypt :: ScryptParams -> Salt -> Pass -> PassHashSource

Calculates a 64-byte hash from the given password, salt and parameters.

scrypt' :: Salt -> Pass -> PassHashSource

Note the prime symbol ('). Calls scrypt with default parameters as recommended in the scrypt paper:

   N = 2^14, r = 8, p = 1

Equivalent to scrypt (fromJust (params 14 8 1)).

getSalt :: IO SaltSource

Reads a 32-byte random salt from /dev/urandom.