Lazy-Pbkdf2-2.1.2: Lazy PBKDF2 generator.

Safe HaskellSafe
LanguageHaskell2010

Crypto.Pbkdf2

Synopsis

Documentation

pbkdf2 Source #

Arguments

:: (ByteString -> ByteString -> ByteString)

PRF, the PRF function to be used for PBKDF2. The first argument is secret, the second argument is not.

-> ByteString

Password, the secret to use in the PBKDF2 computations.

-> ByteString

Salt, the not neccesarily secret data to use in the PBKDF2 computations.

-> Integer

c, number of iterations for the the PBKDF2 computations.

-> ByteString

DK, the output data in the format of an unlimited lazy ByteString.

pbkdf2_iterative Source #

Arguments

:: (ByteString -> ByteString -> ByteString)

PRF, the PRF function to be used for the iterative PBKDF2. The first argument is secret, the second argument is not.

-> ByteString

Password, the secret to use in the PBKDF2 computations.

-> ByteString

Salt, the not neccesarily secret data to use in the PBKDF2 computations.

-> Integer

c, number of iterations for the the PBKDF2 computations.

-> ByteString

DK, the output data in the format of an unlimited lazy ByteString.

This is a non standard variation of PBKDF2 which recursively uses the last generated value to improve the salt. In difference to pbkdf2 the salt can not be precalculated for every iteration (with a simple append of 4 bytes), but has to be calculated for every single iteration. This also creates a function where you cannot jump in the stream without calculating everything before it. Compared to the standard this function only changes the salt for the initial PBKDF2 value of each iteration to include a salt iterated from earlier parts of the PBKDF2 stream. This can be verified by removing the i from (hash $ B.concat [blockSalt, salt, B.pack $ octetsBE c]).

The added salt for the first iteration will be "", and all following will be calculated as (PRF output input), where output is the output of the previous block and input is the added salt for the previous block. Notice that the output from the previous block is put in the password filed of the PRF.