cryptocipher-0.6.1: Symmetrical block and stream ciphers.

Safe HaskellNone

Crypto.Cipher

Contents

Synopsis

Cipher classes

class Cipher cipher where

Symmetric cipher class.

Methods

cipherInit :: Key cipher -> cipher

Initialize a cipher context from a key

cipherName :: cipher -> String

Cipher name

cipherKeySize :: cipher -> KeySizeSpecifier

return the size of the key required for this cipher. Some cipher accept any size for key

class Cipher cipher => BlockCipher cipher where

Symmetric block cipher class

Methods

blockSize :: cipher -> Int

Return the size of block required for this block cipher

ecbEncrypt :: cipher -> ByteString -> ByteString

Encrypt using the ECB mode.

input need to be a multiple of the blocksize

ecbDecrypt :: cipher -> ByteString -> ByteString

Decrypt using the ECB mode.

input need to be a multiple of the blocksize

cbcEncrypt :: cipher -> IV cipher -> ByteString -> ByteString

encrypt using the CBC mode.

input need to be a multiple of the blocksize

cbcDecrypt :: cipher -> IV cipher -> ByteString -> ByteString

decrypt using the CBC mode.

input need to be a multiple of the blocksize

ctrCombine :: cipher -> IV cipher -> ByteString -> ByteString

combine using the CTR mode.

CTR mode produce a stream of randomized data that is combined (by XOR operation) with the input stream.

encryption and decryption are the same operation.

input can be of any size

xtsEncrypt :: (cipher, cipher) -> IV cipher -> DataUnitOffset -> ByteString -> ByteString

encrypt using the XTS mode.

input need to be a multiple of the blocksize

xtsDecrypt :: (cipher, cipher) -> IV cipher -> DataUnitOffset -> ByteString -> ByteString

decrypt using the XTS mode.

input need to be a multiple of the blocksize

aeadInit :: Byteable iv => AEADMode -> cipher -> iv -> Maybe (AEAD cipher)

Initialize a new AEAD State

When Nothing is returns, it means the mode is not handled.

class Cipher cipher => StreamCipher cipher where

Symmetric stream cipher class

Methods

streamEncrypt :: cipher -> ByteString -> (ByteString, cipher)

Encrypt using the stream cipher

streamDecrypt :: cipher -> ByteString -> (ByteString, cipher)

Decrypt using the stream cipher

Cipher implementations

data AES128

AES with 128 bit key

data AES192

AES with 192 bit key

data AES256

AES with 256 bit key

data Blowfish

variable keyed blowfish state

data DES

DES Context

data DES_EEE3

3DES with 3 different keys used all in the same direction

data DES_EDE3

3DES with 3 different keys used in alternative direction

data DES_EEE2

3DES where the first and third keys are equal, used in the same direction

data DES_EDE2

3DES where the first and third keys are equal, used in alternative direction

data Camellia128

Camellia block cipher with 128 bit key