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.UMAC

Description

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

Synopsis

Documentation

class UMAC u where Source #

UMAC is a class of keyed hash algorithms that take an additional nonce.

Keys for UMAC are always 16 bytes; there are different digest sizes: 4, 8, 12 and 16 bytes (32, 64, 96 and 128 bits), and the variants are named after the digest length in bits.

On initialization the nonce is set to 0; each finalize returns a new state with an incremented nonce. The nonce is interpreted as 16-byte (128-bit) big-endian integer (and for string shorter than 16 bytes padded with zeroes on the left; setting empty nonces is not allowed).

Methods

umacDigestSize :: Tagged u Int Source #

digest size in bytes

umacName :: Tagged u String Source #

umac name (UMAC ++ digest size in bits)

umacInit Source #

Arguments

:: ByteString

key argument

-> u 

initialize a new context from a key with a zero nonce

umacSetNonce Source #

Arguments

:: u 
-> ByteString

nonce argument

-> u 

set a nonce; can be called anytime before producing the digest

umacUpdate Source #

Arguments

:: u 
-> ByteString

message argument

-> u 

append message data to be hashed

umacUpdateLazy Source #

Arguments

:: u 
-> ByteString

message argument

-> u 

append lazy message data to be hashed

umacFinalize :: u -> (ByteString, u) Source #

produce a digest, and return a new state with incremented nonce

Instances

Instances details
UMAC UMAC128 Source # 
Instance details

Defined in Crypto.Nettle.UMAC

Methods

umacDigestSize :: Tagged UMAC128 Int Source #

umacName :: Tagged UMAC128 String Source #

umacInit :: ByteString -> UMAC128 Source #

umacSetNonce :: UMAC128 -> ByteString -> UMAC128 Source #

umacUpdate :: UMAC128 -> ByteString -> UMAC128 Source #

umacUpdateLazy :: UMAC128 -> ByteString -> UMAC128 Source #

umacFinalize :: UMAC128 -> (ByteString, UMAC128) Source #

UMAC UMAC96 Source # 
Instance details

Defined in Crypto.Nettle.UMAC

Methods

umacDigestSize :: Tagged UMAC96 Int Source #

umacName :: Tagged UMAC96 String Source #

umacInit :: ByteString -> UMAC96 Source #

umacSetNonce :: UMAC96 -> ByteString -> UMAC96 Source #

umacUpdate :: UMAC96 -> ByteString -> UMAC96 Source #

umacUpdateLazy :: UMAC96 -> ByteString -> UMAC96 Source #

umacFinalize :: UMAC96 -> (ByteString, UMAC96) Source #

UMAC UMAC64 Source # 
Instance details

Defined in Crypto.Nettle.UMAC

Methods

umacDigestSize :: Tagged UMAC64 Int Source #

umacName :: Tagged UMAC64 String Source #

umacInit :: ByteString -> UMAC64 Source #

umacSetNonce :: UMAC64 -> ByteString -> UMAC64 Source #

umacUpdate :: UMAC64 -> ByteString -> UMAC64 Source #

umacUpdateLazy :: UMAC64 -> ByteString -> UMAC64 Source #

umacFinalize :: UMAC64 -> (ByteString, UMAC64) Source #

UMAC UMAC32 Source # 
Instance details

Defined in Crypto.Nettle.UMAC

Methods

umacDigestSize :: Tagged UMAC32 Int Source #

umacName :: Tagged UMAC32 String Source #

umacInit :: ByteString -> UMAC32 Source #

umacSetNonce :: UMAC32 -> ByteString -> UMAC32 Source #

umacUpdate :: UMAC32 -> ByteString -> UMAC32 Source #

umacUpdateLazy :: UMAC32 -> ByteString -> UMAC32 Source #

umacFinalize :: UMAC32 -> (ByteString, UMAC32) Source #

data UMAC32 Source #

UMAC32 is the 32-bit (4 byte) digest variant. See umacInitKeyedHash for the KeyedHashAlgorithm instance.

Instances

Instances details
KeyedHashAlgorithm UMAC32 Source # 
Instance details

Defined in Crypto.Nettle.UMAC

UMAC UMAC32 Source # 
Instance details

Defined in Crypto.Nettle.UMAC

Methods

umacDigestSize :: Tagged UMAC32 Int Source #

umacName :: Tagged UMAC32 String Source #

umacInit :: ByteString -> UMAC32 Source #

umacSetNonce :: UMAC32 -> ByteString -> UMAC32 Source #

umacUpdate :: UMAC32 -> ByteString -> UMAC32 Source #

umacUpdateLazy :: UMAC32 -> ByteString -> UMAC32 Source #

umacFinalize :: UMAC32 -> (ByteString, UMAC32) Source #

data UMAC64 Source #

UMAC64 is the 64-bit (8 byte) digest variant. See umacInitKeyedHash for the KeyedHashAlgorithm instance.

Instances

Instances details
KeyedHashAlgorithm UMAC64 Source # 
Instance details

Defined in Crypto.Nettle.UMAC

UMAC UMAC64 Source # 
Instance details

Defined in Crypto.Nettle.UMAC

Methods

umacDigestSize :: Tagged UMAC64 Int Source #

umacName :: Tagged UMAC64 String Source #

umacInit :: ByteString -> UMAC64 Source #

umacSetNonce :: UMAC64 -> ByteString -> UMAC64 Source #

umacUpdate :: UMAC64 -> ByteString -> UMAC64 Source #

umacUpdateLazy :: UMAC64 -> ByteString -> UMAC64 Source #

umacFinalize :: UMAC64 -> (ByteString, UMAC64) Source #

data UMAC96 Source #

UMAC96 is the 96-bit (12 byte) digest variant. See umacInitKeyedHash for the KeyedHashAlgorithm instance.

Instances

Instances details
KeyedHashAlgorithm UMAC96 Source # 
Instance details

Defined in Crypto.Nettle.UMAC

UMAC UMAC96 Source # 
Instance details

Defined in Crypto.Nettle.UMAC

Methods

umacDigestSize :: Tagged UMAC96 Int Source #

umacName :: Tagged UMAC96 String Source #

umacInit :: ByteString -> UMAC96 Source #

umacSetNonce :: UMAC96 -> ByteString -> UMAC96 Source #

umacUpdate :: UMAC96 -> ByteString -> UMAC96 Source #

umacUpdateLazy :: UMAC96 -> ByteString -> UMAC96 Source #

umacFinalize :: UMAC96 -> (ByteString, UMAC96) Source #

data UMAC128 Source #

UMAC128 is the 128-bit (16 byte) digest variant. See umacInitKeyedHash for the KeyedHashAlgorithm instance.

Instances

Instances details
KeyedHashAlgorithm UMAC128 Source # 
Instance details

Defined in Crypto.Nettle.UMAC

UMAC UMAC128 Source # 
Instance details

Defined in Crypto.Nettle.UMAC

Methods

umacDigestSize :: Tagged UMAC128 Int Source #

umacName :: Tagged UMAC128 String Source #

umacInit :: ByteString -> UMAC128 Source #

umacSetNonce :: UMAC128 -> ByteString -> UMAC128 Source #

umacUpdate :: UMAC128 -> ByteString -> UMAC128 Source #

umacUpdateLazy :: UMAC128 -> ByteString -> UMAC128 Source #

umacFinalize :: UMAC128 -> (ByteString, UMAC128) Source #

umacInitKeyedHash Source #

Arguments

:: (UMAC u, KeyedHashAlgorithm u) 
=> ByteString

key argument

-> ByteString

nonce argument

-> Tagged u KeyedHash 

The default KeyedHash generated for UMAC KeyedHashAlgorithm instances use a zero nonce; to set a different nonce you need to use this initialization function (or use the UMAC interface).

Once the UMAC lives as KeyedHash the nonce cannot be changed anymore, as KeyedHash hides all internal state.