botan-low-0.0.1.0: Low-level Botan bindings
Copyright(c) Leo D 2023
LicenseBSD-3-Clause
Maintainerleo@apotheca.io
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageHaskell2010

Botan.Low.KDF

Description

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.

Typically a KDF is also used with a salt and a label. The salt should be some random information which is available to all of the parties that would need to use the KDF; this could be performed by setting the salt to some kind of session identifier, or by having one of the parties generate a random salt and including it in a message.

The label is used to bind the KDF output to some specific context. For instance if you were using the KDF to derive a specific key referred to as the “message key” in the protocol description, you might use a label of “FooProtocol v2 MessageKey”. This labeling ensures that if you accidentally use the same input key and salt in some other context, you still use different keys in the two contexts.

Synopsis

Key derivation function

kdf Source #

Arguments

:: KDFName

kdf_algo: KDF algorithm, e.g., "SP800-56C"

-> Int

out_len: the desired output length in bytes

-> ByteString

secret[]: the secret input

-> ByteString

salt[]: a diversifier

-> ByteString

label[]: purpose for the derived keying material

-> IO ByteString

out[]: buffer holding the derived key

KDF algorithms

pattern HKDF :: KDFName Source #

pattern KDF2 :: KDFName Source #

pattern KDF1 :: KDFName Source #

Convenience