module Botan.KDF where
import Botan.Low.KDF (KDFName(..))
import qualified Botan.Low.KDF as Low
import Botan.Hash
import Botan.MAC
import Botan.Prelude
data KDF
= HKDF Hash
| Hash
| HKDF_Expand Hash
| KDF2 Hash
| KDF1_18033 Hash
| KDF1 Hash
| TLS_12_PRF Hash
| X9_42_PRF
| SP800_108_Counter Hash
| SP800_108_Feedback Hash
| SP800_108_Pipeline Hash
| SP800_56A Hash
| SP800_56C Hash
deriving (Int -> KDF -> ShowS
[KDF] -> ShowS
KDF -> String
(Int -> KDF -> ShowS)
-> (KDF -> String) -> ([KDF] -> ShowS) -> Show KDF
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> KDF -> ShowS
showsPrec :: Int -> KDF -> ShowS
$cshow :: KDF -> String
show :: KDF -> String
$cshowList :: [KDF] -> ShowS
showList :: [KDF] -> ShowS
Show, KDF -> KDF -> Bool
(KDF -> KDF -> Bool) -> (KDF -> KDF -> Bool) -> Eq KDF
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: KDF -> KDF -> Bool
== :: KDF -> KDF -> Bool
$c/= :: KDF -> KDF -> Bool
/= :: KDF -> KDF -> Bool
Eq)
data SP800_108_Mode
= Counter
| Feedback
| Pipeline
kdfName :: KDF -> KDFName
kdfName :: KDF -> KDFName
kdfName (HKDF Hash
h) = KDFName -> KDFName
Low.hkdf (Hash -> KDFName
hashName Hash
h)
kdfName (HKDF_Extract Hash
h) = KDFName -> KDFName
Low.hkdf_extract (Hash -> KDFName
hashName Hash
h)
kdfName (HKDF_Expand Hash
h) = KDFName -> KDFName
Low.hkdf_expand (Hash -> KDFName
hashName Hash
h)
kdfName (KDF2 Hash
h) = KDFName -> KDFName
Low.kdf2 (Hash -> KDFName
hashName Hash
h)
kdfName (KDF1_18033 Hash
h) = KDFName -> KDFName
Low.kdf1_18033 (Hash -> KDFName
hashName Hash
h)
kdfName (KDF1 Hash
h) = KDFName -> KDFName
Low.kdf1 (Hash -> KDFName
hashName Hash
h)
kdfName (TLS_12_PRF Hash
h) = KDFName -> KDFName
Low.tls_12_prf (Hash -> KDFName
hashName Hash
h)
kdfName KDF
X9_42_PRF = KDFName -> KDFName
Low.x9_42_prf (Hash -> KDFName
hashName Hash
SHA1)
kdfName (SP800_108_Counter Hash
h) = KDFName -> KDFName
Low.sp800_108_counter (Hash -> KDFName
hashName Hash
h)
kdfName (SP800_108_Feedback Hash
h) = KDFName -> KDFName
Low.sp800_108_feedback (Hash -> KDFName
hashName Hash
h)
kdfName (SP800_108_Pipeline Hash
h) = KDFName -> KDFName
Low.sp800_108_pipeline (Hash -> KDFName
hashName Hash
h)
kdfName (SP800_56A Hash
h) = KDFName -> KDFName
Low.sp800_56A (Hash -> KDFName
hashName Hash
h)
kdfName (SP800_56C Hash
h) = KDFName -> KDFName
Low.sp800_56C (Hash -> KDFName
hashName Hash
h)
kdf :: KDF -> Int -> ByteString -> ByteString -> ByteString -> ByteString
kdf :: KDF -> Int -> KDFName -> KDFName -> KDFName -> KDFName
kdf KDF
algo Int
outLen KDFName
secret KDFName
salt KDFName
label = IO KDFName -> KDFName
forall a. IO a -> a
unsafePerformIO (IO KDFName -> KDFName) -> IO KDFName -> KDFName
forall a b. (a -> b) -> a -> b
$ KDFName -> Int -> KDFName -> KDFName -> KDFName -> IO KDFName
Low.kdf (KDF -> KDFName
kdfName KDF
algo) Int
outLen KDFName
secret KDFName
salt KDFName
label