| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
BLAKE3.IO
Description
IO and low level tools.
Synopsis
- hash :: forall len bin. (KnownNat len, ByteArrayAccess bin) => [bin] -> IO (Digest len)
- init :: Ptr Hasher -> IO ()
- update :: forall bin. ByteArrayAccess bin => Ptr Hasher -> [bin] -> IO ()
- finalize :: forall len. KnownNat len => Ptr Hasher -> IO (Digest len)
- finalizeSeek :: forall len. KnownNat len => Ptr Hasher -> Word64 -> IO (Digest len)
- data Digest (len :: Nat)
- digest :: forall len bin. (KnownNat len, ByteArrayAccess bin) => bin -> Maybe (Digest len)
- data Key
- key :: ByteArrayAccess bin => bin -> Maybe Key
- initKeyed :: Ptr Hasher -> Key -> IO ()
- data Context
- context :: ByteArrayAccess bin => bin -> Maybe Context
- initDerive :: Ptr Hasher -> Context -> IO ()
- data Hasher
- modifyHasher :: Hasher -> (Ptr Hasher -> IO a) -> IO a
- type HASHER_ALIGNMENT = 8
- type HASHER_SIZE = 1912
- type KEY_LEN = 32
- type BLOCK_SIZE = 64
- type DEFAULT_DIGEST_LEN = 32
- type CHUNK_LEN = 1024
- type MAX_DEPTH = 54
- type MAX_SIMD_DEGREE = 16
- c_init :: Ptr Hasher -> IO ()
- c_init_keyed :: Ptr Hasher -> Ptr Word8 -> IO ()
- c_init_derive_key :: Ptr Hasher -> CString -> IO ()
- c_update :: Ptr Hasher -> Ptr Word8 -> CSize -> IO ()
- c_finalize :: Ptr Hasher -> Ptr Word8 -> CSize -> IO ()
- c_finalize_seek :: Ptr Hasher -> Word64 -> Ptr Word8 -> CSize -> IO ()
Hashing
Arguments
| :: (KnownNat len, ByteArrayAccess bin) | |
| => [bin] | Data to hash. |
| -> IO (Digest len) | Default digest length is |
BLAKE3 hashing.
Initialize a Hasher.
Arguments
| :: ByteArrayAccess bin | |
| => Ptr Hasher | Obtain with |
| -> [bin] | |
| -> IO () |
Update Hasher state with new data.
Arguments
| :: KnownNat len | |
| => Ptr Hasher | Obtain with |
| -> IO (Digest len) | Default digest length is |
Finalize incremental hashin and obtain a Digest.
Arguments
| :: KnownNat len | |
| => Ptr Hasher | Obtain with |
| -> Word64 | Number of bytes to skip before obtaning the digest output. |
| -> IO (Digest len) | Default digest length is |
Finalize incremental hashing and obtain a Digest of length len after
the specified number of bytes of BLAKE3 output.
finalizeh =finalizeSeekh 0
Digest
data Digest (len :: Nat) Source #
Output from BLAKE3 algorithm, of len bytes.
The default digest length for BLAKE3 is DEFAULT_DIGEST_LEN.
Instances
| KnownNat len => ByteArrayN len (Digest len) Source # | Allocate a |
| Eq (Digest len) Source # | Constant time. |
| Show (Digest len) Source # | Base 16 (hexadecimal). |
| KnownNat len => Storable (Digest len) Source # | When allocating a |
Defined in BLAKE3.IO Methods alignment :: Digest len -> Int # peekElemOff :: Ptr (Digest len) -> Int -> IO (Digest len) # pokeElemOff :: Ptr (Digest len) -> Int -> Digest len -> IO () # peekByteOff :: Ptr b -> Int -> IO (Digest len) # pokeByteOff :: Ptr b -> Int -> Digest len -> IO () # | |
| ByteArrayAccess (Digest len) Source # | |
Arguments
| :: (KnownNat len, ByteArrayAccess bin) | |
| => bin | Raw digest bytes. Must have length |
| -> Maybe (Digest len) |
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.
Keyed hashing
Instances
| Eq Key Source # | Constant time. |
| Show Key Source # | Base 16 (hexadecimal). |
| Storable Key Source # | When allocating a |
Defined in BLAKE3.IO | |
| ByteArrayAccess Key Source # | Length is |
| ByteArrayN KEY_LEN Key Source # | Allocate a |
Arguments
| :: ByteArrayAccess bin | |
| => bin | Key bytes. Must have length |
| -> Maybe Key |
Initialize a Hasher in keyed mode.
Key derivation
Context for BLAKE3 key derivation. Obtain with context.
Instances
| Eq Context Source # | |
| Show Context Source # | Base 16 (hexadecimal). |
| IsString Context Source # |
|
Defined in BLAKE3.IO Methods fromString :: String -> Context # | |
| ByteArrayAccess Context Source # | |
Arguments
| :: ByteArrayAccess bin | |
| => bin | If |
| -> Maybe 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
Hasher
BLAKE3 internal state.
Obtain with hasher, hasherKeyed.
Instances
| Eq Hasher Source # | |
| Show Hasher Source # | Base 16 (hexadecimal). |
| Storable Hasher Source # | When allocating a |
| ByteArrayAccess Hasher Source # | Length is |
| ByteArrayN HASHER_SIZE Hasher Source # | Allocate a |
Obtain a to use with functions like Ptr HasherinitDerive, etc.
Constants
type HASHER_ALIGNMENT = 8 Source #
type HASHER_SIZE = 1912 Source #
In bytes.
type BLOCK_SIZE = 64 Source #
In bytes.
type DEFAULT_DIGEST_LEN = 32 Source #
In bytes.
type MAX_SIMD_DEGREE = 16 Source #
Low-level C bindings
Arguments
| :: Ptr Hasher | You can obtain with |
| -> IO () |
void blake3_hasher_init(blake3_hasher *self)
Arguments
| :: Ptr Hasher | You can obtain with |
| -> Ptr Word8 | You can obtain with |
| -> IO () |
void blake3_hasher_init_keyed(blake3_hasher *self, const uint8_t key[KEY_LEN])Arguments
| :: Ptr Hasher | You can obtain with |
| -> CString | Context. |
| -> IO () |
void blake3_hasher_init_derive_key(blake3_hasher *self, const char *context)
Arguments
| :: Ptr Hasher | Must have been previously initializedi. See |
| -> Ptr Word8 | Data. |
| -> CSize | Data length. |
| -> IO () |
void blake3_hasher_update(blake3_hasher *self, const void *input, size_t input_len)
Arguments
| :: Ptr Hasher | Must have been previously initializedi. See |
| -> Ptr Word8 | Out. |
| -> CSize | Out length. |
| -> IO () |
void blake3_hasher_finalize(const blake3_hasher *self, uint8_t *out, size_t out_len)
Arguments
| :: Ptr Hasher | Must have been previously initializedi. See |
| -> Word64 | Seek position. |
| -> Ptr Word8 | Out. |
| -> CSize | Out length. |
| -> IO () |
void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek, uint8_t *out, size_t out_len)