Skip to content

Key Derivation Functions

etcimon edited this page Dec 4, 2014 · 4 revisions

Key derivation functions are used to turn some amount of shared secret material into uniform random keys suitable for use with symmetric algorithms. An example of an input which is useful for a KDF is a shared secret created using Diffie-Hellman key agreement.

The following methods are declared by the KDF interface and inherited by all KDF objects.

SecureVector!ubyte deriveKey(size_t key_len, 
                               in Vector!ubyte secret, 
                               in string salt = "") const

SecureVector!ubyte deriveKey(size_t key_len, 
                               in Vector!ubyte secret,
                               in Vector!ubyte salt) const

SecureVector!ubyte deriveKey(size_t key_len, 
                               in Vector!ubyte secret, 
                               in ubyte* salt, size_t salt_len) const

SecureVector!ubyte deriveKey(size_t key_len, in byte* secret, 
                               size_t secret_len, in string salt) const

All variations on the same theme. Deterministically creates a uniform random value from secret and salt. Typically salt is a label or identifier, such as a session id.

You can create a KDF class from botan.libstate.libstate using

KDF getKdf(in string algo_spec)
Clone this wiki locally