-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | BLAKE3 hashing algorithm -- -- Bindings to the official BLAKE3 implementation in C @package blake3 @version 0.1 module BLAKE3.IO -- | Initialize a HasherInternal. init :: Ptr HasherInternal -> IO () -- | Update HasherInternal state with new data. update :: forall bin. ByteArrayAccess bin => Ptr HasherInternal -> [bin] -> IO () -- | Finalize HasherInternal state and obtain a digest. -- -- The HasherInternal is mutated. finalize :: forall len. KnownNat len => Ptr HasherInternal -> IO (Digest len) -- | Immutable BLAKE3 hashing state. -- -- Obtain with hasher or hasherKeyed. data Hasher -- | Allocate Hasher. -- -- The Hasher is wiped and freed as soon as it becomes unused. allocRetHasher :: forall a. (Ptr HasherInternal -> IO a) -> IO (a, Hasher) -- | Output from BLAKE3 algorithm, of len bytes. -- -- The default digest length for BLAKE3 is DEFAULT_DIGEST_LEN. data Digest (len :: Nat) -- | Allocate a Digest. -- -- The Digest is wiped and freed as soon as it becomes unused. allocRetDigest :: forall len a. KnownNat len => (Ptr Word8 -> IO a) -> IO (a, Digest len) -- | Opaque datatype of size HASHER_SIZE and alignment -- HASHER_ALIGNMENT. -- -- Obtain with withHasherInternal. data HasherInternal -- | Copy an inmutable Hasher. copyHasher :: Hasher -> IO Hasher -- | Mutate the given Hasher. withHasherInternal :: Hasher -> (Ptr HasherInternal -> IO a) -> IO a -- | Key used for keyed hashing mode. -- -- Obtain with key. -- -- See hashKeyed. data Key -- | Obtain a Key for use in BLAKE3 keyed hashing. -- -- See hashKeyed. key :: ByteArrayAccess bin => bin -> Maybe Key -- | Allocate a Key. -- -- The Key is wiped and freed as soon as it becomes unused. allocRetKey :: forall a. (Ptr Word8 -> IO a) -> IO (a, Key) -- | Initialize a HasherInternal in keyed mode. initKeyed :: Ptr HasherInternal -> Key -> IO () -- | Context for BLAKE3 key derivation. Obtain with context. data Context -- | Obtain a Context for BLAKE3 key derivation. -- -- The context should be hardcoded, globally unique, and -- application-specific. -- -- A good format for the context string is: -- --
-- [application] [commit timestamp] [purpose] ---- -- For example: -- --
-- example.com 2019-12-25 16:18:03 session tokens v1 --context :: ByteArrayAccess bin => bin -> Maybe Context -- | Initialize a HasherInternal in derivation mode. -- -- The input key material must be provided afterwards, using -- update. initDerive :: Ptr HasherInternal -> Context -> IO () type HASHER_ALIGNMENT = 8 -- | In bytes. type HASHER_SIZE = 1912 -- | In bytes. type KEY_LEN = 32 -- | In bytes. type BLOCK_SIZE = 64 -- | In bytes. type DEFAULT_DIGEST_LEN = 32 instance GHC.Classes.Eq BLAKE3.IO.Context instance Data.ByteArray.Types.ByteArrayAccess BLAKE3.IO.Key instance GHC.Classes.Eq BLAKE3.IO.Key instance Data.ByteArray.Types.ByteArrayAccess (BLAKE3.IO.Digest len) instance GHC.Classes.Eq (BLAKE3.IO.Digest len) instance GHC.Show.Show BLAKE3.IO.Context instance Data.String.IsString BLAKE3.IO.Context instance GHC.Show.Show BLAKE3.IO.Key instance GHC.Show.Show (BLAKE3.IO.Digest len) -- | Haskell bindings to the official BLAKE3 hashing implementation in -- C. -- -- The original C implementation is released into the public domain with -- CC0 1.0. Alternatively, it is licensed under the Apache License 2.0, -- copyright of Jack O'Connor and Samuel Neves. See its LICENSE -- for details. -- -- This Haskell library is the copyright of Renzo Carbonara, licensed -- under the terms of the Apache License 2.0. module BLAKE3 -- | BLAKE3 hashing. -- -- For incremental hashing, see hasher, update and -- finalize: -- --
-- hash = finalize . update hasher --hash :: forall len bin. (KnownNat len, ByteArrayAccess bin) => [bin] -> Digest len -- | Output from BLAKE3 algorithm, of len bytes. -- -- The default digest length for BLAKE3 is DEFAULT_DIGEST_LEN. data Digest (len :: Nat) -- | BLAKE3 hashing with a Key. -- -- For incremental hashing, see hasherKeyed, update and -- finalize: -- --
-- hashKeyed key = finalize . update (hasherKeyed key) --hashKeyed :: forall len bin. (KnownNat len, ByteArrayAccess bin) => Key -> [bin] -> Digest len -- | Key used for keyed hashing mode. -- -- Obtain with key. -- -- See hashKeyed. data Key -- | Obtain a Key for use in BLAKE3 keyed hashing. -- -- See hashKeyed. key :: ByteArrayAccess bin => bin -> Maybe Key -- | BLAKE3 key derivation. derive :: forall len ikm. (KnownNat len, ByteArrayAccess ikm) => Context -> [ikm] -> Digest len -- | Context for BLAKE3 key derivation. Obtain with context. data Context -- | Obtain a Context for BLAKE3 key derivation. -- -- The context should be hardcoded, globally unique, and -- application-specific. -- -- A good format for the context string is: -- --
-- [application] [commit timestamp] [purpose] ---- -- For example: -- --
-- example.com 2019-12-25 16:18:03 session tokens v1 --context :: ByteArrayAccess bin => bin -> Maybe Context -- | Immutable BLAKE3 hashing state. -- -- Obtain with hasher or hasherKeyed. data Hasher -- | Initial Hasher for incremental hashing. hasher :: Hasher -- | Initial Hasher for incremental keyed hashing. hasherKeyed :: Key -> Hasher -- | Update Hasher with new data. update :: forall bin. ByteArrayAccess bin => Hasher -> [bin] -> Hasher -- | Update Hasher with new data. finalize :: forall len. KnownNat len => Hasher -> Digest len -- | In bytes. type KEY_LEN = 32 -- | In bytes. type BLOCK_SIZE = 64 -- | In bytes. type DEFAULT_DIGEST_LEN = 32