nettle-0.1.0: safe nettle binding

Portabilityportable
Stabilityexperimental
Maintainerstbuehler@web.de
Safe HaskellNone

Crypto.Nettle.KeyedHash

Description

Generic interface to calculate key based hashes.

Synopsis

Documentation

class KeyedHashAlgorithm k whereSource

KeyedHashAlgorithm is a class for keyed hash algorithms that take a key and a message to produce a digest. The most popular example is HMAC.

Methods

implKeyedHashDigestSize :: Tagged k IntSource

Digest size in bytes the keyed hash algorithm returns

implKeyedHashName :: Tagged k StringSource

Name

implKeyedHashInit :: ByteString -> kSource

Initialize state from a key

implKeyedHashUpdate :: k -> ByteString -> kSource

Add more message data to the state

implKeyedHashUpdateLazy :: k -> ByteString -> kSource

Add more lazy message data to the state

implKeyedHashFinalize :: k -> ByteStringSource

Produce final digest

data KeyedHash Source

KeyedHash hides the KeyedHashAlgorithm implementation.

Constructors

forall k . KeyedHashAlgorithm k => KeyedHash !k 

keyedHashDigestSize :: KeyedHashAlgorithm k => k -> IntSource

Untagged variant of implKeyedHashDigestSize; takes a (possible undefined) key typed value from a KeyedHashAlgorithm instance as parameter.

keyedHashName :: KeyedHashAlgorithm k => k -> StringSource

Untagged variant of implKeyedHashName; takes a (possible undefined) key typed value from a KeyedHashAlgorithm instance as parameter.

keyedHashInitSource

Arguments

:: KeyedHashAlgorithm k 
=> ByteString

key argument

-> Tagged k KeyedHash 

Initialize a KeyedHash context from a key

keyedHashInit' :: KeyedHashAlgorithm k => k -> ByteString -> KeyedHashSource

Untagged variant of keyedHashInit; takes a (possible undefined) key typed value from a KeyedHashAlgorithm instance as parameter.

keyedHashUpdate :: KeyedHash -> ByteString -> KeyedHashSource

Add more message data to the context

keyedHashUpdateLazy :: KeyedHash -> ByteString -> KeyedHashSource

Add more lazy message data to the context

keyedHashFinalize :: KeyedHash -> ByteStringSource

Produce final digest

keyedHash :: KeyedHashAlgorithm k => ByteString -> ByteString -> Tagged k ByteStringSource

Helper to hash key and message in one step

Example:

 untag (keyedHash (fromString "secretkey") (fromString "secret message") :: Tagged (HMAC SHA256) B.ByteString)

keyedHash' :: KeyedHashAlgorithm k => k -> ByteString -> ByteString -> ByteStringSource

Untagged variant of keyedHash; takes a (possible undefined) key typed value from a KeyedHashAlgorithm instance as parameter.

Example:

 keyedHash' (undefined :: HMAC SHA256) (fromString "secretkey") (fromString "secret message")

keyedHashLazy :: KeyedHashAlgorithm k => ByteString -> ByteString -> Tagged k ByteStringSource

Helper to hash key and lazy message in one step

Example:

 untag (keyedHashLazy (fromString "secretkey") (fromString "secret message") :: Tagged (HMAC SHA256) B.ByteString)

keyedHashLazy' :: KeyedHashAlgorithm k => k -> ByteString -> ByteString -> ByteStringSource

Untagged variant of keyedHashLazy; takes a (possible undefined) key typed value from a KeyedHashAlgorithm instance as parameter.

Example:

 keyedHashLazy' (undefined :: HMAC SHA256) (fromString "secretkey") (fromString "secret message")