aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@google.com>2018-08-23 12:24:31 -0400
committerGravatar Benjamin Barenblat <bbaren@google.com>2018-08-23 12:24:31 -0400
commitd225c857d0f445a9842a197d9796925555e0ece5 (patch)
tree5aa0abdd13c5659b6fe2c05e8b22d50c7335ecb7 /src
parent9bbbf151b5bdde3f0bead1886996f17764e85521 (diff)
Codec.Crypto.HKDF: Implement `hkdf` convenience function
Diffstat (limited to 'src')
-rw-r--r--src/Codec/Crypto/HKDF.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Codec/Crypto/HKDF.hs b/src/Codec/Crypto/HKDF.hs
index bd2d7a5..ac86bcc 100644
--- a/src/Codec/Crypto/HKDF.hs
+++ b/src/Codec/Crypto/HKDF.hs
@@ -14,7 +14,7 @@
module Codec.Crypto.HKDF
( AssociatedData(AssociatedData), Salt(Salt), SecretKey(SecretKey), noSalt
- , extract, expand
+ , hkdf, extract, expand
) where
import qualified Data.ByteString as ByteString
@@ -31,6 +31,10 @@ import BTLS.Types
, SecretKey(SecretKey), noSalt
)
+-- | Computes an HKDF as specified by RFC 5869.
+hkdf :: Algorithm -> Salt -> AssociatedData -> Int -> SecretKey -> SecretKey
+hkdf md salt info outLen = expand md info outLen . extract md salt
+
-- | Computes an HKDF pseudorandom key (PRK) as specified by RFC 5869.
extract :: Algorithm -> Salt -> SecretKey -> SecretKey
extract (Algorithm md) (Salt salt) (SecretKey secret) =