| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
BLAKE3.IO
Description
IO and low level tools.
Synopsis
- hash :: forall (len :: Nat) digest bin. (ByteArrayN len digest, ByteArrayAccess bin) => Maybe Key -> [bin] -> IO digest
- init :: Ptr Hasher -> Maybe Key -> IO ()
- update :: ByteArrayAccess bin => Ptr Hasher -> [bin] -> IO ()
- finalize :: forall (len :: Nat) output. ByteArrayN len output => Ptr Hasher -> IO output
- finalizeSeek :: forall (len :: Nat) output. ByteArrayN len output => Ptr Hasher -> Word64 -> IO output
- newtype Digest (len :: Nat) = Digest (SizedByteArray len ScrubbedBytes)
- data Key
- key :: ByteArrayAccess bin => bin -> Maybe Key
- initDerive :: ByteArrayAccess context => 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_raw :: Ptr Hasher -> Ptr Word8 -> CSize -> IO ()
- c_update :: Ptr Hasher -> Ptr Word8 -> CSize -> IO ()
- c_update__safe :: Ptr Hasher -> Ptr Word8 -> CSize -> IO ()
- c_update__unsafe :: 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
| :: forall (len :: Nat) digest bin. (ByteArrayN len digest, ByteArrayAccess bin) | |
| => Maybe Key | Whether to use keyed hashing mode (for MAC, PRF). |
| -> [bin] | Data to hash. |
| -> IO digest | The |
BLAKE3 hashing.
Arguments
| :: Ptr Hasher | Obtain with |
| -> Maybe Key | Whether to use keyed hashing mode (for MAC, PRF). |
| -> IO () |
Initialize a Hasher.
Arguments
| :: ByteArrayAccess bin | |
| => Ptr Hasher | Obtain with |
| -> [bin] | |
| -> IO () |
Update Hasher state with new data.
Arguments
| :: forall (len :: Nat) output. ByteArrayN len output | |
| => Ptr Hasher | Obtain with |
| -> IO output | The |
Finalize incremental hashing and obtain a the BLAKE3 output of the
specified length.
Arguments
| :: forall (len :: Nat) output. ByteArrayN len output | |
| => Ptr Hasher | Obtain with |
| -> Word64 | BLAKE3 output offset. |
| -> IO output |
Finalize incremental hashing and obtain the specified length of BLAKE3
output starting at the specified offset.
finalizeh =finalizeSeekh 0
Digest
newtype Digest (len :: Nat) Source #
Output from BLAKE3 algorithm, of len bytes.
The default digest length for BLAKE3 is DEFAULT_DIGEST_LEN.
Constructors
| Digest (SizedByteArray len ScrubbedBytes) |
Instances
| KnownNat len => ByteArrayN len (Digest len) Source # | |
| 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 () | |
| Show (Digest len) Source # | Base 16 (hexadecimal). |
| Eq (Digest len) Source # | Constant time. |
| Ord (Digest len) Source # | |
| KnownNat len => ByteArrayAccess (Digest len) Source # | |
Defined in BLAKE3.IO Methods withByteArray :: Digest len -> (Ptr p -> IO a) -> IO a copyByteArrayToPtr :: Digest len -> Ptr p -> IO () | |
Keyed hashing
Instances
| Storable Key Source # | When allocating a |
| Show Key Source # | Base 16 (hexadecimal). |
| Eq Key Source # | Constant time. |
| ByteArrayAccess Key Source # | Length is |
Defined in BLAKE3.IO | |
| ByteArrayN KEY_LEN Key Source # | Allocate a The memory is wiped and freed as soon as the |
Key derivation
Hasher
BLAKE3 internal state.
Obtain with hasher, hasherKeyed.
Instances
| Storable Hasher Source # | When allocating a |
Defined in BLAKE3.IO Methods peekElemOff :: Ptr Hasher -> Int -> IO Hasher pokeElemOff :: Ptr Hasher -> Int -> Hasher -> IO () peekByteOff :: Ptr b -> Int -> IO Hasher pokeByteOff :: Ptr b -> Int -> Hasher -> IO () | |
| Show Hasher Source # | Base 16 (hexadecimal). |
| Eq Hasher Source # | Constant time. |
| ByteArrayAccess Hasher Source # | Length is |
Defined in BLAKE3.IO Methods withByteArray :: Hasher -> (Ptr p -> IO a) -> IO a copyByteArrayToPtr :: Hasher -> Ptr p -> IO () | |
| ByteArrayN HASHER_SIZE Hasher Source # | Allocate a |
Defined in BLAKE3.IO Methods allocRet :: Proxy HASHER_SIZE -> (Ptr p -> IO a) -> IO (a, Hasher) | |
Arguments
| :: Hasher | |
| -> (Ptr Hasher -> IO a) |
|
| -> IO 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])c_init_derive_key_raw Source #
Arguments
| :: Ptr Hasher | You can obtain with |
| -> Ptr Word8 | Context. |
| -> CSize | Context length. |
| -> IO () |
void blake3_hasher_init_derive_key_raw(blake3_hasher *self, const void *context, size_t context_len)
Arguments
| :: Ptr Hasher | Must have been previously initialized. See |
| -> Ptr Word8 | Data. |
| -> CSize | Data length. |
| -> IO () |
void blake3_hasher_update(blake3_hasher *self, const void *input, size_t input_len)
Uses c_update__unsafe FFI call for input_len of up to 16 KiB, and
c_update__safe otherwise.
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)
Like c_update_safe, but marked safe for FFI purposes.
Suitable when input_len is small. See c_update.
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)
Like c_update__safe, but marked unsafe for FFI purposes.
Suitable when input_len is big. See c_update.
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)