Copyright | (c) 2024 Auth Global |
---|---|
License | Apache2 |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Internal data structures and functions for hmac
Synopsis
- data HmacKey
- hmacKey_ipad :: HmacKey -> Sha256State
- hmacKey_ipadCtx :: HmacKey -> Sha256Ctx
- hmacKey_opad :: HmacKey -> Sha256State
- hmacKey_opadCtx :: HmacKey -> Sha256Ctx
- data HmacKeyLike
- hmacKeyLike_ipadCtx :: HmacKeyLike -> Sha256Ctx
- hmacKeyLike_opad :: HmacKeyLike -> Sha256State
- hmacKeyLike_opadCtx :: HmacKeyLike -> Sha256Ctx
- hmacKeyLike_runIpadCtx :: HmacKeyLike -> ByteString -> Sha256Ctx
- hmacKeyLike_runOpadCtx :: HmacKeyLike -> ByteString -> Sha256Ctx
- data HmacKeyHashed = HmacKeyHashed {}
- hmacKeyHashed_ipadCtx :: HmacKeyHashed -> Sha256Ctx
- hmacKeyHashed_opadCtx :: HmacKeyHashed -> Sha256Ctx
- hmacKeyHashed_runIpadCtx :: HmacKeyHashed -> ByteString -> Sha256Ctx
- hmacKeyHashed_runOpadCtx :: HmacKeyHashed -> ByteString -> Sha256Ctx
- data HmacKeyPrefixed = HmacKeyPrefixed {}
- hmacKeyPrefixed_opadCtx :: HmacKeyPrefixed -> Sha256Ctx
- hmacKeyPrefixed_runIpadCtx :: HmacKeyPrefixed -> ByteString -> Sha256Ctx
- hmacKeyPrefixed_runOpadCtx :: HmacKeyPrefixed -> ByteString -> Sha256Ctx
- data HmacCtx = HmacCtx {}
Documentation
A cached, precomputed hmac key. It comes in two flavors, one that remembers the plaintext key, and one that doesn't, remembering only the precomputed hmac key.
Computing an hmac key typically requires two SHA256 blocks, unless the key itself is more than 64 bytes, in which case precomputing the key will require at least four SHA256 blocks.
hmacKey_ipad :: HmacKey -> Sha256State Source #
hmacKey_ipadCtx :: HmacKey -> Sha256Ctx Source #
hmacKey_opad :: HmacKey -> Sha256State Source #
hmacKey_opadCtx :: HmacKey -> Sha256Ctx Source #
data HmacKeyLike Source #
An HmacKeyLike
context can either be an HmacKey
, or a
HmacKeyPrefixed
.
HmacKeyLike_Plain !HmacKeyPlain HmacKeyHashed | |
HmacKeyLike_Hashed !HmacKeyHashed | |
HmacKeyLike_Prefixed !HmacKeyPrefixed |
Instances
Eq HmacKeyLike Source # | |
Defined in Crypto.Sha256.Hmac.Implementation (==) :: HmacKeyLike -> HmacKeyLike -> Bool # (/=) :: HmacKeyLike -> HmacKeyLike -> Bool # | |
Ord HmacKeyLike Source # | |
Defined in Crypto.Sha256.Hmac.Implementation compare :: HmacKeyLike -> HmacKeyLike -> Ordering # (<) :: HmacKeyLike -> HmacKeyLike -> Bool # (<=) :: HmacKeyLike -> HmacKeyLike -> Bool # (>) :: HmacKeyLike -> HmacKeyLike -> Bool # (>=) :: HmacKeyLike -> HmacKeyLike -> Bool # max :: HmacKeyLike -> HmacKeyLike -> HmacKeyLike # min :: HmacKeyLike -> HmacKeyLike -> HmacKeyLike # |
data HmacKeyHashed Source #
A precomputed HMAC key. This structure is 64 bytes long, and consists of two SHA256 hashes.
Computing an HMAC key typically costs two SHA256 blocks. No additional blocks are incurred for keys that are 64 bytes or less in length. Keys that are longer than 64 bytes long must be first hashed with SHA256 before the key can be derived, incurring extra block comptuations.
It is not uncommon that implementations of PBKDF2, HKDF, etc unnecessarily redo this computation even though a single HMAC key is used repeatedly.
Technically these "hashes" are unfinished SHA-256 states, as the standard end-of-message padding has yet to be applied. Thus you can't compute these hashes using the most common command-line tools like sha256sum.
The lack of end-of-message padding is also why precomputing HMAC keys on keys up to 64 bytes only requires one SHA-256 block computation for each of the two pads, whereas more typically the boundary for extra block computations happens between the 55th and 56th byte due to end-of-message padding.
Instances
Eq HmacKeyHashed Source # | |
Defined in Crypto.Sha256.Hmac.Implementation (==) :: HmacKeyHashed -> HmacKeyHashed -> Bool # (/=) :: HmacKeyHashed -> HmacKeyHashed -> Bool # | |
Ord HmacKeyHashed Source # | |
Defined in Crypto.Sha256.Hmac.Implementation compare :: HmacKeyHashed -> HmacKeyHashed -> Ordering # (<) :: HmacKeyHashed -> HmacKeyHashed -> Bool # (<=) :: HmacKeyHashed -> HmacKeyHashed -> Bool # (>) :: HmacKeyHashed -> HmacKeyHashed -> Bool # (>=) :: HmacKeyHashed -> HmacKeyHashed -> Bool # max :: HmacKeyHashed -> HmacKeyHashed -> HmacKeyHashed # min :: HmacKeyHashed -> HmacKeyHashed -> HmacKeyHashed # |
data HmacKeyPrefixed Source #
Halfway between an HmacKeyHashed and an HmacCtx. It's both an HmacKeyHashed that's gained a counter, and a HmacCtx that's guaranteed to contain no unprocessed input data.
Instances
Eq HmacKeyPrefixed Source # | |
Defined in Crypto.Sha256.Hmac.Implementation (==) :: HmacKeyPrefixed -> HmacKeyPrefixed -> Bool # (/=) :: HmacKeyPrefixed -> HmacKeyPrefixed -> Bool # | |
Ord HmacKeyPrefixed Source # | |
Defined in Crypto.Sha256.Hmac.Implementation compare :: HmacKeyPrefixed -> HmacKeyPrefixed -> Ordering # (<) :: HmacKeyPrefixed -> HmacKeyPrefixed -> Bool # (<=) :: HmacKeyPrefixed -> HmacKeyPrefixed -> Bool # (>) :: HmacKeyPrefixed -> HmacKeyPrefixed -> Bool # (>=) :: HmacKeyPrefixed -> HmacKeyPrefixed -> Bool # max :: HmacKeyPrefixed -> HmacKeyPrefixed -> HmacKeyPrefixed # min :: HmacKeyPrefixed -> HmacKeyPrefixed -> HmacKeyPrefixed # |
Fixed-size context representing the state of a partial HMAC computation with a complete HMAC key and a partial message parameter. This maintains a buffer of up to 63 unprocessed bytes, so that you may feed it arbitrary bytestring without dealing with buffer boundaries.