| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cometa.Crypto.Pbkdf2
Description
Password-based key derivation using PBKDF2-HMAC-SHA512. Inputs are raw bytes; no text encoding or normalization is applied. This module deliberately exports secret bytes: callers control their lifetime and must avoid logging them.
import qualified Cometa.Crypto.Pbkdf2 as Pbkdf2 -- Deterministic example data only; choose cost and salt for your application. derive password salt = Pbkdf2.deriveBytes password salt 100000 32
Synopsis
- deriveBytes :: ByteString -> ByteString -> Integer -> Integer -> Either Error ByteString
Documentation
deriveBytes :: ByteString -> ByteString -> Integer -> Integer -> Either Error ByteString Source #
Explicitly derive and export secret bytes from password, salt, iteration
count and output byte count, in that order. Password may be empty or contain
NUL; salt must be nonempty. Iterations must be 1..4294967295. Output must be
1..min(maxBound :: Int, 64 * (2^32 - 1)) bytes, the PBKDF2 block limit.
Invalid inputs return EmptyPbkdf2Salt, InvalidPbkdf2Iterations or
InvalidPbkdf2OutputLength before derivation. Other failures return
NativeError; allocation exceptions propagate. No default cost is chosen.
Large requests can require substantial memory and computation. Cancellation
waits for the ongoing derivation and cleanup. Input and returned Haskell
bytes are not erased by this operation.