nettle-0.3.0: safe nettle binding
Copyright(c) 2013 Stefan Bühler
LicenseMIT-style (see the file COPYING)
Maintainerstbuehler@web.de
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Crypto.Nettle.Hash

Description

This module exports hash algorithms supported by nettle: http://www.lysator.liu.se/~nisse/nettle/

Synopsis

HashAlgorithm class

class HashAlgorithm a where Source #

HashAlgorithm is a class that hash algorithms will implement. generating a digest is a 3 step procedure:

The final digest has hashDigestSize bytes, and the algorithm uses hashBlockSize as internal block size.

Methods

hashBlockSize :: Tagged a Int Source #

Block size in bytes the hash algorithm operates on

hashDigestSize :: Tagged a Int Source #

Digest size in bytes the hash algorithm returns

hashName :: Tagged a String Source #

Name of the hash algorithm

hashInit :: a Source #

Initialize a new context for this hash algorithm

hashUpdate :: a -> ByteString -> a Source #

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

hashUpdateLazy :: a -> ByteString -> a Source #

Update the context with a lazy bytestring, and return a new context with the updates.

hashFinalize :: a -> ByteString Source #

Finalize a context and return a digest.

hashHMAC :: ByteString -> Tagged a KeyedHash Source #

Use HashAlgorithm for HMAC; can use a optimized variant or the default hmacInit one

Instances

Instances details
HashAlgorithm SHA3_512 Source # 
Instance details

Defined in Crypto.Nettle.Hash

HashAlgorithm SHA3_384 Source # 
Instance details

Defined in Crypto.Nettle.Hash

HashAlgorithm SHA3_256 Source # 
Instance details

Defined in Crypto.Nettle.Hash

HashAlgorithm SHA3_224 Source # 
Instance details

Defined in Crypto.Nettle.Hash

HashAlgorithm SHA512 Source # 
Instance details

Defined in Crypto.Nettle.Hash

HashAlgorithm SHA384 Source # 
Instance details

Defined in Crypto.Nettle.Hash

HashAlgorithm SHA256 Source # 
Instance details

Defined in Crypto.Nettle.Hash

HashAlgorithm SHA224 Source # 
Instance details

Defined in Crypto.Nettle.Hash

HashAlgorithm SHA1 Source # 
Instance details

Defined in Crypto.Nettle.Hash

HashAlgorithm RIPEMD160 Source # 
Instance details

Defined in Crypto.Nettle.Hash

HashAlgorithm MD5 Source # 
Instance details

Defined in Crypto.Nettle.Hash

Methods

hashBlockSize :: Tagged MD5 Int Source #

hashDigestSize :: Tagged MD5 Int Source #

hashName :: Tagged MD5 String Source #

hashInit :: MD5 Source #

hashUpdate :: MD5 -> ByteString -> MD5 Source #

hashUpdateLazy :: MD5 -> ByteString -> MD5 Source #

hashFinalize :: MD5 -> ByteString Source #

hashHMAC :: ByteString -> Tagged MD5 KeyedHash Source #

HashAlgorithm MD4 Source # 
Instance details

Defined in Crypto.Nettle.Hash

Methods

hashBlockSize :: Tagged MD4 Int Source #

hashDigestSize :: Tagged MD4 Int Source #

hashName :: Tagged MD4 String Source #

hashInit :: MD4 Source #

hashUpdate :: MD4 -> ByteString -> MD4 Source #

hashUpdateLazy :: MD4 -> ByteString -> MD4 Source #

hashFinalize :: MD4 -> ByteString Source #

hashHMAC :: ByteString -> Tagged MD4 KeyedHash Source #

HashAlgorithm MD2 Source # 
Instance details

Defined in Crypto.Nettle.Hash

Methods

hashBlockSize :: Tagged MD2 Int Source #

hashDigestSize :: Tagged MD2 Int Source #

hashName :: Tagged MD2 String Source #

hashInit :: MD2 Source #

hashUpdate :: MD2 -> ByteString -> MD2 Source #

hashUpdateLazy :: MD2 -> ByteString -> MD2 Source #

hashFinalize :: MD2 -> ByteString Source #

hashHMAC :: ByteString -> Tagged MD2 KeyedHash Source #

HashAlgorithm GOSTHASH94 Source # 
Instance details

Defined in Crypto.Nettle.Hash

hash :: HashAlgorithm a => ByteString -> Tagged a ByteString Source #

Helper to hash a single (strict) ByteString in one step.

Example:

untag (hash (fromString "abc") :: Tagged SHA256 B.ByteString)

hash' :: HashAlgorithm a => a -> ByteString -> ByteString Source #

Untagged variant of hash; takes a (possible undefined) typed HashAlgorithm context as parameter.

Example:

hash' (undefined :: SHA256) $ fromString "abc"

hashLazy :: HashAlgorithm a => ByteString -> Tagged a ByteString Source #

Helper to hash a single (lazy) ByteString in one step.

Example:

untag (hashLazy (fromString "abc") :: Tagged SHA256 L.ByteString)

hashLazy' :: HashAlgorithm a => a -> ByteString -> ByteString Source #

Untagged variant of hashLazy; takes a (possible undefined) typed HashAlgorithm context as parameter.

Example:

hashLazy' (undefined :: SHA256) $ fromString "abc"

hash algorithms

Only members of the SHA2 and SHA3 family have no known weaknesses (according to http://www.lysator.liu.se/~nisse/nettle/nettle.html#Hash-functions)

GOSTHASH94

data GOSTHASH94 Source #

The GOST94 or GOST R 34.11-94 hash algorithm is a Soviet-era algorithm used in Russian government standards (see RFC 4357). It outputs message digests of 32 bytes (256 bits).

MD family

data MD2 Source #

MD2 is a hash function of Ronald Rivest's, described in RFC 1319. It outputs message digests of 16 bytes (128 bits).

Instances

Instances details
HashAlgorithm MD2 Source # 
Instance details

Defined in Crypto.Nettle.Hash

Methods

hashBlockSize :: Tagged MD2 Int Source #

hashDigestSize :: Tagged MD2 Int Source #

hashName :: Tagged MD2 String Source #

hashInit :: MD2 Source #

hashUpdate :: MD2 -> ByteString -> MD2 Source #

hashUpdateLazy :: MD2 -> ByteString -> MD2 Source #

hashFinalize :: MD2 -> ByteString Source #

hashHMAC :: ByteString -> Tagged MD2 KeyedHash Source #

data MD4 Source #

MD4 is a hash function of Ronald Rivest's, described in RFC 1320. It outputs message digests of 16 bytes (128 bits).

Instances

Instances details
HashAlgorithm MD4 Source # 
Instance details

Defined in Crypto.Nettle.Hash

Methods

hashBlockSize :: Tagged MD4 Int Source #

hashDigestSize :: Tagged MD4 Int Source #

hashName :: Tagged MD4 String Source #

hashInit :: MD4 Source #

hashUpdate :: MD4 -> ByteString -> MD4 Source #

hashUpdateLazy :: MD4 -> ByteString -> MD4 Source #

hashFinalize :: MD4 -> ByteString Source #

hashHMAC :: ByteString -> Tagged MD4 KeyedHash Source #

data MD5 Source #

MD5 is a hash function of Ronald Rivest's, described in RFC 1321. It outputs message digests of 16 bytes (128 bits).

Instances

Instances details
HashAlgorithm MD5 Source # 
Instance details

Defined in Crypto.Nettle.Hash

Methods

hashBlockSize :: Tagged MD5 Int Source #

hashDigestSize :: Tagged MD5 Int Source #

hashName :: Tagged MD5 String Source #

hashInit :: MD5 Source #

hashUpdate :: MD5 -> ByteString -> MD5 Source #

hashUpdateLazy :: MD5 -> ByteString -> MD5 Source #

hashFinalize :: MD5 -> ByteString Source #

hashHMAC :: ByteString -> Tagged MD5 KeyedHash Source #

RIPEMD160

data RIPEMD160 Source #

RIPEMD160 is a hash function designed by Hans Dobbertin, Antoon Bosselaers, and Bart Preneel, as a strengthened version of RIPEMD. It produces message digests of 20 bytes (160 bits).

SHA1

data SHA1 Source #

SHA1 is a hash function specified by NIST (The U.S. National Institute for Standards and Technology). It produces message digests of 20 bytes (160 bits).

Instances

Instances details
HashAlgorithm SHA1 Source # 
Instance details

Defined in Crypto.Nettle.Hash

SHA2 family

The SHA2 family supports digests lengths of 28, 32, 48 or 64 bytes (224, 256, 384, 512 bits), and the variants are named after the bit length.

The SHA2 family of hash functions were specified by NIST, intended as a replacement for SHA1.

data SHA224 Source #

SHA224 is a member of the SHA2 family which outputs messages digests of 28 bytes (224 bits).

Instances

Instances details
HashAlgorithm SHA224 Source # 
Instance details

Defined in Crypto.Nettle.Hash

data SHA256 Source #

SHA256 is a member of the SHA2 family which outputs messages digests of 32 bytes (256 bits).

Instances

Instances details
HashAlgorithm SHA256 Source # 
Instance details

Defined in Crypto.Nettle.Hash

data SHA384 Source #

SHA384 is a member of the SHA2 family which outputs messages digests of 48 bytes (384 bits).

Instances

Instances details
HashAlgorithm SHA384 Source # 
Instance details

Defined in Crypto.Nettle.Hash

data SHA512 Source #

SHA512 is a member of the SHA2 family which outputs messages digests of 64 bytes (512 bits).

Instances

Instances details
HashAlgorithm SHA512 Source # 
Instance details

Defined in Crypto.Nettle.Hash

SHA3 family

The SHA3 family supports (like SHA2) digests lengths of 28, 32, 48 or 64 bytes (224, 256, 384, 512 bits), and the variants are named after the bit length.

The SHA3 hash functions were specified by NIST in response to weaknesses in SHA1, and doubts about SHA2 hash functions which structurally are very similar to SHA1. The standard is a result of a competition, where the winner, also known as Keccak, was designed by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche. It is structurally very different from all widely used earlier hash functions.

data SHA3_224 Source #

SHA3_224 is a member of the SHA3 family which outputs messages digests of 28 bytes (224 bits).

data SHA3_256 Source #

SHA3_256 is a member of the SHA3 family which outputs messages digests of 32 bytes (256 bits).

data SHA3_384 Source #

SHA3_384 is a member of the SHA3 family which outputs messages digests of 48 bytes (384 bits).

data SHA3_512 Source #

SHA3_512 is a member of the SHA3 family which outputs messages digests of 64 bytes (512 bits).