pbkdf

Pure Haskell password-based KDF (docs.ppad.tech/pbkdf).
git clone git://git.ppad.tech/pbkdf.git
Log | Files | Refs | README | LICENSE

commit f57238108ff1feaa1b7ec95bee3953a5a0236cf7
parent e61072b6f3c7bf134c53dff5e3e659f4802f959c
Author: Jared Tobin <jared@jtobin.io>
Date:   Mon, 22 Dec 2025 19:13:03 -0330

meta: add llvm flag

Diffstat:
MREADME.md | 12++++++------
Mflake.lock | 22++++++++++++++--------
Mflake.nix | 21+++++++++++++++++----
Mppad-pbkdf.cabal | 7+++++++
4 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/README.md b/README.md @@ -39,16 +39,16 @@ Current benchmark figures on an M4 Silicon MacBook Air look like (use ``` benchmarking ppad-pbkdf/PBKDF-SHA256/derive (outlen 32) - time 216.9 μs (216.3 μs .. 217.3 μs) + time 58.19 μs (58.14 μs .. 58.25 μs) 1.000 R² (1.000 R² .. 1.000 R²) - mean 215.7 μs (215.3 μs .. 216.1 μs) - std dev 1.446 μs (1.275 μs .. 1.819 μs) + mean 58.39 μs (58.35 μs .. 58.44 μs) + std dev 155.6 ns (130.8 ns .. 193.7 ns) benchmarking ppad-pbkdf/PBKDF-SHA512/derive (outlen 32) - time 113.5 μs (113.3 μs .. 113.6 μs) + time 44.01 μs (43.92 μs .. 44.14 μs) 1.000 R² (1.000 R² .. 1.000 R²) - mean 113.4 μs (113.3 μs .. 113.5 μs) - std dev 303.1 ns (256.5 ns .. 398.4 ns) + mean 44.09 μs (44.02 μs .. 44.19 μs) + std dev 270.4 ns (209.1 ns .. 345.1 ns) ``` ## Security diff --git a/flake.lock b/flake.lock @@ -97,16 +97,19 @@ "ppad-nixpkgs", "nixpkgs" ], + "ppad-base16": [ + "ppad-base16" + ], "ppad-nixpkgs": [ "ppad-nixpkgs" ] }, "locked": { - "lastModified": 1740802974, - "narHash": "sha256-GTD9UrxwMa5zY7hxzDSXjKXKUwMK4r3FBHLG0nvgapk=", + "lastModified": 1766435555, + "narHash": "sha256-ysN0iRuBLSQrgWU3rCFUyq0NvRpug6DTBRZSlWbmI1A=", "ref": "master", - "rev": "ab0957e305dff0243dcab11e381470585849fd20", - "revCount": 94, + "rev": "a4c17689cd66e1ef35c667914765cb24c9a4b305", + "revCount": 96, "type": "git", "url": "git://git.ppad.tech/sha256.git" }, @@ -128,16 +131,19 @@ "ppad-nixpkgs", "nixpkgs" ], + "ppad-base16": [ + "ppad-base16" + ], "ppad-nixpkgs": [ "ppad-nixpkgs" ] }, "locked": { - "lastModified": 1740802979, - "narHash": "sha256-6VAXmA1XiIT/WFcP+eFb6uK3YyfgVqIgDv3ASNIoCMs=", + "lastModified": 1766437426, + "narHash": "sha256-vn0nUVrMqux2PorMOZlx3RAqylf88BTw+jRMXC0gIz8=", "ref": "master", - "rev": "ff165b29fb21b99749460ae7e3fdca42a85c822b", - "revCount": 28, + "rev": "669c4ffd1cc7826876af2d67661738c2081ea6a9", + "revCount": 31, "type": "git", "url": "git://git.ppad.tech/sha512.git" }, diff --git a/flake.nix b/flake.nix @@ -18,12 +18,14 @@ url = "git://git.ppad.tech/sha256.git"; ref = "master"; inputs.ppad-nixpkgs.follows = "ppad-nixpkgs"; + inputs.ppad-base16.follows = "ppad-base16"; }; ppad-sha512 = { type = "git"; url = "git://git.ppad.tech/sha512.git"; ref = "master"; inputs.ppad-nixpkgs.follows = "ppad-nixpkgs"; + inputs.ppad-base16.follows = "ppad-base16"; }; flake-utils.follows = "ppad-nixpkgs/flake-utils"; nixpkgs.follows = "ppad-nixpkgs/nixpkgs"; @@ -38,15 +40,26 @@ pkgs = import nixpkgs { inherit system; }; hlib = pkgs.haskell.lib; + llvm = pkgs.llvmPackages_15.llvm; base16 = ppad-base16.packages.${system}.default; + sha256 = ppad-sha256.packages.${system}.default; + sha256-llvm = + hlib.addBuildTools + (hlib.enableCabalFlag sha256 "llvm") + [ llvm ]; + sha512 = ppad-sha512.packages.${system}.default; + sha512-llvm = + hlib.addBuildTools + (hlib.enableCabalFlag sha512 "llvm") + [ llvm ]; hpkgs = pkgs.haskell.packages.ghc981.extend (new: old: { ppad-base16 = base16; - ppad-sha256 = sha256; - ppad-sha512 = sha512; + ppad-sha256 = sha256-llvm; + ppad-sha512 = sha512-llvm; ${lib} = new.callCabal2nix lib ./. { ppad-base16 = new.ppad-base16; ppad-sha256 = new.ppad-sha256; @@ -69,10 +82,9 @@ buildInputs = [ cabal cc + llvm ]; - inputsFrom = builtins.attrValues self.packages.${system}; - doBenchmark = true; shellHook = '' @@ -81,6 +93,7 @@ echo "cc: $(${cc}/bin/cc --version)" echo "ghc: $(${ghc}/bin/ghc --version)" echo "cabal: $(${cabal}/bin/cabal --version)" + echo "llc: $(${llvm}/bin/llc --version | head -2 | tail -1)" ''; }; } diff --git a/ppad-pbkdf.cabal b/ppad-pbkdf.cabal @@ -14,6 +14,11 @@ description: A pure implementation of the password-based key derivation function PBKDF2, per RFC 2898. +flag llvm + description: Use GHC's LLVM backend. + default: False + manual: True + source-repository head type: git location: git.ppad.tech/pbkdf.git @@ -23,6 +28,8 @@ library hs-source-dirs: lib ghc-options: -Wall + if flag(llvm) + ghc-options: -fllvm -O2 exposed-modules: Crypto.KDF.PBKDF build-depends: