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

Portabilityunknown
Stabilityexperimental
MaintainerVincent Hanquez <vincent@snarc.org>
Safe HaskellTrustworthy

Crypto.Hash

Contents

Description

Crypto hash main module

Synopsis

Types

class HashAlgorithm a whereSource

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 -> IntSource

Block size in bytes the hash algorithm operates on

hashInit :: Context aSource

Initialize a new context for this hash algorithm

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

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

hashFinalize :: Context a -> Digest aSource

Finalize a context and return a digest.

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

Try to convert a binary digest bytestring to a digest.

type HashFunctionBS a = ByteString -> Digest aSource

Alias to a single pass hash function that operate on a strict bytestring

type HashFunctionLBS a = ByteString -> Digest aSource

Alias to a single pass hash function that operate on a lazy bytestring

data Context a Source

Represent a context for a given hash algorithm.

Instances

data Digest a Source

Represent a digest for a given hash algorithm.

Instances

Eq (Digest a) 
Ord (Digest a) 
Show (Digest a) 
Byteable (Digest a) 

Functions

digestToByteString :: Digest a -> ByteStringSource

Deprecated: use toBytes from byteable:Data.Byteable

return the binary bytestring. deprecated use toBytes.

digestToHexByteString :: Digest a -> ByteStringSource

Return the hexadecimal (base16) bytestring of the digest

hash :: HashAlgorithm a => ByteString -> Digest aSource

Hash a strict bytestring into a digest.

hashlazy :: HashAlgorithm a => ByteString -> Digest aSource

Hash a lazy bytestring into a digest.

hashUpdate :: HashAlgorithm a => Context a -> ByteString -> Context aSource

run hashUpdates on one single bytestring and return the updated context.

hashInitAlg :: HashAlgorithm alg => alg -> Context algSource

Initialize a new context for a specified hash algorithm

hash algorithms

data MD2 Source

MD2 cryptographic hash

Constructors

MD2 

data MD4 Source

MD4 cryptographic hash

Constructors

MD4 

data MD5 Source

MD5 cryptographic hash

Constructors

MD5 

data SHA1 Source

SHA1 cryptographic hash

Constructors

SHA1 

data SHA224 Source

SHA224 cryptographic hash

Constructors

SHA224 

data SHA256 Source

SHA256 cryptographic hash

Constructors

SHA256 

data SHA384 Source

SHA384 cryptographic hash

Constructors

SHA384 

data SHA512 Source

SHA512 cryptographic hash

Constructors

SHA512 

data RIPEMD160 Source

RIPEMD160 cryptographic hash

Constructors

RIPEMD160 

data Tiger Source

Tiger cryptographic hash

Constructors

Tiger 

data SHA3_224 Source

SHA3 (224 bits version) cryptographic hash

Constructors

SHA3_224 

data SHA3_256 Source

SHA3 (256 bits version) cryptographic hash

Constructors

SHA3_256 

data SHA3_384 Source

SHA3 (384 bits version) cryptographic hash

Constructors

SHA3_384 

data SHA3_512 Source

SHA3 (512 bits version) cryptographic hash

Constructors

SHA3_512 

data Skein256_224 Source

Skein256 (224 bits version) cryptographic hash

Constructors

Skein256_224 

data Skein256_256 Source

Skein256 (256 bits version) cryptographic hash

Constructors

Skein256_256 

data Skein512_224 Source

Skein512 (224 bits version) cryptographic hash

Constructors

Skein512_224 

data Skein512_256 Source

Skein512 (256 bits version) cryptographic hash

Constructors

Skein512_256 

data Skein512_384 Source

Skein512 (384 bits version) cryptographic hash

Constructors

Skein512_384 

data Skein512_512 Source

Skein512 (512 bits version) cryptographic hash

Constructors

Skein512_512 

data Whirlpool Source

Whirlpool cryptographic hash

Constructors

Whirlpool 

MAC algorithms

newtype HMAC a Source

Represent an HMAC that is a phantom type with the hash used to produce the mac.

The Eq instance is constant time.

Constructors

HMAC 

Fields

hmacGetDigest :: Digest a
 

Instances

Eq (HMAC a) 
Byteable (HMAC a) 

hmacSource

Arguments

:: HashAlgorithm a 
=> ByteString

Secret key

-> ByteString

Message to MAC

-> HMAC a 

compute a MAC using the supplied hashing function

hmacAlgSource

Arguments

:: HashAlgorithm a 
=> a

the hash algorithm the actual value is unused.

-> ByteString

Secret key

-> ByteString

Message to MAC

-> HMAC a 

compute a HMAC using a specified algorithm