Crypto.Nettle.Ciphers

nettle-0.2.0: safe nettle binding

Copyright | (c) 2013 Stefan Bühler
License | MIT-style (see the file COPYING)
Maintainer | stbuehler@web.de
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell98

Crypto.Nettle.Ciphers

Contents

- Block ciphers
  - AES
  - ARCTWO
  - BLOWFISH
  - Camellia
  - CAST-128
  - DES
  - DES3 (EDE)
  - TWOFISH
  - SERPENT
- Stream ciphers
  - Nonce ciphers
  - ARCFOUR
  - ChaCha
  - Salsa20

Description

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

Synopsis

- data AES
- data AES128
- data AES192
- data AES256
- data ARCTWO
- arctwoInitEKB :: Key ARCTWO -> Word -> ARCTWO
- arctwoInitGutmann :: Key ARCTWO -> ARCTWO
- data BLOWFISH
- data Camellia
- data Camellia128
- data Camellia192
- data Camellia256
- data CAST128
- data DES
- data DES_EDE3
- data TWOFISH
- data SERPENT
- class StreamCipher cipher => StreamNonceCipher cipher where
- streamSetNonceWord64 :: StreamNonceCipher cipher => cipher -> Word64 -> Maybe cipher
- data ARCFOUR
- data CHACHA
- data SALSA20
- data ESTREAM_SALSA20

# Block ciphers

Only block ciphers with a 128-bit `blockSize` (16 bytes) support the XTS cipher mode.

For `aeadInit` only `AEAD_GCM` and `AEAD_CCM` (with `ccmInitTLS`) is supported, and only if the the `blockSize` is 16 bytes. In all other cases `aeadInit` just returns `Nothing`.

## AES

data AES #

`AES` is the generic cipher context for the AES cipher, supporting key sizes of 128, 196 and 256 bits (16, 24 and 32 bytes). The `blockSize` is always 128 bits (16 bytes).

`aeadInit` only supports the `AEAD_GCM` mode for now.

Instances

BlockCipher AES # |
Methods blockSize :: AES -> Int # ecbEncrypt :: AES -> ByteString -> ByteString # ecbDecrypt :: AES -> ByteString -> ByteString # cbcEncrypt :: AES -> IV AES -> ByteString -> ByteString # cbcDecrypt :: AES -> IV AES -> ByteString -> ByteString # cfbEncrypt :: AES -> IV AES -> ByteString -> ByteString # cfbDecrypt :: AES -> IV AES -> ByteString -> ByteString # ctrCombine :: AES -> IV AES -> ByteString -> ByteString # xtsEncrypt :: (AES, AES) -> IV AES -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (AES, AES) -> IV AES -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> AES -> iv -> Maybe (AEAD AES) #
Cipher AES # |
Methods cipherInit :: Key AES -> AES # cipherName :: AES -> String # cipherKeySize :: AES -> KeySizeSpecifier #

data AES128 #

`AES128` provides the same interface as `AES`, but is restricted to 128-bit keys.

Instances

BlockCipher AES128 # |
Methods blockSize :: AES128 -> Int # ecbEncrypt :: AES128 -> ByteString -> ByteString # ecbDecrypt :: AES128 -> ByteString -> ByteString # cbcEncrypt :: AES128 -> IV AES128 -> ByteString -> ByteString # cbcDecrypt :: AES128 -> IV AES128 -> ByteString -> ByteString # cfbEncrypt :: AES128 -> IV AES128 -> ByteString -> ByteString # cfbDecrypt :: AES128 -> IV AES128 -> ByteString -> ByteString # ctrCombine :: AES128 -> IV AES128 -> ByteString -> ByteString # xtsEncrypt :: (AES128, AES128) -> IV AES128 -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (AES128, AES128) -> IV AES128 -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> AES128 -> iv -> Maybe (AEAD AES128) #
Cipher AES128 # |
Methods cipherInit :: Key AES128 -> AES128 # cipherName :: AES128 -> String # cipherKeySize :: AES128 -> KeySizeSpecifier #

data AES192 #

`AES192` provides the same interface as `AES`, but is restricted to 192-bit keys.

Instances

BlockCipher AES192 # |
Methods blockSize :: AES192 -> Int # ecbEncrypt :: AES192 -> ByteString -> ByteString # ecbDecrypt :: AES192 -> ByteString -> ByteString # cbcEncrypt :: AES192 -> IV AES192 -> ByteString -> ByteString # cbcDecrypt :: AES192 -> IV AES192 -> ByteString -> ByteString # cfbEncrypt :: AES192 -> IV AES192 -> ByteString -> ByteString # cfbDecrypt :: AES192 -> IV AES192 -> ByteString -> ByteString # ctrCombine :: AES192 -> IV AES192 -> ByteString -> ByteString # xtsEncrypt :: (AES192, AES192) -> IV AES192 -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (AES192, AES192) -> IV AES192 -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> AES192 -> iv -> Maybe (AEAD AES192) #
Cipher AES192 # |
Methods cipherInit :: Key AES192 -> AES192 # cipherName :: AES192 -> String # cipherKeySize :: AES192 -> KeySizeSpecifier #

data AES256 #

`AES256` provides the same interface as `AES`, but is restricted to 256-bit keys.

Instances

BlockCipher AES256 # |
Methods blockSize :: AES256 -> Int # ecbEncrypt :: AES256 -> ByteString -> ByteString # ecbDecrypt :: AES256 -> ByteString -> ByteString # cbcEncrypt :: AES256 -> IV AES256 -> ByteString -> ByteString # cbcDecrypt :: AES256 -> IV AES256 -> ByteString -> ByteString # cfbEncrypt :: AES256 -> IV AES256 -> ByteString -> ByteString # cfbDecrypt :: AES256 -> IV AES256 -> ByteString -> ByteString # ctrCombine :: AES256 -> IV AES256 -> ByteString -> ByteString # xtsEncrypt :: (AES256, AES256) -> IV AES256 -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (AES256, AES256) -> IV AES256 -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> AES256 -> iv -> Maybe (AEAD AES256) #
Cipher AES256 # |
Methods cipherInit :: Key AES256 -> AES256 # cipherName :: AES256 -> String # cipherKeySize :: AES256 -> KeySizeSpecifier #

## ARCTWO

data ARCTWO #

`ARCTWO` (also known as the trade marked name RC2) is a block cipher specified in RFC 2268.

The default `cipherInit` uses `ekb = bit-length of the key`; `arctwoInitEKB` allows to specify ekb manually. `arctwoInitGutmann` uses `ekb = 1024` (the maximum).

`ARCTWO` uses keysizes from 1 to 128 bytes, and uses a `blockSize` of 64 bits (8 bytes).

Instances

BlockCipher ARCTWO # |
Methods blockSize :: ARCTWO -> Int # ecbEncrypt :: ARCTWO -> ByteString -> ByteString # ecbDecrypt :: ARCTWO -> ByteString -> ByteString # cbcEncrypt :: ARCTWO -> IV ARCTWO -> ByteString -> ByteString # cbcDecrypt :: ARCTWO -> IV ARCTWO -> ByteString -> ByteString # cfbEncrypt :: ARCTWO -> IV ARCTWO -> ByteString -> ByteString # cfbDecrypt :: ARCTWO -> IV ARCTWO -> ByteString -> ByteString # ctrCombine :: ARCTWO -> IV ARCTWO -> ByteString -> ByteString # xtsEncrypt :: (ARCTWO, ARCTWO) -> IV ARCTWO -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (ARCTWO, ARCTWO) -> IV ARCTWO -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> ARCTWO -> iv -> Maybe (AEAD ARCTWO) #
Cipher ARCTWO # |
Methods cipherInit :: Key ARCTWO -> ARCTWO # cipherName :: ARCTWO -> String # cipherKeySize :: ARCTWO -> KeySizeSpecifier #

arctwoInitEKB :: Key ARCTWO -> Word -> ARCTWO #

Initialize cipher with an explicit `ekb` value (valid values from 1 to 1024, 0 meaning the same as 1024).

arctwoInitGutmann :: Key ARCTWO -> ARCTWO #

Initialize cipher with `ekb = 1024`.

## BLOWFISH

data BLOWFISH #

`BLOWFISH` is a block cipher designed by Bruce Schneier. It uses a `blockSize` of 64 bits (8 bytes), and a variable key size from 64 to 448 bits (8 to 56 bytes).

Instances

BlockCipher BLOWFISH # |
Methods blockSize :: BLOWFISH -> Int # ecbEncrypt :: BLOWFISH -> ByteString -> ByteString # ecbDecrypt :: BLOWFISH -> ByteString -> ByteString # cbcEncrypt :: BLOWFISH -> IV BLOWFISH -> ByteString -> ByteString # cbcDecrypt :: BLOWFISH -> IV BLOWFISH -> ByteString -> ByteString # cfbEncrypt :: BLOWFISH -> IV BLOWFISH -> ByteString -> ByteString # cfbDecrypt :: BLOWFISH -> IV BLOWFISH -> ByteString -> ByteString # ctrCombine :: BLOWFISH -> IV BLOWFISH -> ByteString -> ByteString # xtsEncrypt :: (BLOWFISH, BLOWFISH) -> IV BLOWFISH -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (BLOWFISH, BLOWFISH) -> IV BLOWFISH -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> BLOWFISH -> iv -> Maybe (AEAD BLOWFISH) #
Cipher BLOWFISH # |
Methods cipherInit :: Key BLOWFISH -> BLOWFISH # cipherName :: BLOWFISH -> String # cipherKeySize :: BLOWFISH -> KeySizeSpecifier #

## Camellia

data Camellia #

Camellia is a block cipher developed by Mitsubishi and Nippon Telegraph and Telephone Corporation, described in RFC3713, and recommended by some Japanese and European authorities as an alternative to AES. The algorithm is patented (details see http://www.lysator.liu.se/~nisse/nettle/nettle.html).

Camellia uses a the same `blockSize` and key sizes as `AES`.

`aeadInit` only supports the `AEAD_GCM` mode for now.

Instances

BlockCipher Camellia # |
Methods blockSize :: Camellia -> Int # ecbEncrypt :: Camellia -> ByteString -> ByteString # ecbDecrypt :: Camellia -> ByteString -> ByteString # cbcEncrypt :: Camellia -> IV Camellia -> ByteString -> ByteString # cbcDecrypt :: Camellia -> IV Camellia -> ByteString -> ByteString # cfbEncrypt :: Camellia -> IV Camellia -> ByteString -> ByteString # cfbDecrypt :: Camellia -> IV Camellia -> ByteString -> ByteString # ctrCombine :: Camellia -> IV Camellia -> ByteString -> ByteString # xtsEncrypt :: (Camellia, Camellia) -> IV Camellia -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (Camellia, Camellia) -> IV Camellia -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> Camellia -> iv -> Maybe (AEAD Camellia) #
Cipher Camellia # |
Methods cipherInit :: Key Camellia -> Camellia # cipherName :: Camellia -> String # cipherKeySize :: Camellia -> KeySizeSpecifier #

data Camellia128 #

`Camellia128` provides the same interface as `Camellia`, but is restricted to 128-bit keys.

Instances

BlockCipher Camellia128 # |
Methods blockSize :: Camellia128 -> Int # ecbEncrypt :: Camellia128 -> ByteString -> ByteString # ecbDecrypt :: Camellia128 -> ByteString -> ByteString # cbcEncrypt :: Camellia128 -> IV Camellia128 -> ByteString -> ByteString # cbcDecrypt :: Camellia128 -> IV Camellia128 -> ByteString -> ByteString # cfbEncrypt :: Camellia128 -> IV Camellia128 -> ByteString -> ByteString # cfbDecrypt :: Camellia128 -> IV Camellia128 -> ByteString -> ByteString # ctrCombine :: Camellia128 -> IV Camellia128 -> ByteString -> ByteString # xtsEncrypt :: (Camellia128, Camellia128) -> IV Camellia128 -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (Camellia128, Camellia128) -> IV Camellia128 -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> Camellia128 -> iv -> Maybe (AEAD Camellia128) #
Cipher Camellia128 # |
Methods cipherInit :: Key Camellia128 -> Camellia128 # cipherName :: Camellia128 -> String # cipherKeySize :: Camellia128 -> KeySizeSpecifier #

data Camellia192 #

`Camellia192` provides the same interface as `Camellia`, but is restricted to 192-bit keys.

Instances

BlockCipher Camellia192 # |
Methods blockSize :: Camellia192 -> Int # ecbEncrypt :: Camellia192 -> ByteString -> ByteString # ecbDecrypt :: Camellia192 -> ByteString -> ByteString # cbcEncrypt :: Camellia192 -> IV Camellia192 -> ByteString -> ByteString # cbcDecrypt :: Camellia192 -> IV Camellia192 -> ByteString -> ByteString # cfbEncrypt :: Camellia192 -> IV Camellia192 -> ByteString -> ByteString # cfbDecrypt :: Camellia192 -> IV Camellia192 -> ByteString -> ByteString # ctrCombine :: Camellia192 -> IV Camellia192 -> ByteString -> ByteString # xtsEncrypt :: (Camellia192, Camellia192) -> IV Camellia192 -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (Camellia192, Camellia192) -> IV Camellia192 -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> Camellia192 -> iv -> Maybe (AEAD Camellia192) #
Cipher Camellia192 # |
Methods cipherInit :: Key Camellia192 -> Camellia192 # cipherName :: Camellia192 -> String # cipherKeySize :: Camellia192 -> KeySizeSpecifier #

data Camellia256 #

`Camellia256` provides the same interface as `Camellia`, but is restricted to 256-bit keys.

Instances

BlockCipher Camellia256 # |
Methods blockSize :: Camellia256 -> Int # ecbEncrypt :: Camellia256 -> ByteString -> ByteString # ecbDecrypt :: Camellia256 -> ByteString -> ByteString # cbcEncrypt :: Camellia256 -> IV Camellia256 -> ByteString -> ByteString # cbcDecrypt :: Camellia256 -> IV Camellia256 -> ByteString -> ByteString # cfbEncrypt :: Camellia256 -> IV Camellia256 -> ByteString -> ByteString # cfbDecrypt :: Camellia256 -> IV Camellia256 -> ByteString -> ByteString # ctrCombine :: Camellia256 -> IV Camellia256 -> ByteString -> ByteString # xtsEncrypt :: (Camellia256, Camellia256) -> IV Camellia256 -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (Camellia256, Camellia256) -> IV Camellia256 -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> Camellia256 -> iv -> Maybe (AEAD Camellia256) #
Cipher Camellia256 # |
Methods cipherInit :: Key Camellia256 -> Camellia256 # cipherName :: Camellia256 -> String # cipherKeySize :: Camellia256 -> KeySizeSpecifier #

## CAST-128

data CAST128 #

`CAST128` is a block cipher specified in RFC 2144. It uses a 64 bit (8 bytes) `blockSize`, and a variable key size of 40 up to 128 bits (5 to 16 bytes).

Instances

BlockCipher CAST128 # |
Methods blockSize :: CAST128 -> Int # ecbEncrypt :: CAST128 -> ByteString -> ByteString # ecbDecrypt :: CAST128 -> ByteString -> ByteString # cbcEncrypt :: CAST128 -> IV CAST128 -> ByteString -> ByteString # cbcDecrypt :: CAST128 -> IV CAST128 -> ByteString -> ByteString # cfbEncrypt :: CAST128 -> IV CAST128 -> ByteString -> ByteString # cfbDecrypt :: CAST128 -> IV CAST128 -> ByteString -> ByteString # ctrCombine :: CAST128 -> IV CAST128 -> ByteString -> ByteString # xtsEncrypt :: (CAST128, CAST128) -> IV CAST128 -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (CAST128, CAST128) -> IV CAST128 -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> CAST128 -> iv -> Maybe (AEAD CAST128) #
Cipher CAST128 # |
Methods cipherInit :: Key CAST128 -> CAST128 # cipherName :: CAST128 -> String # cipherKeySize :: CAST128 -> KeySizeSpecifier #

## DES

data DES #

`DES` is the old Data Encryption Standard, specified by NIST. It uses a `blockSize` of 64 bits (8 bytes), and a key size of 56 bits.

The key is given as 8 bytes, as one bit per byte is used as a parity bit. The parity bit is ignored by this implementation.

Instances

BlockCipher DES # |
Methods blockSize :: DES -> Int # ecbEncrypt :: DES -> ByteString -> ByteString # ecbDecrypt :: DES -> ByteString -> ByteString # cbcEncrypt :: DES -> IV DES -> ByteString -> ByteString # cbcDecrypt :: DES -> IV DES -> ByteString -> ByteString # cfbEncrypt :: DES -> IV DES -> ByteString -> ByteString # cfbDecrypt :: DES -> IV DES -> ByteString -> ByteString # ctrCombine :: DES -> IV DES -> ByteString -> ByteString # xtsEncrypt :: (DES, DES) -> IV DES -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (DES, DES) -> IV DES -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> DES -> iv -> Maybe (AEAD DES) #
Cipher DES # |
Methods cipherInit :: Key DES -> DES # cipherName :: DES -> String # cipherKeySize :: DES -> KeySizeSpecifier #

## DES3 (EDE)

data DES_EDE3 #

`DES_EDE3` uses 3 `DES` keys `k1 || k2 || k3`. Encryption first encrypts with k1, then decrypts with k2, then encrypts with k3.

The `blockSize` is the same as for `DES`: 64 bits (8 bytes), and the keys are simply concatenated, forming a 24 byte key string (with 168 bits actually getting used).

Instances

BlockCipher DES_EDE3 # |
Methods blockSize :: DES_EDE3 -> Int # ecbEncrypt :: DES_EDE3 -> ByteString -> ByteString # ecbDecrypt :: DES_EDE3 -> ByteString -> ByteString # cbcEncrypt :: DES_EDE3 -> IV DES_EDE3 -> ByteString -> ByteString # cbcDecrypt :: DES_EDE3 -> IV DES_EDE3 -> ByteString -> ByteString # cfbEncrypt :: DES_EDE3 -> IV DES_EDE3 -> ByteString -> ByteString # cfbDecrypt :: DES_EDE3 -> IV DES_EDE3 -> ByteString -> ByteString # ctrCombine :: DES_EDE3 -> IV DES_EDE3 -> ByteString -> ByteString # xtsEncrypt :: (DES_EDE3, DES_EDE3) -> IV DES_EDE3 -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (DES_EDE3, DES_EDE3) -> IV DES_EDE3 -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> DES_EDE3 -> iv -> Maybe (AEAD DES_EDE3) #
Cipher DES_EDE3 # |
Methods cipherInit :: Key DES_EDE3 -> DES_EDE3 # cipherName :: DES_EDE3 -> String # cipherKeySize :: DES_EDE3 -> KeySizeSpecifier #

## TWOFISH

data TWOFISH #

`TWOFISH` is another AES finalist, designed by Bruce Schneier and others.

`TWOFISH` uses a the same `blockSize` and key sizes as `AES`.

`aeadInit` only supports the `AEAD_GCM` mode for now.

Instances

BlockCipher TWOFISH # |
Methods blockSize :: TWOFISH -> Int # ecbEncrypt :: TWOFISH -> ByteString -> ByteString # ecbDecrypt :: TWOFISH -> ByteString -> ByteString # cbcEncrypt :: TWOFISH -> IV TWOFISH -> ByteString -> ByteString # cbcDecrypt :: TWOFISH -> IV TWOFISH -> ByteString -> ByteString # cfbEncrypt :: TWOFISH -> IV TWOFISH -> ByteString -> ByteString # cfbDecrypt :: TWOFISH -> IV TWOFISH -> ByteString -> ByteString # ctrCombine :: TWOFISH -> IV TWOFISH -> ByteString -> ByteString # xtsEncrypt :: (TWOFISH, TWOFISH) -> IV TWOFISH -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (TWOFISH, TWOFISH) -> IV TWOFISH -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> TWOFISH -> iv -> Maybe (AEAD TWOFISH) #
Cipher TWOFISH # |
Methods cipherInit :: Key TWOFISH -> TWOFISH # cipherName :: TWOFISH -> String # cipherKeySize :: TWOFISH -> KeySizeSpecifier #

## SERPENT

data SERPENT #

`SERPENT` is one of the AES finalists, designed by Ross Anderson, Eli Biham and Lars Knudsen.

The `blockSize` is 128 bits (16 bytes), and the valid key sizes are from 128 bits to 256 bits (16 to 32 bytes), although smaller bits are just padded with zeroes.

`aeadInit` only supports the `AEAD_GCM` mode for now.

Instances

BlockCipher SERPENT # |
Methods blockSize :: SERPENT -> Int # ecbEncrypt :: SERPENT -> ByteString -> ByteString # ecbDecrypt :: SERPENT -> ByteString -> ByteString # cbcEncrypt :: SERPENT -> IV SERPENT -> ByteString -> ByteString # cbcDecrypt :: SERPENT -> IV SERPENT -> ByteString -> ByteString # cfbEncrypt :: SERPENT -> IV SERPENT -> ByteString -> ByteString # cfbDecrypt :: SERPENT -> IV SERPENT -> ByteString -> ByteString # ctrCombine :: SERPENT -> IV SERPENT -> ByteString -> ByteString # xtsEncrypt :: (SERPENT, SERPENT) -> IV SERPENT -> DataUnitOffset -> ByteString -> ByteString # xtsDecrypt :: (SERPENT, SERPENT) -> IV SERPENT -> DataUnitOffset -> ByteString -> ByteString # aeadInit :: Byteable iv => AEADMode -> SERPENT -> iv -> Maybe (AEAD SERPENT) #
Cipher SERPENT # |
Methods cipherInit :: Key SERPENT -> SERPENT # cipherName :: SERPENT -> String # cipherKeySize :: SERPENT -> KeySizeSpecifier #

# Stream ciphers

## Nonce ciphers

class StreamCipher cipher => StreamNonceCipher cipher where #

`StreamNonceCipher` are special stream ciphers that can encrypt many messages with the same key; setting a nonce restarts the cipher.

A good value for the nonce is a message/packet counter. Usually a nonce should not be reused with the same key.

Minimal complete definition

streamNonceSize, streamSetNonce

Methods

streamNonceSize :: cipher -> KeySizeSpecifier #

streamSetNonce :: cipher -> ByteString -> Maybe cipher #

Instances

StreamNonceCipher ESTREAM_SALSA20 # |
Methods streamNonceSize :: ESTREAM_SALSA20 -> KeySizeSpecifier # streamSetNonce :: ESTREAM_SALSA20 -> ByteString -> Maybe ESTREAM_SALSA20 #
StreamNonceCipher SALSA20 # |
Methods streamNonceSize :: SALSA20 -> KeySizeSpecifier # streamSetNonce :: SALSA20 -> ByteString -> Maybe SALSA20 #
StreamNonceCipher CHACHA # |
Methods streamNonceSize :: CHACHA -> KeySizeSpecifier # streamSetNonce :: CHACHA -> ByteString -> Maybe CHACHA #

streamSetNonceWord64 :: StreamNonceCipher cipher => cipher -> Word64 -> Maybe cipher #

Sets a `Word64` as 8-byte nonce (bigendian encoded)

## ARCFOUR

data ARCFOUR #

`ARCFOUR` is a stream cipher, also known under the trade marked name RC4.

Valid key sizes are from 1 to 256 bytes.

Instances

StreamCipher ARCFOUR # |
Methods streamCombine :: ARCFOUR -> ByteString -> (ByteString, ARCFOUR) #
Cipher ARCFOUR # |
Methods cipherInit :: Key ARCFOUR -> ARCFOUR # cipherName :: ARCFOUR -> String # cipherKeySize :: ARCFOUR -> KeySizeSpecifier #

## ChaCha

data CHACHA #

`CHACHA` is a variant of the `SALSA20` stream cipher, both designed by D. J. Bernstein.

Key size is 256 bits (32 bytes).

`CHACHA` works similar to `SALSA20`; it could theoretically also support 128-bit keys, but there is no need for it as they share the same performance.

ChaCha uses a blocksize of 64 bytes internally; if crpyted input isn't aligned to 64 bytes it will pad it with 0 and store the encrypted padding to xor with future input data.

Each message also requires a 8-byte (`Word64`) nonce (which is initialized to 0; you can use a message sequence number). Don't reuse a nonce with the same key.

Setting a nonce also resets the remaining padding data.

Instances

StreamCipher CHACHA # |
Methods streamCombine :: CHACHA -> ByteString -> (ByteString, CHACHA) #
Cipher CHACHA # |
Methods cipherInit :: Key CHACHA -> CHACHA # cipherName :: CHACHA -> String # cipherKeySize :: CHACHA -> KeySizeSpecifier #
StreamNonceCipher CHACHA # |
Methods streamNonceSize :: CHACHA -> KeySizeSpecifier # streamSetNonce :: CHACHA -> ByteString -> Maybe CHACHA #

## Salsa20

data SALSA20 #

`SALSA20` is a fairly recent stream cipher designed by D. J. Bernstein.

Valid key sizes are 128 and 256 bits (16 and 32 bytes).

Salsa20 uses a blocksize of 64 bytes internally; if crpyted input isn't aligned to 64 bytes it will pad it with 0 and store the encrypted padding to xor with future input data.

Each message also requires a 8-byte (`Word64`) nonce (which is initialized to 0; you can use a message sequence number). Don't reuse a nonce with the same key.

Setting a nonce also resets the remaining padding data.

Instances

StreamCipher SALSA20 # |
Methods streamCombine :: SALSA20 -> ByteString -> (ByteString, SALSA20) #
Cipher SALSA20 # |
Methods cipherInit :: Key SALSA20 -> SALSA20 # cipherName :: SALSA20 -> String # cipherKeySize :: SALSA20 -> KeySizeSpecifier #
StreamNonceCipher SALSA20 # |
Methods streamNonceSize :: SALSA20 -> KeySizeSpecifier # streamSetNonce :: SALSA20 -> ByteString -> Maybe SALSA20 #

data ESTREAM_SALSA20 #

`ESTREAM_SALSA20` is the same as `SALSA20`, but uses only 12 instead of 20 rounds in mixing.

Instances

StreamCipher ESTREAM_SALSA20 # |
Methods streamCombine :: ESTREAM_SALSA20 -> ByteString -> (ByteString, ESTREAM_SALSA20) #
Cipher ESTREAM_SALSA20 # |
Methods cipherInit :: Key ESTREAM_SALSA20 -> ESTREAM_SALSA20 # cipherName :: ESTREAM_SALSA20 -> String # cipherKeySize :: ESTREAM_SALSA20 -> KeySizeSpecifier #
StreamNonceCipher ESTREAM_SALSA20 # |
Methods streamNonceSize :: ESTREAM_SALSA20 -> KeySizeSpecifier # streamSetNonce :: ESTREAM_SALSA20 -> ByteString -> Maybe ESTREAM_SALSA20 #