Crypto.Hash.IO

cryptonite-0.19: Cryptography Primitives sink

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | unknown
Safe Haskell | None
Language | Haskell2010

Crypto.Hash.IO

Description

Generalized impure cryptographic hash interface

Synopsis

- class HashAlgorithm a where
- data MutableContext a
- hashMutableInit :: HashAlgorithm alg => IO (MutableContext alg)
- hashMutableInitWith :: HashAlgorithm alg => alg -> IO (MutableContext alg)
- hashMutableUpdate :: (ByteArrayAccess ba, HashAlgorithm a) => MutableContext a -> ba -> IO ()
- hashMutableFinalize :: HashAlgorithm a => MutableContext a -> IO (Digest a)
- hashMutableReset :: HashAlgorithm a => MutableContext a -> IO ()

# Documentation

class HashAlgorithm a where #

Class representing hashing algorithms.

The interface presented here is update in place and lowlevel. the Hash module takes care of hidding the mutable interface properly.

Minimal complete definition

hashBlockSize, hashDigestSize, hashInternalContextSize, hashInternalInit, hashInternalUpdate, hashInternalFinalize

Methods

hashBlockSize :: a -> Int #

Get the block size of a hash algorithm

hashDigestSize :: a -> Int #

Get the digest size of a hash algorithm

hashInternalContextSize :: a -> Int #

Get the size of the context used for a hash algorithm

hashInternalInit :: Ptr (Context a) -> IO () #

Initialize a context pointer to the initial state of a hash algorithm

hashInternalUpdate :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO () #

Update the context with some raw data

hashInternalFinalize :: Ptr (Context a) -> Ptr (Digest a) -> IO () #

Finalize the context and set the digest raw memory to the right value

Instances

HashAlgorithm Blake2s_256 # |
Methods hashBlockSize :: Blake2s_256 -> Int # hashDigestSize :: Blake2s_256 -> Int # hashInternalContextSize :: Blake2s_256 -> Int # hashInternalInit :: Ptr (Context Blake2s_256) -> IO () # hashInternalUpdate :: Ptr (Context Blake2s_256) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Blake2s_256) -> Ptr (Digest Blake2s_256) -> IO () #
HashAlgorithm Blake2s_224 # |
Methods hashBlockSize :: Blake2s_224 -> Int # hashDigestSize :: Blake2s_224 -> Int # hashInternalContextSize :: Blake2s_224 -> Int # hashInternalInit :: Ptr (Context Blake2s_224) -> IO () # hashInternalUpdate :: Ptr (Context Blake2s_224) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Blake2s_224) -> Ptr (Digest Blake2s_224) -> IO () #
HashAlgorithm Blake2sp_256 # |
Methods hashBlockSize :: Blake2sp_256 -> Int # hashDigestSize :: Blake2sp_256 -> Int # hashInternalContextSize :: Blake2sp_256 -> Int # hashInternalInit :: Ptr (Context Blake2sp_256) -> IO () # hashInternalUpdate :: Ptr (Context Blake2sp_256) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Blake2sp_256) -> Ptr (Digest Blake2sp_256) -> IO () #
HashAlgorithm Blake2sp_224 # |
Methods hashBlockSize :: Blake2sp_224 -> Int # hashDigestSize :: Blake2sp_224 -> Int # hashInternalContextSize :: Blake2sp_224 -> Int # hashInternalInit :: Ptr (Context Blake2sp_224) -> IO () # hashInternalUpdate :: Ptr (Context Blake2sp_224) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Blake2sp_224) -> Ptr (Digest Blake2sp_224) -> IO () #
HashAlgorithm Blake2b_512 # |
Methods hashBlockSize :: Blake2b_512 -> Int # hashDigestSize :: Blake2b_512 -> Int # hashInternalContextSize :: Blake2b_512 -> Int # hashInternalInit :: Ptr (Context Blake2b_512) -> IO () # hashInternalUpdate :: Ptr (Context Blake2b_512) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Blake2b_512) -> Ptr (Digest Blake2b_512) -> IO () #
HashAlgorithm Blake2bp_512 # |
Methods hashBlockSize :: Blake2bp_512 -> Int # hashDigestSize :: Blake2bp_512 -> Int # hashInternalContextSize :: Blake2bp_512 -> Int # hashInternalInit :: Ptr (Context Blake2bp_512) -> IO () # hashInternalUpdate :: Ptr (Context Blake2bp_512) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Blake2bp_512) -> Ptr (Digest Blake2bp_512) -> IO () #
HashAlgorithm MD2 # |
Methods hashBlockSize :: MD2 -> Int # hashDigestSize :: MD2 -> Int # hashInternalContextSize :: MD2 -> Int # hashInternalInit :: Ptr (Context MD2) -> IO () # hashInternalUpdate :: Ptr (Context MD2) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context MD2) -> Ptr (Digest MD2) -> IO () #
HashAlgorithm MD4 # |
Methods hashBlockSize :: MD4 -> Int # hashDigestSize :: MD4 -> Int # hashInternalContextSize :: MD4 -> Int # hashInternalInit :: Ptr (Context MD4) -> IO () # hashInternalUpdate :: Ptr (Context MD4) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context MD4) -> Ptr (Digest MD4) -> IO () #
HashAlgorithm MD5 # |
Methods hashBlockSize :: MD5 -> Int # hashDigestSize :: MD5 -> Int # hashInternalContextSize :: MD5 -> Int # hashInternalInit :: Ptr (Context MD5) -> IO () # hashInternalUpdate :: Ptr (Context MD5) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context MD5) -> Ptr (Digest MD5) -> IO () #
HashAlgorithm SHA1 # |
Methods hashBlockSize :: SHA1 -> Int # hashDigestSize :: SHA1 -> Int # hashInternalContextSize :: SHA1 -> Int # hashInternalInit :: Ptr (Context SHA1) -> IO () # hashInternalUpdate :: Ptr (Context SHA1) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context SHA1) -> Ptr (Digest SHA1) -> IO () #
HashAlgorithm SHA224 # |
Methods hashBlockSize :: SHA224 -> Int # hashDigestSize :: SHA224 -> Int # hashInternalContextSize :: SHA224 -> Int # hashInternalInit :: Ptr (Context SHA224) -> IO () # hashInternalUpdate :: Ptr (Context SHA224) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context SHA224) -> Ptr (Digest SHA224) -> IO () #
HashAlgorithm SHA256 # |
Methods hashBlockSize :: SHA256 -> Int # hashDigestSize :: SHA256 -> Int # hashInternalContextSize :: SHA256 -> Int # hashInternalInit :: Ptr (Context SHA256) -> IO () # hashInternalUpdate :: Ptr (Context SHA256) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context SHA256) -> Ptr (Digest SHA256) -> IO () #
HashAlgorithm SHA384 # |
Methods hashBlockSize :: SHA384 -> Int # hashDigestSize :: SHA384 -> Int # hashInternalContextSize :: SHA384 -> Int # hashInternalInit :: Ptr (Context SHA384) -> IO () # hashInternalUpdate :: Ptr (Context SHA384) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context SHA384) -> Ptr (Digest SHA384) -> IO () #
HashAlgorithm SHA512 # |
Methods hashBlockSize :: SHA512 -> Int # hashDigestSize :: SHA512 -> Int # hashInternalContextSize :: SHA512 -> Int # hashInternalInit :: Ptr (Context SHA512) -> IO () # hashInternalUpdate :: Ptr (Context SHA512) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context SHA512) -> Ptr (Digest SHA512) -> IO () #
HashAlgorithm SHA512t_256 # |
Methods hashBlockSize :: SHA512t_256 -> Int # hashDigestSize :: SHA512t_256 -> Int # hashInternalContextSize :: SHA512t_256 -> Int # hashInternalInit :: Ptr (Context SHA512t_256) -> IO () # hashInternalUpdate :: Ptr (Context SHA512t_256) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context SHA512t_256) -> Ptr (Digest SHA512t_256) -> IO () #
HashAlgorithm SHA512t_224 # |
Methods hashBlockSize :: SHA512t_224 -> Int # hashDigestSize :: SHA512t_224 -> Int # hashInternalContextSize :: SHA512t_224 -> Int # hashInternalInit :: Ptr (Context SHA512t_224) -> IO () # hashInternalUpdate :: Ptr (Context SHA512t_224) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context SHA512t_224) -> Ptr (Digest SHA512t_224) -> IO () #
HashAlgorithm SHA3_512 # |
Methods hashBlockSize :: SHA3_512 -> Int # hashDigestSize :: SHA3_512 -> Int # hashInternalContextSize :: SHA3_512 -> Int # hashInternalInit :: Ptr (Context SHA3_512) -> IO () # hashInternalUpdate :: Ptr (Context SHA3_512) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context SHA3_512) -> Ptr (Digest SHA3_512) -> IO () #
HashAlgorithm SHA3_384 # |
Methods hashBlockSize :: SHA3_384 -> Int # hashDigestSize :: SHA3_384 -> Int # hashInternalContextSize :: SHA3_384 -> Int # hashInternalInit :: Ptr (Context SHA3_384) -> IO () # hashInternalUpdate :: Ptr (Context SHA3_384) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context SHA3_384) -> Ptr (Digest SHA3_384) -> IO () #
HashAlgorithm SHA3_256 # |
Methods hashBlockSize :: SHA3_256 -> Int # hashDigestSize :: SHA3_256 -> Int # hashInternalContextSize :: SHA3_256 -> Int # hashInternalInit :: Ptr (Context SHA3_256) -> IO () # hashInternalUpdate :: Ptr (Context SHA3_256) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context SHA3_256) -> Ptr (Digest SHA3_256) -> IO () #
HashAlgorithm SHA3_224 # |
Methods hashBlockSize :: SHA3_224 -> Int # hashDigestSize :: SHA3_224 -> Int # hashInternalContextSize :: SHA3_224 -> Int # hashInternalInit :: Ptr (Context SHA3_224) -> IO () # hashInternalUpdate :: Ptr (Context SHA3_224) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context SHA3_224) -> Ptr (Digest SHA3_224) -> IO () #
HashAlgorithm Keccak_512 # |
Methods hashBlockSize :: Keccak_512 -> Int # hashDigestSize :: Keccak_512 -> Int # hashInternalContextSize :: Keccak_512 -> Int # hashInternalInit :: Ptr (Context Keccak_512) -> IO () # hashInternalUpdate :: Ptr (Context Keccak_512) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Keccak_512) -> Ptr (Digest Keccak_512) -> IO () #
HashAlgorithm Keccak_384 # |
Methods hashBlockSize :: Keccak_384 -> Int # hashDigestSize :: Keccak_384 -> Int # hashInternalContextSize :: Keccak_384 -> Int # hashInternalInit :: Ptr (Context Keccak_384) -> IO () # hashInternalUpdate :: Ptr (Context Keccak_384) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Keccak_384) -> Ptr (Digest Keccak_384) -> IO () #
HashAlgorithm Keccak_256 # |
Methods hashBlockSize :: Keccak_256 -> Int # hashDigestSize :: Keccak_256 -> Int # hashInternalContextSize :: Keccak_256 -> Int # hashInternalInit :: Ptr (Context Keccak_256) -> IO () # hashInternalUpdate :: Ptr (Context Keccak_256) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Keccak_256) -> Ptr (Digest Keccak_256) -> IO () #
HashAlgorithm Keccak_224 # |
Methods hashBlockSize :: Keccak_224 -> Int # hashDigestSize :: Keccak_224 -> Int # hashInternalContextSize :: Keccak_224 -> Int # hashInternalInit :: Ptr (Context Keccak_224) -> IO () # hashInternalUpdate :: Ptr (Context Keccak_224) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Keccak_224) -> Ptr (Digest Keccak_224) -> IO () #
HashAlgorithm RIPEMD160 # |
Methods hashBlockSize :: RIPEMD160 -> Int # hashDigestSize :: RIPEMD160 -> Int # hashInternalContextSize :: RIPEMD160 -> Int # hashInternalInit :: Ptr (Context RIPEMD160) -> IO () # hashInternalUpdate :: Ptr (Context RIPEMD160) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context RIPEMD160) -> Ptr (Digest RIPEMD160) -> IO () #
HashAlgorithm Tiger # |
Methods hashBlockSize :: Tiger -> Int # hashDigestSize :: Tiger -> Int # hashInternalContextSize :: Tiger -> Int # hashInternalInit :: Ptr (Context Tiger) -> IO () # hashInternalUpdate :: Ptr (Context Tiger) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Tiger) -> Ptr (Digest Tiger) -> IO () #
HashAlgorithm Skein256_256 # |
Methods hashBlockSize :: Skein256_256 -> Int # hashDigestSize :: Skein256_256 -> Int # hashInternalContextSize :: Skein256_256 -> Int # hashInternalInit :: Ptr (Context Skein256_256) -> IO () # hashInternalUpdate :: Ptr (Context Skein256_256) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Skein256_256) -> Ptr (Digest Skein256_256) -> IO () #
HashAlgorithm Skein256_224 # |
Methods hashBlockSize :: Skein256_224 -> Int # hashDigestSize :: Skein256_224 -> Int # hashInternalContextSize :: Skein256_224 -> Int # hashInternalInit :: Ptr (Context Skein256_224) -> IO () # hashInternalUpdate :: Ptr (Context Skein256_224) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Skein256_224) -> Ptr (Digest Skein256_224) -> IO () #
HashAlgorithm Skein512_512 # |
Methods hashBlockSize :: Skein512_512 -> Int # hashDigestSize :: Skein512_512 -> Int # hashInternalContextSize :: Skein512_512 -> Int # hashInternalInit :: Ptr (Context Skein512_512) -> IO () # hashInternalUpdate :: Ptr (Context Skein512_512) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Skein512_512) -> Ptr (Digest Skein512_512) -> IO () #
HashAlgorithm Skein512_384 # |
Methods hashBlockSize :: Skein512_384 -> Int # hashDigestSize :: Skein512_384 -> Int # hashInternalContextSize :: Skein512_384 -> Int # hashInternalInit :: Ptr (Context Skein512_384) -> IO () # hashInternalUpdate :: Ptr (Context Skein512_384) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Skein512_384) -> Ptr (Digest Skein512_384) -> IO () #
HashAlgorithm Skein512_256 # |
Methods hashBlockSize :: Skein512_256 -> Int # hashDigestSize :: Skein512_256 -> Int # hashInternalContextSize :: Skein512_256 -> Int # hashInternalInit :: Ptr (Context Skein512_256) -> IO () # hashInternalUpdate :: Ptr (Context Skein512_256) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Skein512_256) -> Ptr (Digest Skein512_256) -> IO () #
HashAlgorithm Skein512_224 # |
Methods hashBlockSize :: Skein512_224 -> Int # hashDigestSize :: Skein512_224 -> Int # hashInternalContextSize :: Skein512_224 -> Int # hashInternalInit :: Ptr (Context Skein512_224) -> IO () # hashInternalUpdate :: Ptr (Context Skein512_224) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Skein512_224) -> Ptr (Digest Skein512_224) -> IO () #
HashAlgorithm Whirlpool # |
Methods hashBlockSize :: Whirlpool -> Int # hashDigestSize :: Whirlpool -> Int # hashInternalContextSize :: Whirlpool -> Int # hashInternalInit :: Ptr (Context Whirlpool) -> IO () # hashInternalUpdate :: Ptr (Context Whirlpool) -> Ptr Word8 -> Word32 -> IO () # hashInternalFinalize :: Ptr (Context Whirlpool) -> Ptr (Digest Whirlpool) -> IO () #

data MutableContext a #

A Mutable hash context

Instances

ByteArrayAccess (MutableContext a) # |
Methods length :: MutableContext a -> Int # withByteArray :: MutableContext a -> (Ptr p -> IO a) -> IO a #

hashMutableInit :: HashAlgorithm alg => IO (MutableContext alg) #

Create a new mutable hash context.

the algorithm used is automatically determined from the return constraint.

hashMutableInitWith :: HashAlgorithm alg => alg -> IO (MutableContext alg) #

Create a new mutable hash context.

The algorithm is explicitely passed as parameter

hashMutableUpdate :: (ByteArrayAccess ba, HashAlgorithm a) => MutableContext a -> ba -> IO () #

Update a mutable hash context in place

hashMutableFinalize :: HashAlgorithm a => MutableContext a -> IO (Digest a) #

Finalize a mutable hash context and compute a digest

hashMutableReset :: HashAlgorithm a => MutableContext a -> IO () #

Reset the mutable context to the initial state of the hash