hkdf

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

commit 494d24f77d14f24418eda93658b3ec0a09f80482
parent e8bfb8fc61c158ca1f15dc522d4a008a9bc3624b
Author: Jared Tobin <jared@jtobin.io>
Date:   Mon, 24 Feb 2025 07:23:04 +0400

lib: vertical integration

Diffstat:
Mflake.lock | 32++++++++++++++++++++++++++++++++
Mflake.nix | 12+++++++++++-
Mppad-hkdf.cabal | 2+-
Mtest/Wycheproof.hs | 4+++-
4 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/flake.lock b/flake.lock @@ -34,6 +34,37 @@ "type": "github" } }, + "ppad-base16": { + "inputs": { + "flake-utils": [ + "ppad-base16", + "ppad-nixpkgs", + "flake-utils" + ], + "nixpkgs": [ + "ppad-base16", + "ppad-nixpkgs", + "nixpkgs" + ], + "ppad-nixpkgs": [ + "ppad-nixpkgs" + ] + }, + "locked": { + "lastModified": 1739979569, + "narHash": "sha256-omEcmgzRlzIE5Vdty0/SskEcR2f7OtcHzGFE4i1dI60=", + "ref": "master", + "rev": "4439e0efafbb5185bd7d9bfb352a17c2a31b96b4", + "revCount": 15, + "type": "git", + "url": "git://git.ppad.tech/base16.git" + }, + "original": { + "ref": "master", + "type": "git", + "url": "git://git.ppad.tech/base16.git" + } + }, "ppad-nixpkgs": { "inputs": { "flake-utils": "flake-utils", @@ -126,6 +157,7 @@ "ppad-nixpkgs", "nixpkgs" ], + "ppad-base16": "ppad-base16", "ppad-nixpkgs": "ppad-nixpkgs", "ppad-sha256": "ppad-sha256", "ppad-sha512": "ppad-sha512" diff --git a/flake.nix b/flake.nix @@ -7,6 +7,12 @@ url = "git://git.ppad.tech/nixpkgs.git"; ref = "master"; }; + ppad-base16 = { + type = "git"; + url = "git://git.ppad.tech/base16.git"; + ref = "master"; + inputs.ppad-nixpkgs.follows = "ppad-nixpkgs"; + }; ppad-sha256 = { type = "git"; url = "git://git.ppad.tech/sha256.git"; @@ -24,7 +30,8 @@ }; outputs = { self, nixpkgs, flake-utils, ppad-nixpkgs - , ppad-sha256, ppad-sha512 }: + , ppad-sha256, ppad-sha512 + , ppad-base16 }: flake-utils.lib.eachDefaultSystem (system: let lib = "ppad-hkdf"; @@ -32,13 +39,16 @@ pkgs = import nixpkgs { inherit system; }; hlib = pkgs.haskell.lib; + base16 = ppad-base16.packages.${system}.default; sha256 = ppad-sha256.packages.${system}.default; sha512 = ppad-sha512.packages.${system}.default; hpkgs = pkgs.haskell.packages.ghc981.extend (new: old: { + ppad-base16 = base16; ppad-sha256 = sha256; ppad-sha512 = sha512; ${lib} = new.callCabal2nix lib ./. { + ppad-base16 = new.ppad-base16; ppad-sha256 = new.ppad-sha256; ppad-sha512 = new.ppad-sha512; }; diff --git a/ppad-hkdf.cabal b/ppad-hkdf.cabal @@ -43,8 +43,8 @@ test-suite hkdf-tests build-depends: aeson , base - , base16-bytestring , bytestring + , ppad-base16 , ppad-hkdf , ppad-sha256 , ppad-sha512 diff --git a/test/Wycheproof.hs b/test/Wycheproof.hs @@ -48,7 +48,9 @@ data HkdfTest = HkdfTest { } deriving Show decodehex :: T.Text -> BS.ByteString -decodehex = B16.decodeLenient . TE.encodeUtf8 +decodehex t = case B16.decode (TE.encodeUtf8 t) of + Nothing -> error "bang" + Just bs -> bs instance A.FromJSON HkdfTest where parseJSON = A.withObject "HkdfTest" $ \m -> HkdfTest