ppad-hkdf-0.1.0: A HMAC-based key derivation function
Copyright(c) 2024 Jared Tobin
LicenseMIT
MaintainerJared Tobin <jared@ppad.tech>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Crypto.KDF.HMAC

Description

A pure HKDF implementation, as specified by RFC5869.

Synopsis

HMAC-based KDF

hkdf Source #

Arguments

:: HMAC

HMAC function

-> ByteString

salt

-> ByteString

optional context and application-specific info

-> Word64

bytelength of output keying material (<= 255 * hashlen)

-> ByteString

input keying material

-> ByteString

output keying material

HMAC-based key derivation function.

The salt and info arguments are optional to the KDF, and may be simply passed as mempty. An empty salt will be replaced by hashlen zero bytes.

>>> import qualified Crypto.Hash.SHA256 as SHA256
>>> hkdf SHA256.hmac "my public salt" mempty 64 "my secret input"
<64-byte output keying material>

type HMAC = ByteString -> ByteString -> ByteString Source #

A HMAC function, taking a key as the first argument and the input value as the second, producing a MAC digest.

>>> import qualified Crypto.Hash.SHA256 as SHA256
>>> :t SHA256.hmac
SHA256.hmac :: BS.ByteString -> BS.ByteString -> BS.ByteString