-------------------------------------------------------------------------------
-- |
-- Module:      Crypto.Sha256.Hkdf.Subtle
-- Copyright:   (c) 2024 Auth Global
-- License:     Apache2
--
-------------------------------------------------------------------------------

module Crypto.Sha256.Hkdf.Subtle where

import Data.ByteString.Short(ShortByteString)
import Data.Word
import Crypto.HashString
import Crypto.Sha256.Hmac

-- | Context type for incremental @hkdfExtract@

newtype HkdfCtx = HkdfCtx {
    HkdfCtx -> HmacCtx
hkdfCtx_hmacCtx :: HmacCtx
  } deriving (HkdfCtx -> HkdfCtx -> Bool
(HkdfCtx -> HkdfCtx -> Bool)
-> (HkdfCtx -> HkdfCtx -> Bool) -> Eq HkdfCtx
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HkdfCtx -> HkdfCtx -> Bool
== :: HkdfCtx -> HkdfCtx -> Bool
$c/= :: HkdfCtx -> HkdfCtx -> Bool
/= :: HkdfCtx -> HkdfCtx -> Bool
Eq, Eq HkdfCtx
Eq HkdfCtx =>
(HkdfCtx -> HkdfCtx -> Ordering)
-> (HkdfCtx -> HkdfCtx -> Bool)
-> (HkdfCtx -> HkdfCtx -> Bool)
-> (HkdfCtx -> HkdfCtx -> Bool)
-> (HkdfCtx -> HkdfCtx -> Bool)
-> (HkdfCtx -> HkdfCtx -> HkdfCtx)
-> (HkdfCtx -> HkdfCtx -> HkdfCtx)
-> Ord HkdfCtx
HkdfCtx -> HkdfCtx -> Bool
HkdfCtx -> HkdfCtx -> Ordering
HkdfCtx -> HkdfCtx -> HkdfCtx
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: HkdfCtx -> HkdfCtx -> Ordering
compare :: HkdfCtx -> HkdfCtx -> Ordering
$c< :: HkdfCtx -> HkdfCtx -> Bool
< :: HkdfCtx -> HkdfCtx -> Bool
$c<= :: HkdfCtx -> HkdfCtx -> Bool
<= :: HkdfCtx -> HkdfCtx -> Bool
$c> :: HkdfCtx -> HkdfCtx -> Bool
> :: HkdfCtx -> HkdfCtx -> Bool
$c>= :: HkdfCtx -> HkdfCtx -> Bool
>= :: HkdfCtx -> HkdfCtx -> Bool
$cmax :: HkdfCtx -> HkdfCtx -> HkdfCtx
max :: HkdfCtx -> HkdfCtx -> HkdfCtx
$cmin :: HkdfCtx -> HkdfCtx -> HkdfCtx
min :: HkdfCtx -> HkdfCtx -> HkdfCtx
Ord)

-- | Plain-old-data representation of the generator for @hkdfExpand@

data HkdfGen = HkdfGen
  { HkdfGen -> ShortByteString
hkdfGen_info :: !ShortByteString
  , HkdfGen -> HmacKey
hkdfGen_key :: !HmacKey
  , HkdfGen -> Word8
hkdfGen_counter :: !Word8
  , HkdfGen -> HashString
hkdfGen_state :: !HashString
  }