Crypto.Hash.Types

cryptohash-0.11.0: collection of crypto hashes, fast, pure and practical

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

Crypto.Hash.Types

Contents

- deprecated

Description

Crypto hash types definitions

Synopsis

- class HashAlgorithm a where
  - hashBlockSize :: Context a -> Int
  - hashInit :: Context a
  - hashUpdates :: Context a -> [ByteString] -> Context a
  - hashFinalize :: Context a -> Digest a
  - digestFromByteString :: ByteString -> Maybe (Digest a)
- newtype Context a = Context ByteString
- newtype Digest a = Digest ByteString
- contextToByteString :: Context a -> ByteString
- digestToByteString :: Digest a -> ByteString

# Documentation

class HashAlgorithm a where #

Class representing hashing algorithms.

The hash algorithm is built over 3 primitives:

init : create a new context updates : update the context with some strict bytestrings finalize : finalize the context into a digest

Methods

hashBlockSize :: Context a -> Int #

Block size in bytes the hash algorithm operates on

hashInit :: Context a #

Initialize a new context for this hash algorithm

hashUpdates :: Context a -> [ByteString] -> Context a #

Update the context with a list of strict bytestring, and return a new context with the updates.

hashFinalize :: Context a -> Digest a #

Finalize a context and return a digest.

digestFromByteString :: ByteString -> Maybe (Digest a) #

Try to convert a binary digest bytestring to a digest.

Instances

HashAlgorithm Skein512_512 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context Skein512_512 -> Int # hashInit :: Context Skein512_512 # hashUpdates :: Context Skein512_512 -> [ByteString] -> Context Skein512_512 # hashFinalize :: Context Skein512_512 -> Digest Skein512_512 # digestFromByteString :: ByteString -> Maybe (Digest Skein512_512) #
HashAlgorithm Skein512_384 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context Skein512_384 -> Int # hashInit :: Context Skein512_384 # hashUpdates :: Context Skein512_384 -> [ByteString] -> Context Skein512_384 # hashFinalize :: Context Skein512_384 -> Digest Skein512_384 # digestFromByteString :: ByteString -> Maybe (Digest Skein512_384) #
HashAlgorithm Skein512_256 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context Skein512_256 -> Int # hashInit :: Context Skein512_256 # hashUpdates :: Context Skein512_256 -> [ByteString] -> Context Skein512_256 # hashFinalize :: Context Skein512_256 -> Digest Skein512_256 # digestFromByteString :: ByteString -> Maybe (Digest Skein512_256) #
HashAlgorithm Skein512_224 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context Skein512_224 -> Int # hashInit :: Context Skein512_224 # hashUpdates :: Context Skein512_224 -> [ByteString] -> Context Skein512_224 # hashFinalize :: Context Skein512_224 -> Digest Skein512_224 # digestFromByteString :: ByteString -> Maybe (Digest Skein512_224) #
HashAlgorithm Skein256_256 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context Skein256_256 -> Int # hashInit :: Context Skein256_256 # hashUpdates :: Context Skein256_256 -> [ByteString] -> Context Skein256_256 # hashFinalize :: Context Skein256_256 -> Digest Skein256_256 # digestFromByteString :: ByteString -> Maybe (Digest Skein256_256) #
HashAlgorithm Skein256_224 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context Skein256_224 -> Int # hashInit :: Context Skein256_224 # hashUpdates :: Context Skein256_224 -> [ByteString] -> Context Skein256_224 # hashFinalize :: Context Skein256_224 -> Digest Skein256_224 # digestFromByteString :: ByteString -> Maybe (Digest Skein256_224) #
HashAlgorithm SHA3_512 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context SHA3_512 -> Int # hashInit :: Context SHA3_512 # hashUpdates :: Context SHA3_512 -> [ByteString] -> Context SHA3_512 # hashFinalize :: Context SHA3_512 -> Digest SHA3_512 # digestFromByteString :: ByteString -> Maybe (Digest SHA3_512) #
HashAlgorithm SHA3_384 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context SHA3_384 -> Int # hashInit :: Context SHA3_384 # hashUpdates :: Context SHA3_384 -> [ByteString] -> Context SHA3_384 # hashFinalize :: Context SHA3_384 -> Digest SHA3_384 # digestFromByteString :: ByteString -> Maybe (Digest SHA3_384) #
HashAlgorithm SHA3_256 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context SHA3_256 -> Int # hashInit :: Context SHA3_256 # hashUpdates :: Context SHA3_256 -> [ByteString] -> Context SHA3_256 # hashFinalize :: Context SHA3_256 -> Digest SHA3_256 # digestFromByteString :: ByteString -> Maybe (Digest SHA3_256) #
HashAlgorithm SHA3_224 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context SHA3_224 -> Int # hashInit :: Context SHA3_224 # hashUpdates :: Context SHA3_224 -> [ByteString] -> Context SHA3_224 # hashFinalize :: Context SHA3_224 -> Digest SHA3_224 # digestFromByteString :: ByteString -> Maybe (Digest SHA3_224) #
HashAlgorithm Tiger # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context Tiger -> Int # hashInit :: Context Tiger # hashUpdates :: Context Tiger -> [ByteString] -> Context Tiger # hashFinalize :: Context Tiger -> Digest Tiger # digestFromByteString :: ByteString -> Maybe (Digest Tiger) #
HashAlgorithm Whirlpool # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context Whirlpool -> Int # hashInit :: Context Whirlpool # hashUpdates :: Context Whirlpool -> [ByteString] -> Context Whirlpool # hashFinalize :: Context Whirlpool -> Digest Whirlpool # digestFromByteString :: ByteString -> Maybe (Digest Whirlpool) #
HashAlgorithm RIPEMD160 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context RIPEMD160 -> Int # hashInit :: Context RIPEMD160 # hashUpdates :: Context RIPEMD160 -> [ByteString] -> Context RIPEMD160 # hashFinalize :: Context RIPEMD160 -> Digest RIPEMD160 # digestFromByteString :: ByteString -> Maybe (Digest RIPEMD160) #
HashAlgorithm SHA512 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context SHA512 -> Int # hashInit :: Context SHA512 # hashUpdates :: Context SHA512 -> [ByteString] -> Context SHA512 # hashFinalize :: Context SHA512 -> Digest SHA512 # digestFromByteString :: ByteString -> Maybe (Digest SHA512) #
HashAlgorithm SHA384 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context SHA384 -> Int # hashInit :: Context SHA384 # hashUpdates :: Context SHA384 -> [ByteString] -> Context SHA384 # hashFinalize :: Context SHA384 -> Digest SHA384 # digestFromByteString :: ByteString -> Maybe (Digest SHA384) #
HashAlgorithm SHA256 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context SHA256 -> Int # hashInit :: Context SHA256 # hashUpdates :: Context SHA256 -> [ByteString] -> Context SHA256 # hashFinalize :: Context SHA256 -> Digest SHA256 # digestFromByteString :: ByteString -> Maybe (Digest SHA256) #
HashAlgorithm SHA224 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context SHA224 -> Int # hashInit :: Context SHA224 # hashUpdates :: Context SHA224 -> [ByteString] -> Context SHA224 # hashFinalize :: Context SHA224 -> Digest SHA224 # digestFromByteString :: ByteString -> Maybe (Digest SHA224) #
HashAlgorithm SHA1 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context SHA1 -> Int # hashInit :: Context SHA1 # hashUpdates :: Context SHA1 -> [ByteString] -> Context SHA1 # hashFinalize :: Context SHA1 -> Digest SHA1 # digestFromByteString :: ByteString -> Maybe (Digest SHA1) #
HashAlgorithm MD5 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context MD5 -> Int # hashInit :: Context MD5 # hashUpdates :: Context MD5 -> [ByteString] -> Context MD5 # hashFinalize :: Context MD5 -> Digest MD5 # digestFromByteString :: ByteString -> Maybe (Digest MD5) #
HashAlgorithm MD4 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context MD4 -> Int # hashInit :: Context MD4 # hashUpdates :: Context MD4 -> [ByteString] -> Context MD4 # hashFinalize :: Context MD4 -> Digest MD4 # digestFromByteString :: ByteString -> Maybe (Digest MD4) #
HashAlgorithm MD2 # |
Instance details Defined in Crypto.Hash Methods hashBlockSize :: Context MD2 -> Int # hashInit :: Context MD2 # hashUpdates :: Context MD2 -> [ByteString] -> Context MD2 # hashFinalize :: Context MD2 -> Digest MD2 # digestFromByteString :: ByteString -> Maybe (Digest MD2) #

newtype Context a #

Represent a context for a given hash algorithm.

Constructors

Context ByteString |

Instances

Byteable (Context a) # |
Instance details Defined in Crypto.Hash.Types Methods toBytes :: Context a -> ByteString # byteableLength :: Context a -> Int # withBytePtr :: Context a -> (Ptr Word8 -> IO b) -> IO b #

newtype Digest a #

Represent a digest for a given hash algorithm.

Constructors

Digest ByteString |

Instances

Eq (Digest a) # |
Instance details Defined in Crypto.Hash.Types Methods (==) :: Digest a -> Digest a -> Bool # (/=) :: Digest a -> Digest a -> Bool #
Ord (Digest a) # |
Instance details Defined in Crypto.Hash.Types Methods compare :: Digest a -> Digest a -> Ordering # (<) :: Digest a -> Digest a -> Bool # (<=) :: Digest a -> Digest a -> Bool # (>) :: Digest a -> Digest a -> Bool # (>=) :: Digest a -> Digest a -> Bool # max :: Digest a -> Digest a -> Digest a # min :: Digest a -> Digest a -> Digest a #
Show (Digest a) # |
Instance details Defined in Crypto.Hash.Types Methods showsPrec :: Int -> Digest a -> ShowS # show :: Digest a -> String # showList :: [Digest a] -> ShowS #
Byteable (Digest a) # |
Instance details Defined in Crypto.Hash.Types Methods toBytes :: Digest a -> ByteString # byteableLength :: Digest a -> Int # withBytePtr :: Digest a -> (Ptr Word8 -> IO b) -> IO b #

# deprecated

contextToByteString :: Context a -> ByteString #

return the binary bytestring. deprecated use toBytes.

digestToByteString :: Digest a -> ByteString #

Deprecated: use toBytes from byteable:Data.Byteable

return the binary bytestring. deprecated use toBytes.