License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Stability | experimental |
Portability | unknown |
Safe Haskell | Trustworthy |
Language | Haskell98 |
Crypto.Hash
Description
Crypto hash main module
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)
- type HashFunctionBS a = ByteString -> Digest a
- type HashFunctionLBS a = ByteString -> Digest a
- data Context a
- data Digest a
- digestToByteString :: Digest a -> ByteString
- digestToHexByteString :: Digest a -> ByteString
- hash :: HashAlgorithm a => ByteString -> Digest a
- hashlazy :: HashAlgorithm a => ByteString -> Digest a
- hashUpdate :: HashAlgorithm a => Context a -> ByteString -> Context a
- hashInitAlg :: HashAlgorithm alg => alg -> Context alg
- data MD2 = MD2
- data MD4 = MD4
- data MD5 = MD5
- data SHA1 = SHA1
- data SHA224 = SHA224
- data SHA256 = SHA256
- data SHA384 = SHA384
- data SHA512 = SHA512
- data RIPEMD160 = RIPEMD160
- data Tiger = Tiger
- data SHA3_224 = SHA3_224
- data SHA3_256 = SHA3_256
- data SHA3_384 = SHA3_384
- data SHA3_512 = SHA3_512
- data Skein256_224 = Skein256_224
- data Skein256_256 = Skein256_256
- data Skein512_224 = Skein512_224
- data Skein512_256 = Skein512_256
- data Skein512_384 = Skein512_384
- data Skein512_512 = Skein512_512
- data Whirlpool = Whirlpool
- newtype HMAC a = HMAC {
- hmacGetDigest :: Digest a
- hmac :: HashAlgorithm a => ByteString -> ByteString -> HMAC a
- hmacAlg :: HashAlgorithm a => a -> ByteString -> ByteString -> HMAC a
Types
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
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
type HashFunctionBS a = ByteString -> Digest a #
Alias to a single pass hash function that operate on a strict bytestring
type HashFunctionLBS a = ByteString -> Digest a #
Alias to a single pass hash function that operate on a lazy bytestring
Represent a context for a given hash algorithm.
Instances
Byteable (Context a) # | |
Defined in Crypto.Hash.Types |
Represent a digest for a given hash algorithm.
Functions
digestToByteString :: Digest a -> ByteString #
Deprecated: use toBytes from byteable:Data.Byteable
return the binary bytestring. deprecated use toBytes.
digestToHexByteString :: Digest a -> ByteString #
Return the hexadecimal (base16) bytestring of the digest
hash :: HashAlgorithm a => ByteString -> Digest a #
Hash a strict bytestring into a digest.
hashlazy :: HashAlgorithm a => ByteString -> Digest a #
Hash a lazy bytestring into a digest.
hashUpdate :: HashAlgorithm a => Context a -> ByteString -> Context a #
run hashUpdates on one single bytestring and return the updated context.
hashInitAlg :: HashAlgorithm alg => alg -> Context alg #
Initialize a new context for a specified hash algorithm
hash algorithms
MD2 cryptographic hash
Constructors
MD2 |
Instances
Show MD2 # | |
HashAlgorithm MD2 # | |
Defined in Crypto.Hash Methods hashBlockSize :: Context MD2 -> Int # hashUpdates :: Context MD2 -> [ByteString] -> Context MD2 # hashFinalize :: Context MD2 -> Digest MD2 # digestFromByteString :: ByteString -> Maybe (Digest MD2) # |
MD4 cryptographic hash
Constructors
MD4 |
Instances
Show MD4 # | |
HashAlgorithm MD4 # | |
Defined in Crypto.Hash Methods hashBlockSize :: Context MD4 -> Int # hashUpdates :: Context MD4 -> [ByteString] -> Context MD4 # hashFinalize :: Context MD4 -> Digest MD4 # digestFromByteString :: ByteString -> Maybe (Digest MD4) # |
MD5 cryptographic hash
Constructors
MD5 |
Instances
Show MD5 # | |
HashAlgorithm MD5 # | |
Defined in Crypto.Hash Methods hashBlockSize :: Context MD5 -> Int # hashUpdates :: Context MD5 -> [ByteString] -> Context MD5 # hashFinalize :: Context MD5 -> Digest MD5 # digestFromByteString :: ByteString -> Maybe (Digest MD5) # |
SHA1 cryptographic hash
Constructors
SHA1 |
Instances
Show SHA1 # | |
HashAlgorithm SHA1 # | |
Defined in Crypto.Hash Methods hashBlockSize :: Context SHA1 -> Int # hashUpdates :: Context SHA1 -> [ByteString] -> Context SHA1 # hashFinalize :: Context SHA1 -> Digest SHA1 # digestFromByteString :: ByteString -> Maybe (Digest SHA1) # |
SHA224 cryptographic hash
Constructors
SHA224 |
Instances
Show SHA224 # | |
HashAlgorithm SHA224 # | |
Defined in Crypto.Hash Methods hashBlockSize :: Context SHA224 -> Int # hashUpdates :: Context SHA224 -> [ByteString] -> Context SHA224 # hashFinalize :: Context SHA224 -> Digest SHA224 # digestFromByteString :: ByteString -> Maybe (Digest SHA224) # |
SHA256 cryptographic hash
Constructors
SHA256 |
Instances
Show SHA256 # | |
HashAlgorithm SHA256 # | |
Defined in Crypto.Hash Methods hashBlockSize :: Context SHA256 -> Int # hashUpdates :: Context SHA256 -> [ByteString] -> Context SHA256 # hashFinalize :: Context SHA256 -> Digest SHA256 # digestFromByteString :: ByteString -> Maybe (Digest SHA256) # |
SHA384 cryptographic hash
Constructors
SHA384 |
Instances
Show SHA384 # | |
HashAlgorithm SHA384 # | |
Defined in Crypto.Hash Methods hashBlockSize :: Context SHA384 -> Int # hashUpdates :: Context SHA384 -> [ByteString] -> Context SHA384 # hashFinalize :: Context SHA384 -> Digest SHA384 # digestFromByteString :: ByteString -> Maybe (Digest SHA384) # |
SHA512 cryptographic hash
Constructors
SHA512 |
Instances
Show SHA512 # | |
HashAlgorithm SHA512 # | |
Defined in Crypto.Hash Methods hashBlockSize :: Context SHA512 -> Int # hashUpdates :: Context SHA512 -> [ByteString] -> Context SHA512 # hashFinalize :: Context SHA512 -> Digest SHA512 # digestFromByteString :: ByteString -> Maybe (Digest SHA512) # |
RIPEMD160 cryptographic hash
Constructors
RIPEMD160 |
Instances
Show RIPEMD160 # | |
HashAlgorithm RIPEMD160 # | |
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) # |
Tiger cryptographic hash
Constructors
Tiger |
Instances
Show Tiger # | |
HashAlgorithm Tiger # | |
Defined in Crypto.Hash Methods hashBlockSize :: Context Tiger -> Int # hashUpdates :: Context Tiger -> [ByteString] -> Context Tiger # hashFinalize :: Context Tiger -> Digest Tiger # digestFromByteString :: ByteString -> Maybe (Digest Tiger) # |
SHA3 (224 bits version) cryptographic hash
Constructors
SHA3_224 |
Instances
Show SHA3_224 # | |
HashAlgorithm SHA3_224 # | |
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) # |
SHA3 (256 bits version) cryptographic hash
Constructors
SHA3_256 |
Instances
Show SHA3_256 # | |
HashAlgorithm SHA3_256 # | |
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) # |
SHA3 (384 bits version) cryptographic hash
Constructors
SHA3_384 |
Instances
Show SHA3_384 # | |
HashAlgorithm SHA3_384 # | |
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) # |
SHA3 (512 bits version) cryptographic hash
Constructors
SHA3_512 |
Instances
Show SHA3_512 # | |
HashAlgorithm SHA3_512 # | |
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) # |
data Skein256_224 #
Skein256 (224 bits version) cryptographic hash
Constructors
Skein256_224 |
Instances
Show Skein256_224 # | |
Defined in Crypto.Hash Methods showsPrec :: Int -> Skein256_224 -> ShowS # show :: Skein256_224 -> String # showList :: [Skein256_224] -> ShowS # | |
HashAlgorithm Skein256_224 # | |
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) # |
data Skein256_256 #
Skein256 (256 bits version) cryptographic hash
Constructors
Skein256_256 |
Instances
Show Skein256_256 # | |
Defined in Crypto.Hash Methods showsPrec :: Int -> Skein256_256 -> ShowS # show :: Skein256_256 -> String # showList :: [Skein256_256] -> ShowS # | |
HashAlgorithm Skein256_256 # | |
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) # |
data Skein512_224 #
Skein512 (224 bits version) cryptographic hash
Constructors
Skein512_224 |
Instances
Show Skein512_224 # | |
Defined in Crypto.Hash Methods showsPrec :: Int -> Skein512_224 -> ShowS # show :: Skein512_224 -> String # showList :: [Skein512_224] -> ShowS # | |
HashAlgorithm Skein512_224 # | |
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) # |
data Skein512_256 #
Skein512 (256 bits version) cryptographic hash
Constructors
Skein512_256 |
Instances
Show Skein512_256 # | |
Defined in Crypto.Hash Methods showsPrec :: Int -> Skein512_256 -> ShowS # show :: Skein512_256 -> String # showList :: [Skein512_256] -> ShowS # | |
HashAlgorithm Skein512_256 # | |
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) # |
data Skein512_384 #
Skein512 (384 bits version) cryptographic hash
Constructors
Skein512_384 |
Instances
Show Skein512_384 # | |
Defined in Crypto.Hash Methods showsPrec :: Int -> Skein512_384 -> ShowS # show :: Skein512_384 -> String # showList :: [Skein512_384] -> ShowS # | |
HashAlgorithm Skein512_384 # | |
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) # |
data Skein512_512 #
Skein512 (512 bits version) cryptographic hash
Constructors
Skein512_512 |
Instances
Show Skein512_512 # | |
Defined in Crypto.Hash Methods showsPrec :: Int -> Skein512_512 -> ShowS # show :: Skein512_512 -> String # showList :: [Skein512_512] -> ShowS # | |
HashAlgorithm Skein512_512 # | |
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) # |
Whirlpool cryptographic hash
Constructors
Whirlpool |
Instances
Show Whirlpool # | |
HashAlgorithm Whirlpool # | |
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) # |
MAC algorithms
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
|
Arguments
:: HashAlgorithm a | |
=> ByteString | Secret key |
-> ByteString | Message to MAC |
-> HMAC a |
compute a MAC using the supplied hashing function
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