crypton-0.33: Cryptography Primitives sink
LicenseBSD-style
MaintainerVincent Hanquez <vincent@snarc.org>
Stabilityexperimental
Portabilityunknown
Safe HaskellSafe-Inferred
LanguageHaskell2010

Crypto.Hash.IO

Description

Generalized impure cryptographic hash interface

Synopsis

Documentation

class HashAlgorithm a where Source #

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.

Associated Types

type HashBlockSize a :: Nat Source #

Associated type for the block size of the hash algorithm

type HashDigestSize a :: Nat Source #

Associated type for the digest size of the hash algorithm

type HashInternalContextSize a :: Nat Source #

Associated type for the internal context size of the hash algorithm

Methods

hashBlockSize :: a -> Int Source #

Get the block size of a hash algorithm

hashDigestSize :: a -> Int Source #

Get the digest size of a hash algorithm

hashInternalContextSize :: a -> Int Source #

Get the size of the context used for a hash algorithm

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

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

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

Update the context with some raw data

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

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

Instances

Instances details
HashAlgorithm Blake2b_160 Source # 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2b_224 Source # 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2b_256 Source # 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2b_384 Source # 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2b_512 Source # 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2bp_512 Source # 
Instance details

Defined in Crypto.Hash.Blake2bp

HashAlgorithm Blake2s_160 Source # 
Instance details

Defined in Crypto.Hash.Blake2s

HashAlgorithm Blake2s_224 Source # 
Instance details

Defined in Crypto.Hash.Blake2s

HashAlgorithm Blake2s_256 Source # 
Instance details

Defined in Crypto.Hash.Blake2s

HashAlgorithm Blake2sp_224 Source # 
Instance details

Defined in Crypto.Hash.Blake2sp

HashAlgorithm Blake2sp_256 Source # 
Instance details

Defined in Crypto.Hash.Blake2sp

HashAlgorithm Keccak_224 Source # 
Instance details

Defined in Crypto.Hash.Keccak

HashAlgorithm Keccak_256 Source # 
Instance details

Defined in Crypto.Hash.Keccak

HashAlgorithm Keccak_384 Source # 
Instance details

Defined in Crypto.Hash.Keccak

HashAlgorithm Keccak_512 Source # 
Instance details

Defined in Crypto.Hash.Keccak

HashAlgorithm MD2 Source # 
Instance details

Defined in Crypto.Hash.MD2

Associated Types

type HashBlockSize MD2 :: Nat Source #

type HashDigestSize MD2 :: Nat Source #

type HashInternalContextSize MD2 :: Nat Source #

Methods

hashBlockSize :: MD2 -> Int Source #

hashDigestSize :: MD2 -> Int Source #

hashInternalContextSize :: MD2 -> Int Source #

hashInternalInit :: Ptr (Context MD2) -> IO () Source #

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

hashInternalFinalize :: Ptr (Context MD2) -> Ptr (Digest MD2) -> IO () Source #

HashAlgorithm MD4 Source # 
Instance details

Defined in Crypto.Hash.MD4

Associated Types

type HashBlockSize MD4 :: Nat Source #

type HashDigestSize MD4 :: Nat Source #

type HashInternalContextSize MD4 :: Nat Source #

Methods

hashBlockSize :: MD4 -> Int Source #

hashDigestSize :: MD4 -> Int Source #

hashInternalContextSize :: MD4 -> Int Source #

hashInternalInit :: Ptr (Context MD4) -> IO () Source #

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

hashInternalFinalize :: Ptr (Context MD4) -> Ptr (Digest MD4) -> IO () Source #

HashAlgorithm MD5 Source # 
Instance details

Defined in Crypto.Hash.MD5

Associated Types

type HashBlockSize MD5 :: Nat Source #

type HashDigestSize MD5 :: Nat Source #

type HashInternalContextSize MD5 :: Nat Source #

Methods

hashBlockSize :: MD5 -> Int Source #

hashDigestSize :: MD5 -> Int Source #

hashInternalContextSize :: MD5 -> Int Source #

hashInternalInit :: Ptr (Context MD5) -> IO () Source #

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

hashInternalFinalize :: Ptr (Context MD5) -> Ptr (Digest MD5) -> IO () Source #

HashAlgorithm RIPEMD160 Source # 
Instance details

Defined in Crypto.Hash.RIPEMD160

HashAlgorithm SHA1 Source # 
Instance details

Defined in Crypto.Hash.SHA1

Associated Types

type HashBlockSize SHA1 :: Nat Source #

type HashDigestSize SHA1 :: Nat Source #

type HashInternalContextSize SHA1 :: Nat Source #

Methods

hashBlockSize :: SHA1 -> Int Source #

hashDigestSize :: SHA1 -> Int Source #

hashInternalContextSize :: SHA1 -> Int Source #

hashInternalInit :: Ptr (Context SHA1) -> IO () Source #

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

hashInternalFinalize :: Ptr (Context SHA1) -> Ptr (Digest SHA1) -> IO () Source #

HashAlgorithm SHA224 Source # 
Instance details

Defined in Crypto.Hash.SHA224

Associated Types

type HashBlockSize SHA224 :: Nat Source #

type HashDigestSize SHA224 :: Nat Source #

type HashInternalContextSize SHA224 :: Nat Source #

Methods

hashBlockSize :: SHA224 -> Int Source #

hashDigestSize :: SHA224 -> Int Source #

hashInternalContextSize :: SHA224 -> Int Source #

hashInternalInit :: Ptr (Context SHA224) -> IO () Source #

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

hashInternalFinalize :: Ptr (Context SHA224) -> Ptr (Digest SHA224) -> IO () Source #

HashAlgorithm SHA256 Source # 
Instance details

Defined in Crypto.Hash.SHA256

Associated Types

type HashBlockSize SHA256 :: Nat Source #

type HashDigestSize SHA256 :: Nat Source #

type HashInternalContextSize SHA256 :: Nat Source #

Methods

hashBlockSize :: SHA256 -> Int Source #

hashDigestSize :: SHA256 -> Int Source #

hashInternalContextSize :: SHA256 -> Int Source #

hashInternalInit :: Ptr (Context SHA256) -> IO () Source #

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

hashInternalFinalize :: Ptr (Context SHA256) -> Ptr (Digest SHA256) -> IO () Source #

HashAlgorithm SHA3_224 Source # 
Instance details

Defined in Crypto.Hash.SHA3

HashAlgorithm SHA3_256 Source # 
Instance details

Defined in Crypto.Hash.SHA3

HashAlgorithm SHA3_384 Source # 
Instance details

Defined in Crypto.Hash.SHA3

HashAlgorithm SHA3_512 Source # 
Instance details

Defined in Crypto.Hash.SHA3

HashAlgorithm SHA384 Source # 
Instance details

Defined in Crypto.Hash.SHA384

Associated Types

type HashBlockSize SHA384 :: Nat Source #

type HashDigestSize SHA384 :: Nat Source #

type HashInternalContextSize SHA384 :: Nat Source #

Methods

hashBlockSize :: SHA384 -> Int Source #

hashDigestSize :: SHA384 -> Int Source #

hashInternalContextSize :: SHA384 -> Int Source #

hashInternalInit :: Ptr (Context SHA384) -> IO () Source #

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

hashInternalFinalize :: Ptr (Context SHA384) -> Ptr (Digest SHA384) -> IO () Source #

HashAlgorithm SHA512 Source # 
Instance details

Defined in Crypto.Hash.SHA512

Associated Types

type HashBlockSize SHA512 :: Nat Source #

type HashDigestSize SHA512 :: Nat Source #

type HashInternalContextSize SHA512 :: Nat Source #

Methods

hashBlockSize :: SHA512 -> Int Source #

hashDigestSize :: SHA512 -> Int Source #

hashInternalContextSize :: SHA512 -> Int Source #

hashInternalInit :: Ptr (Context SHA512) -> IO () Source #

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

hashInternalFinalize :: Ptr (Context SHA512) -> Ptr (Digest SHA512) -> IO () Source #

HashAlgorithm SHA512t_224 Source # 
Instance details

Defined in Crypto.Hash.SHA512t

HashAlgorithm SHA512t_256 Source # 
Instance details

Defined in Crypto.Hash.SHA512t

HashAlgorithm Skein256_224 Source # 
Instance details

Defined in Crypto.Hash.Skein256

HashAlgorithm Skein256_256 Source # 
Instance details

Defined in Crypto.Hash.Skein256

HashAlgorithm Skein512_224 Source # 
Instance details

Defined in Crypto.Hash.Skein512

HashAlgorithm Skein512_256 Source # 
Instance details

Defined in Crypto.Hash.Skein512

HashAlgorithm Skein512_384 Source # 
Instance details

Defined in Crypto.Hash.Skein512

HashAlgorithm Skein512_512 Source # 
Instance details

Defined in Crypto.Hash.Skein512

HashAlgorithm Tiger Source # 
Instance details

Defined in Crypto.Hash.Tiger

Associated Types

type HashBlockSize Tiger :: Nat Source #

type HashDigestSize Tiger :: Nat Source #

type HashInternalContextSize Tiger :: Nat Source #

Methods

hashBlockSize :: Tiger -> Int Source #

hashDigestSize :: Tiger -> Int Source #

hashInternalContextSize :: Tiger -> Int Source #

hashInternalInit :: Ptr (Context Tiger) -> IO () Source #

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

hashInternalFinalize :: Ptr (Context Tiger) -> Ptr (Digest Tiger) -> IO () Source #

HashAlgorithm Whirlpool Source # 
Instance details

Defined in Crypto.Hash.Whirlpool

(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512) => HashAlgorithm (Blake2b bitlen) Source # 
Instance details

Defined in Crypto.Hash.Blake2

Associated Types

type HashBlockSize (Blake2b bitlen) :: Nat Source #

type HashDigestSize (Blake2b bitlen) :: Nat Source #

type HashInternalContextSize (Blake2b bitlen) :: Nat Source #

Methods

hashBlockSize :: Blake2b bitlen -> Int Source #

hashDigestSize :: Blake2b bitlen -> Int Source #

hashInternalContextSize :: Blake2b bitlen -> Int Source #

hashInternalInit :: Ptr (Context (Blake2b bitlen)) -> IO () Source #

hashInternalUpdate :: Ptr (Context (Blake2b bitlen)) -> Ptr Word8 -> Word32 -> IO () Source #

hashInternalFinalize :: Ptr (Context (Blake2b bitlen)) -> Ptr (Digest (Blake2b bitlen)) -> IO () Source #

(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512) => HashAlgorithm (Blake2bp bitlen) Source # 
Instance details

Defined in Crypto.Hash.Blake2

Associated Types

type HashBlockSize (Blake2bp bitlen) :: Nat Source #

type HashDigestSize (Blake2bp bitlen) :: Nat Source #

type HashInternalContextSize (Blake2bp bitlen) :: Nat Source #

Methods

hashBlockSize :: Blake2bp bitlen -> Int Source #

hashDigestSize :: Blake2bp bitlen -> Int Source #

hashInternalContextSize :: Blake2bp bitlen -> Int Source #

hashInternalInit :: Ptr (Context (Blake2bp bitlen)) -> IO () Source #

hashInternalUpdate :: Ptr (Context (Blake2bp bitlen)) -> Ptr Word8 -> Word32 -> IO () Source #

hashInternalFinalize :: Ptr (Context (Blake2bp bitlen)) -> Ptr (Digest (Blake2bp bitlen)) -> IO () Source #

(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256) => HashAlgorithm (Blake2s bitlen) Source # 
Instance details

Defined in Crypto.Hash.Blake2

Associated Types

type HashBlockSize (Blake2s bitlen) :: Nat Source #

type HashDigestSize (Blake2s bitlen) :: Nat Source #

type HashInternalContextSize (Blake2s bitlen) :: Nat Source #

Methods

hashBlockSize :: Blake2s bitlen -> Int Source #

hashDigestSize :: Blake2s bitlen -> Int Source #

hashInternalContextSize :: Blake2s bitlen -> Int Source #

hashInternalInit :: Ptr (Context (Blake2s bitlen)) -> IO () Source #

hashInternalUpdate :: Ptr (Context (Blake2s bitlen)) -> Ptr Word8 -> Word32 -> IO () Source #

hashInternalFinalize :: Ptr (Context (Blake2s bitlen)) -> Ptr (Digest (Blake2s bitlen)) -> IO () Source #

(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256) => HashAlgorithm (Blake2sp bitlen) Source # 
Instance details

Defined in Crypto.Hash.Blake2

Associated Types

type HashBlockSize (Blake2sp bitlen) :: Nat Source #

type HashDigestSize (Blake2sp bitlen) :: Nat Source #

type HashInternalContextSize (Blake2sp bitlen) :: Nat Source #

Methods

hashBlockSize :: Blake2sp bitlen -> Int Source #

hashDigestSize :: Blake2sp bitlen -> Int Source #

hashInternalContextSize :: Blake2sp bitlen -> Int Source #

hashInternalInit :: Ptr (Context (Blake2sp bitlen)) -> IO () Source #

hashInternalUpdate :: Ptr (Context (Blake2sp bitlen)) -> Ptr Word8 -> Word32 -> IO () Source #

hashInternalFinalize :: Ptr (Context (Blake2sp bitlen)) -> Ptr (Digest (Blake2sp bitlen)) -> IO () Source #

KnownNat bitlen => HashAlgorithm (SHAKE128 bitlen) Source # 
Instance details

Defined in Crypto.Hash.SHAKE

Associated Types

type HashBlockSize (SHAKE128 bitlen) :: Nat Source #

type HashDigestSize (SHAKE128 bitlen) :: Nat Source #

type HashInternalContextSize (SHAKE128 bitlen) :: Nat Source #

Methods

hashBlockSize :: SHAKE128 bitlen -> Int Source #

hashDigestSize :: SHAKE128 bitlen -> Int Source #

hashInternalContextSize :: SHAKE128 bitlen -> Int Source #

hashInternalInit :: Ptr (Context (SHAKE128 bitlen)) -> IO () Source #

hashInternalUpdate :: Ptr (Context (SHAKE128 bitlen)) -> Ptr Word8 -> Word32 -> IO () Source #

hashInternalFinalize :: Ptr (Context (SHAKE128 bitlen)) -> Ptr (Digest (SHAKE128 bitlen)) -> IO () Source #

KnownNat bitlen => HashAlgorithm (SHAKE256 bitlen) Source # 
Instance details

Defined in Crypto.Hash.SHAKE

Associated Types

type HashBlockSize (SHAKE256 bitlen) :: Nat Source #

type HashDigestSize (SHAKE256 bitlen) :: Nat Source #

type HashInternalContextSize (SHAKE256 bitlen) :: Nat Source #

Methods

hashBlockSize :: SHAKE256 bitlen -> Int Source #

hashDigestSize :: SHAKE256 bitlen -> Int Source #

hashInternalContextSize :: SHAKE256 bitlen -> Int Source #

hashInternalInit :: Ptr (Context (SHAKE256 bitlen)) -> IO () Source #

hashInternalUpdate :: Ptr (Context (SHAKE256 bitlen)) -> Ptr Word8 -> Word32 -> IO () Source #

hashInternalFinalize :: Ptr (Context (SHAKE256 bitlen)) -> Ptr (Digest (SHAKE256 bitlen)) -> IO () Source #

data MutableContext a Source #

A Mutable hash context

This type is an instance of ByteArrayAccess for debugging purpose. Internal layout is architecture dependent, may contain uninitialized data fragments, and change in future versions. The bytearray should not be used as input to cryptographic algorithms.

Instances

Instances details
ByteArrayAccess (MutableContext a) Source # 
Instance details

Defined in Crypto.Hash.IO

Methods

length :: MutableContext a -> Int

withByteArray :: MutableContext a -> (Ptr p -> IO a0) -> IO a0

copyByteArrayToPtr :: MutableContext a -> Ptr p -> IO ()

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

Create a new mutable hash context.

the algorithm used is automatically determined from the return constraint.

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

Create a new mutable hash context.

The algorithm is explicitely passed as parameter

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

Update a mutable hash context in place

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

Finalize a mutable hash context and compute a digest

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

Reset the mutable context to the initial state of the hash