Crypto.Hash.IO

cryptonite-0.13: 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
  - hashBlockSize :: a -> Int
  - hashDigestSize :: a -> Int
  - hashInternalContextSize :: a -> Int
  - hashInternalInit :: Ptr (Context a) -> IO ()
  - hashInternalUpdate :: Ptr (Context a) -> Ptr Word8 -> Word32 -> IO ()
  - hashInternalFinalize :: Ptr (Context a) -> Ptr (Digest a) -> IO ()
- 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.

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 |
HashAlgorithm Blake2s_224 |
HashAlgorithm Blake2sp_256 |
HashAlgorithm Blake2sp_224 |
HashAlgorithm Blake2b_512 |
HashAlgorithm Blake2bp_512 |
HashAlgorithm MD2 |
HashAlgorithm MD4 |
HashAlgorithm MD5 |
HashAlgorithm SHA1 |
HashAlgorithm SHA224 |
HashAlgorithm SHA256 |
HashAlgorithm SHA384 |
HashAlgorithm SHA512 |
HashAlgorithm SHA512t_256 |
HashAlgorithm SHA512t_224 |
HashAlgorithm SHA3_512 |
HashAlgorithm SHA3_384 |
HashAlgorithm SHA3_256 |
HashAlgorithm SHA3_224 |
HashAlgorithm Keccak_512 |
HashAlgorithm Keccak_384 |
HashAlgorithm Keccak_256 |
HashAlgorithm Keccak_224 |
HashAlgorithm RIPEMD160 |
HashAlgorithm Tiger |
HashAlgorithm Skein256_256 |
HashAlgorithm Skein256_224 |
HashAlgorithm Skein512_512 |
HashAlgorithm Skein512_384 |
HashAlgorithm Skein512_256 |
HashAlgorithm Skein512_224 |
HashAlgorithm Whirlpool |

data MutableContext a

A Mutable hash context

Instances

ByteArrayAccess (MutableContext 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