-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | BLAKE3 hashing algorithm -- -- Bindings to the official fast BLAKE3 implementations in assembly and -- C, with support for AVX-512, AVX2 and SSE 4.1. @package blake3 @version 0.2 -- | IO and low level tools. module BLAKE3.IO -- | BLAKE3 hashing. hash :: forall len bin. (KnownNat len, ByteArrayAccess bin) => [bin] -> IO (Digest len) -- | Initialize a Hasher. init :: Ptr Hasher -> IO () -- | Update Hasher state with new data. update :: forall bin. ByteArrayAccess bin => Ptr Hasher -> [bin] -> IO () -- | Finalize incremental hashin and obtain a Digest. finalize :: forall len. KnownNat len => Ptr Hasher -> IO (Digest len) -- | Finalize incremental hashing and obtain a Digest of length -- len after the specified number of bytes of BLAKE3 -- output. -- --
--   finalize h = finalizeSeek h 0
--   
finalizeSeek :: forall len. KnownNat len => Ptr Hasher -> Word64 -> IO (Digest len) -- | Output from BLAKE3 algorithm, of len bytes. -- -- The default digest length for BLAKE3 is DEFAULT_DIGEST_LEN. data Digest (len :: Nat) -- | Obtain a digest containing bytes from a third-party source. -- -- This is useful if you want to use the Digest datatype in your -- programs, but you are loading the pre-calculated digests from a -- database or similar. digest :: forall len bin. (KnownNat len, ByteArrayAccess bin) => bin -> Maybe (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 -- | Initialize a Hasher in keyed mode. initKeyed :: Ptr Hasher -> 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 Hasher in derivation mode. -- -- The input key material must be provided afterwards, using -- update. initDerive :: Ptr Hasher -> Context -> IO () -- | BLAKE3 internal state. -- -- Obtain with hasher, hasherKeyed. data Hasher -- | Obtain a Ptr Hasher to use with functions like -- initDerive, etc. modifyHasher :: Hasher -> (Ptr Hasher -> IO a) -> IO a 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 type CHUNK_LEN = 1024 type MAX_DEPTH = 54 type MAX_SIMD_DEGREE = 16 -- |
--   void blake3_hasher_init(blake3_hasher *self)
--   
c_init :: Ptr Hasher -> IO () -- |
--   void blake3_hasher_init_keyed(blake3_hasher *self, const uint8_t key[KEY_LEN])
--   
c_init_keyed :: Ptr Hasher -> Ptr Word8 -> IO () -- |
--   void blake3_hasher_init_derive_key(blake3_hasher *self, const char *context)
--   
c_init_derive_key :: Ptr Hasher -> CString -> IO () -- |
--   void blake3_hasher_update(blake3_hasher *self, const void *input, size_t input_len)
--   
c_update :: Ptr Hasher -> Ptr Word8 -> CSize -> IO () -- |
--   void blake3_hasher_finalize(const blake3_hasher *self, uint8_t *out, size_t out_len)
--   
c_finalize :: Ptr Hasher -> Ptr Word8 -> CSize -> IO () -- |
--   void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek, uint8_t *out, size_t out_len)
--   
c_finalize_seek :: Ptr Hasher -> Word64 -> Ptr Word8 -> CSize -> IO () instance Data.ByteArray.Sized.ByteArrayN BLAKE3.IO.HASHER_SIZE BLAKE3.IO.Hasher instance Data.ByteArray.Types.ByteArrayAccess BLAKE3.IO.Hasher instance GHC.Classes.Eq BLAKE3.IO.Context instance GHC.Classes.Eq BLAKE3.IO.Hasher instance GHC.Show.Show BLAKE3.IO.Hasher instance Foreign.Storable.Storable BLAKE3.IO.Hasher instance Data.ByteArray.Sized.ByteArrayN BLAKE3.IO.KEY_LEN BLAKE3.IO.Key instance Data.ByteArray.Types.ByteArrayAccess BLAKE3.IO.Context instance GHC.Show.Show BLAKE3.IO.Context instance Data.String.IsString BLAKE3.IO.Context instance GHC.Classes.Eq BLAKE3.IO.Key instance GHC.Show.Show BLAKE3.IO.Key instance Data.ByteArray.Types.ByteArrayAccess BLAKE3.IO.Key instance Foreign.Storable.Storable BLAKE3.IO.Key instance GHC.Classes.Eq (BLAKE3.IO.Digest len) instance GHC.Show.Show (BLAKE3.IO.Digest len) instance Data.ByteArray.Types.ByteArrayAccess (BLAKE3.IO.Digest len) instance GHC.TypeNats.KnownNat len => Data.ByteArray.Sized.ByteArrayN len (BLAKE3.IO.Digest len) instance GHC.TypeNats.KnownNat len => Foreign.Storable.Storable (BLAKE3.IO.Digest len) -- | Haskell bindings to the fast official BLAKE3 hashing implementation -- in assembly and C. With support for AVX-512, AVX2 and SSE 4.1. -- -- The original assembly and 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) -- | Obtain a digest containing bytes from a third-party source. -- -- This is useful if you want to use the Digest datatype in your -- programs, but you are loading the pre-calculated digests from a -- database or similar. digest :: forall len bin. (KnownNat len, ByteArrayAccess bin) => bin -> Maybe (Digest len) -- | BLAKE3 hashing with a Key. -- -- This can be used for MAC (message authentication code), PRF (pseudo -- random function) and SHO (stateful hash object) purposes. -- -- 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. -- -- This can be used for KDF (key derivation function) purposes. 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 -- | BLAKE3 internal state. -- -- Obtain with hasher, 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 -- | Finish hashing and obtain a Digest of the specified -- length. finalize :: forall len. KnownNat len => Hasher -> Digest len -- | Finalize incremental hashing and obtain a Digest of length -- len after the specified number of bytes of BLAKE3 -- output. -- --
--   finalize h = finalizeSeek h 0
--   
finalizeSeek :: forall len. KnownNat len => Hasher -> Word64 -> Digest len -- | In bytes. type KEY_LEN = 32 -- | In bytes. type BLOCK_SIZE = 64 -- | In bytes. type DEFAULT_DIGEST_LEN = 32