Skip to content

Commit

Permalink
hkdf: fix constraints to match hmac #122
Browse files Browse the repository at this point in the history
Adjusting to match the underlying SHA2 requirement
Also this accidentally changes the newline format from CRLF to LF
marsella committed Jan 23, 2025
1 parent 768a60b commit a6c53e9
Showing 2 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Primitive/Symmetric/KDF/HKDF.md
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ parameter
type constraint validHMACSizes KeyLen MsgLen =
( fin KeyLen, fin MsgLen
, 32 >= width MsgLen
, 64 >= width (8 * KeyLen)
, 64 > width (8 * KeyLen)
, 64 >= width (8 * 64 + MsgLen))
23 changes: 11 additions & 12 deletions Primitive/Symmetric/KDF/HKDF256.cry
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
module Primitive::Symmetric::KDF::HKDF256 = Primitive::Symmetric::KDF::HKDF where

import Primitive::Symmetric::MAC::HMAC

type HashLen = 32
HMAC = hmacBytes

hmacBytes : {n, m} (64 >= width (8 * (64 + m)),
64 >= width (8 * n), 32 >= width m, fin m, fin n) =>
[n][8] -> [m][8] -> [32][8]
hmacBytes key msg = split (hmacSHA256 key msg)

module Primitive::Symmetric::KDF::HKDF256 = Primitive::Symmetric::KDF::HKDF where

import Primitive::Symmetric::MAC::HMAC

type HashLen = 32
HMAC = hmacBytes

hmacBytes : {n, m} (64 >= width (8 * (64 + m)),
64 > width (8 * n), 32 >= width m, fin m, fin n) =>
[n][8] -> [m][8] -> [32][8]
hmacBytes key msg = split (hmacSHA256 key msg)

0 comments on commit a6c53e9

Please sign in to comment.