cryptonite-0.30: Cryptography Primitives sink

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | stable
Portability | good
Safe Haskell | Safe-Inferred
Language | Haskell2010

Crypto.Cipher.ChaCha

Contents

- Simple interface for DRG purpose

Description

Synopsis

- initialize :: (ByteArrayAccess key, ByteArrayAccess nonce) => Int -> key -> nonce -> State
- combine :: ByteArray ba => State -> ba -> (ba, State)
- generate :: ByteArray ba => State -> Int -> (ba, State)
- data State
- initializeSimple :: ByteArrayAccess seed => seed -> StateSimple
- generateSimple :: ByteArray ba => StateSimple -> Int -> (ba, StateSimple)
- data StateSimple

# Documentation

initialize Source #

Arguments

:: (ByteArrayAccess key, ByteArrayAccess nonce) |
=> Int | number of rounds (8,12,20)
-> key | the key (128 or 256 bits)
-> nonce | the nonce (64 or 96 bits)
-> State | the initial ChaCha state

Initialize a new ChaCha context with the number of rounds, the key and the nonce associated.

combine Source #

Arguments

:: ByteArray ba |
=> State | the current ChaCha state
-> ba | the source to xor with the generator
-> (ba, State) |

Combine the chacha output and an arbitrary message with a xor, and return the combined output and the new state.

generate Source #

Arguments

:: ByteArray ba |
=> State | the current ChaCha state
-> Int | the length of data to generate
-> (ba, State) |

Generate a number of bytes from the ChaCha output directly

data State Source #

ChaCha context

#### Instances

Instances details

NFData State Source # |
Instance details Defined in Crypto.Cipher.ChaCha Methods rnf :: State -> () Source #

# Simple interface for DRG purpose

initializeSimple Source #

Arguments

:: ByteArrayAccess seed |
=> seed | a 40 bytes long seed
-> StateSimple |

Initialize simple ChaCha State

The seed need to be at least 40 bytes long

generateSimple :: ByteArray ba => StateSimple -> Int -> (ba, StateSimple) Source #

similar to `generate` but assume certains values

data StateSimple Source #

ChaCha context for DRG purpose (see Crypto.Random.ChaChaDRG)

#### Instances

Instances details

NFData StateSimple Source # |
Instance details Defined in Crypto.Cipher.ChaCha Methods rnf :: StateSimple -> () Source #