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 HaskellSafe
LanguageHaskell98

Crypto.Nettle.KeyedHash

Description

Generic interface to calculate key based hashes.

Synopsis

Documentation

class KeyedHashAlgorithm k where Source #

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 Int Source #

Digest size in bytes the keyed hash algorithm returns

implKeyedHashName :: Tagged k String Source #

Name

implKeyedHashInit :: ByteString -> k Source #

Initialize state from a key

implKeyedHashUpdate :: k -> ByteString -> k Source #

Add more message data to the state

implKeyedHashUpdateLazy :: k -> ByteString -> k Source #

Add more lazy message data to the state

implKeyedHashFinalize :: k -> ByteString Source #

Produce final digest

Instances

KeyedHashAlgorithm UMAC128 Source # 
KeyedHashAlgorithm UMAC96 Source # 
KeyedHashAlgorithm UMAC64 Source # 
KeyedHashAlgorithm UMAC32 Source # 
HashAlgorithm a => KeyedHashAlgorithm (HMAC a) Source # 

data KeyedHash Source #

KeyedHash hides the KeyedHashAlgorithm implementation.

Constructors

KeyedHashAlgorithm k => KeyedHash !k 

keyedHashDigestSize :: KeyedHashAlgorithm k => k -> Int Source #

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

keyedHashName :: KeyedHashAlgorithm k => k -> String Source #

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

keyedHashInit Source #

Arguments

:: KeyedHashAlgorithm k 
=> ByteString

key argument

-> Tagged k KeyedHash 

Initialize a KeyedHash context from a key

keyedHashInit' :: KeyedHashAlgorithm k => k -> ByteString -> KeyedHash Source #

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

keyedHashUpdate :: KeyedHash -> ByteString -> KeyedHash Source #

Add more message data to the context

keyedHashUpdateLazy :: KeyedHash -> ByteString -> KeyedHash Source #

Add more lazy message data to the context

keyedHashFinalize :: KeyedHash -> ByteString Source #

Produce final digest

keyedHash :: KeyedHashAlgorithm k => ByteString -> ByteString -> Tagged k ByteString Source #

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 -> ByteString Source #

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 ByteString Source #

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 -> ByteString Source #

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")