Botan

PBKDF

License
Botan is released under the Simplified BSD License (see LICENSE.md)

interface  PBKDF;

Base class for  PBKDF (password based key derivation function) implementations. Converts a password into a key using a salt and iterated hashing to make brute force attacks harder.


abstract const PBKDF  clone();

Returns
new instance of this same algorithm

final const OctetString  deriveKey(size_t output_len, in string passphrase, const(ubyte)* salt, size_t salt_len, size_t iterations);

Derive a key from a passphrase

Parameters
size_t output_len the desired length of the key to produce
string passphrase the password to derive the key from
const(ubyte)* salt a randomly chosen salt
size_t salt_len length of salt in bytes
size_t iterations the number of iterations to use (use 10K or more)

final const OctetString  deriveKey(Alloc)(size_t output_len, in string passphrase, ref const Vector!(ubyte, Alloc) salt, size_t iterations);

Derive a key from a passphrase

Parameters
size_t output_len the desired length of the key to produce
string passphrase the password to derive the key from
Vector!(ubyte, Alloc) salt a randomly chosen salt
size_t iterations the number of iterations to use (use 10K or more)

final const OctetString  deriveKey(size_t output_len, in string passphrase, const(ubyte)* salt, size_t salt_len, Duration loop_for, ref size_t iterations);

Derive a key from a passphrase

Parameters
size_t output_len the desired length of the key to produce
string passphrase the password to derive the key from
const(ubyte)* salt a randomly chosen salt
size_t salt_len length of salt in bytes
Duration loop_for is how long to run the PBKDF
size_t iterations is set to the number of iterations used

final const OctetString  deriveKey(Alloc)(size_t output_len, in string passphrase, ref const Vector!(ubyte, Alloc) salt, Duration loop_for, ref size_t iterations);

Derive a key from a passphrase using a certain amount of time

Parameters
size_t output_len the desired length of the key to produce
string passphrase the password to derive the key from
Vector!(ubyte, Alloc) salt a randomly chosen salt
Duration loop_for is how long to run the PBKDF
size_t iterations is set to the number of iterations used

abstract const Pair!(size_t, OctetString)  keyDerivation(size_t output_len, in string passphrase, const(ubyte)* salt, size_t salt_len, size_t iterations, Duration loop_for);

Derive a key from a passphrase for a number of iterations specified by either iterations or if iterations == 0 then running until seconds time has elapsed.

Parameters
size_t output_len the desired length of the key to produce
string passphrase the password to derive the key from
const(ubyte)* salt a randomly chosen salt
size_t salt_len length of salt in bytes
size_t iterations the number of iterations to use (use 10K or more)
Duration loop_for if iterations is zero, then instead the PBKDF is run until duration has passed.
Returns
the number of iterations performed and the derived key