crypton-0.33: Cryptography Primitives sink

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

Crypto.Cipher.Types

Contents

- Cipher classes
- AEAD functions
- Initial Vector type and constructor
- Authentification Tag

Description

Symmetric cipher basic types

Synopsis

- class Cipher cipher where
  - cipherInit :: ByteArray key => key -> CryptoFailable cipher
  - cipherName :: cipher -> String
  - cipherKeySize :: cipher -> KeySizeSpecifier
- class Cipher cipher => BlockCipher cipher where
  - blockSize :: cipher -> Int
  - ecbEncrypt :: ByteArray ba => cipher -> ba -> ba
  - ecbDecrypt :: ByteArray ba => cipher -> ba -> ba
  - cbcEncrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba
  - cbcDecrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba
  - cfbEncrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba
  - cfbDecrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba
  - ctrCombine :: ByteArray ba => cipher -> IV cipher -> ba -> ba
  - aeadInit :: ByteArrayAccess iv => AEADMode -> cipher -> iv -> CryptoFailable (AEAD cipher)
- class BlockCipher cipher => BlockCipher128 cipher where
  - xtsEncrypt :: ByteArray ba => (cipher, cipher) -> IV cipher -> DataUnitOffset -> ba -> ba
  - xtsDecrypt :: ByteArray ba => (cipher, cipher) -> IV cipher -> DataUnitOffset -> ba -> ba
- class Cipher cipher => StreamCipher cipher where
  - streamCombine :: ByteArray ba => cipher -> ba -> (ba, cipher)
- type DataUnitOffset = Word32
- data KeySizeSpecifier
  - = KeySizeRange Int Int
  - | KeySizeEnum [Int]
  - | KeySizeFixed Int
- data AEADMode
  - = AEAD_OCB
  - | AEAD_CCM Int CCM_M CCM_L
  - | AEAD_EAX
  - | AEAD_CWC
  - | AEAD_GCM
- data CCM_M
  - = CCM_M4
  - | CCM_M6
  - | CCM_M8
  - | CCM_M10
  - | CCM_M12
  - | CCM_M14
  - | CCM_M16
- data CCM_L
  - = CCM_L2
  - | CCM_L3
  - | CCM_L4
- data AEADModeImpl st = AEADModeImpl {
  - aeadImplAppendHeader :: forall ba. ByteArrayAccess ba => st -> ba -> st
  - aeadImplEncrypt :: forall ba. ByteArray ba => st -> ba -> (ba, st)
  - aeadImplDecrypt :: forall ba. ByteArray ba => st -> ba -> (ba, st)
  - aeadImplFinalize :: st -> Int -> AuthTag
  }
- data AEAD cipher = forall st.AEAD {
  - aeadModeImpl :: AEADModeImpl st
  - aeadState :: !st
  }
- aeadAppendHeader :: ByteArrayAccess aad => AEAD cipher -> aad -> AEAD cipher
- aeadEncrypt :: ByteArray ba => AEAD cipher -> ba -> (ba, AEAD cipher)
- aeadDecrypt :: ByteArray ba => AEAD cipher -> ba -> (ba, AEAD cipher)
- aeadFinalize :: AEAD cipher -> Int -> AuthTag
- aeadSimpleEncrypt :: (ByteArrayAccess aad, ByteArray ba) => AEAD a -> aad -> ba -> Int -> (AuthTag, ba)
- aeadSimpleDecrypt :: (ByteArrayAccess aad, ByteArray ba) => AEAD a -> aad -> ba -> AuthTag -> Maybe ba
- data IV c
- makeIV :: (ByteArrayAccess b, BlockCipher c) => b -> Maybe (IV c)
- nullIV :: BlockCipher c => IV c
- ivAdd :: IV c -> Int -> IV c
- newtype AuthTag = AuthTag {
  - unAuthTag :: Bytes
  }

# Cipher classes

class Cipher cipher where Source #

Symmetric cipher class.

Methods

cipherInit :: ByteArray key => key -> CryptoFailable cipher Source #

Initialize a cipher context from a key

cipherName :: cipher -> String Source #

Cipher name

cipherKeySize :: cipher -> KeySizeSpecifier Source #

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

#### Instances

Instances details

Cipher AES128 Source # |
Instance details Defined in Crypto.Cipher.AES Methods cipherInit :: ByteArray key => key -> CryptoFailable AES128 Source # cipherName :: AES128 -> String Source # cipherKeySize :: AES128 -> KeySizeSpecifier Source #
Cipher AES192 Source # |
Instance details Defined in Crypto.Cipher.AES Methods cipherInit :: ByteArray key => key -> CryptoFailable AES192 Source # cipherName :: AES192 -> String Source # cipherKeySize :: AES192 -> KeySizeSpecifier Source #
Cipher AES256 Source # |
Instance details Defined in Crypto.Cipher.AES Methods cipherInit :: ByteArray key => key -> CryptoFailable AES256 Source # cipherName :: AES256 -> String Source # cipherKeySize :: AES256 -> KeySizeSpecifier Source #
Cipher Blowfish Source # |
Instance details Defined in Crypto.Cipher.Blowfish Methods cipherInit :: ByteArray key => key -> CryptoFailable Blowfish Source # cipherName :: Blowfish -> String Source # cipherKeySize :: Blowfish -> KeySizeSpecifier Source #
Cipher Blowfish128 Source # |
Instance details Defined in Crypto.Cipher.Blowfish Methods cipherInit :: ByteArray key => key -> CryptoFailable Blowfish128 Source # cipherName :: Blowfish128 -> String Source # cipherKeySize :: Blowfish128 -> KeySizeSpecifier Source #
Cipher Blowfish256 Source # |
Instance details Defined in Crypto.Cipher.Blowfish Methods cipherInit :: ByteArray key => key -> CryptoFailable Blowfish256 Source # cipherName :: Blowfish256 -> String Source # cipherKeySize :: Blowfish256 -> KeySizeSpecifier Source #
Cipher Blowfish448 Source # |
Instance details Defined in Crypto.Cipher.Blowfish Methods cipherInit :: ByteArray key => key -> CryptoFailable Blowfish448 Source # cipherName :: Blowfish448 -> String Source # cipherKeySize :: Blowfish448 -> KeySizeSpecifier Source #
Cipher Blowfish64 Source # |
Instance details Defined in Crypto.Cipher.Blowfish Methods cipherInit :: ByteArray key => key -> CryptoFailable Blowfish64 Source # cipherName :: Blowfish64 -> String Source # cipherKeySize :: Blowfish64 -> KeySizeSpecifier Source #
Cipher CAST5 Source # |
Instance details Defined in Crypto.Cipher.CAST5 Methods cipherInit :: ByteArray key => key -> CryptoFailable CAST5 Source # cipherName :: CAST5 -> String Source # cipherKeySize :: CAST5 -> KeySizeSpecifier Source #
Cipher Camellia128 Source # |
Instance details Defined in Crypto.Cipher.Camellia Methods cipherInit :: ByteArray key => key -> CryptoFailable Camellia128 Source # cipherName :: Camellia128 -> String Source # cipherKeySize :: Camellia128 -> KeySizeSpecifier Source #
Cipher DES Source # |
Instance details Defined in Crypto.Cipher.DES Methods cipherInit :: ByteArray key => key -> CryptoFailable DES Source # cipherName :: DES -> String Source # cipherKeySize :: DES -> KeySizeSpecifier Source #
Cipher DES_EDE2 Source # |
Instance details Defined in Crypto.Cipher.TripleDES Methods cipherInit :: ByteArray key => key -> CryptoFailable DES_EDE2 Source # cipherName :: DES_EDE2 -> String Source # cipherKeySize :: DES_EDE2 -> KeySizeSpecifier Source #
Cipher DES_EDE3 Source # |
Instance details Defined in Crypto.Cipher.TripleDES Methods cipherInit :: ByteArray key => key -> CryptoFailable DES_EDE3 Source # cipherName :: DES_EDE3 -> String Source # cipherKeySize :: DES_EDE3 -> KeySizeSpecifier Source #
Cipher DES_EEE2 Source # |
Instance details Defined in Crypto.Cipher.TripleDES Methods cipherInit :: ByteArray key => key -> CryptoFailable DES_EEE2 Source # cipherName :: DES_EEE2 -> String Source # cipherKeySize :: DES_EEE2 -> KeySizeSpecifier Source #
Cipher DES_EEE3 Source # |
Instance details Defined in Crypto.Cipher.TripleDES Methods cipherInit :: ByteArray key => key -> CryptoFailable DES_EEE3 Source # cipherName :: DES_EEE3 -> String Source # cipherKeySize :: DES_EEE3 -> KeySizeSpecifier Source #
Cipher Twofish128 Source # |
Instance details Defined in Crypto.Cipher.Twofish Methods cipherInit :: ByteArray key => key -> CryptoFailable Twofish128 Source # cipherName :: Twofish128 -> String Source # cipherKeySize :: Twofish128 -> KeySizeSpecifier Source #
Cipher Twofish192 Source # |
Instance details Defined in Crypto.Cipher.Twofish Methods cipherInit :: ByteArray key => key -> CryptoFailable Twofish192 Source # cipherName :: Twofish192 -> String Source # cipherKeySize :: Twofish192 -> KeySizeSpecifier Source #
Cipher Twofish256 Source # |
Instance details Defined in Crypto.Cipher.Twofish Methods cipherInit :: ByteArray key => key -> CryptoFailable Twofish256 Source # cipherName :: Twofish256 -> String Source # cipherKeySize :: Twofish256 -> KeySizeSpecifier Source #

class Cipher cipher => BlockCipher cipher where Source #

Symmetric block cipher class

Minimal complete definition

blockSize, ecbEncrypt, ecbDecrypt

Methods

blockSize :: cipher -> Int Source #

Return the size of block required for this block cipher

ecbEncrypt :: ByteArray ba => cipher -> ba -> ba Source #

Encrypt blocks

the input string need to be multiple of the block size

ecbDecrypt :: ByteArray ba => cipher -> ba -> ba Source #

Decrypt blocks

the input string need to be multiple of the block size

cbcEncrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba Source #

encrypt using the CBC mode.

input need to be a multiple of the blocksize

cbcDecrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba Source #

decrypt using the CBC mode.

input need to be a multiple of the blocksize

cfbEncrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba Source #

encrypt using the CFB mode.

input need to be a multiple of the blocksize

cfbDecrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba Source #

decrypt using the CFB mode.

input need to be a multiple of the blocksize

ctrCombine :: ByteArray ba => cipher -> IV cipher -> ba -> ba Source #

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

aeadInit :: ByteArrayAccess iv => AEADMode -> cipher -> iv -> CryptoFailable (AEAD cipher) Source #

Initialize a new AEAD State

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

#### Instances

Instances details

BlockCipher AES128 Source # |

Instance details

Defined in Crypto.Cipher.AES

Methods

blockSize :: AES128 -> Int Source #

ecbEncrypt :: ByteArray ba => AES128 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => AES128 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => AES128 -> IV AES128 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => AES128 -> IV AES128 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => AES128 -> IV AES128 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => AES128 -> IV AES128 -> ba -> ba Source #

ctrCombine :: ByteArray ba => AES128 -> IV AES128 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> AES128 -> iv -> CryptoFailable (AEAD AES128) Source #

BlockCipher AES192 Source # |

Instance details

Defined in Crypto.Cipher.AES

Methods

blockSize :: AES192 -> Int Source #

ecbEncrypt :: ByteArray ba => AES192 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => AES192 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => AES192 -> IV AES192 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => AES192 -> IV AES192 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => AES192 -> IV AES192 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => AES192 -> IV AES192 -> ba -> ba Source #

ctrCombine :: ByteArray ba => AES192 -> IV AES192 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> AES192 -> iv -> CryptoFailable (AEAD AES192) Source #

BlockCipher AES256 Source # |

Instance details

Defined in Crypto.Cipher.AES

Methods

blockSize :: AES256 -> Int Source #

ecbEncrypt :: ByteArray ba => AES256 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => AES256 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => AES256 -> IV AES256 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => AES256 -> IV AES256 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => AES256 -> IV AES256 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => AES256 -> IV AES256 -> ba -> ba Source #

ctrCombine :: ByteArray ba => AES256 -> IV AES256 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> AES256 -> iv -> CryptoFailable (AEAD AES256) Source #

BlockCipher Blowfish Source # |

Instance details

Defined in Crypto.Cipher.Blowfish

Methods

blockSize :: Blowfish -> Int Source #

ecbEncrypt :: ByteArray ba => Blowfish -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => Blowfish -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => Blowfish -> IV Blowfish -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => Blowfish -> IV Blowfish -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => Blowfish -> IV Blowfish -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => Blowfish -> IV Blowfish -> ba -> ba Source #

ctrCombine :: ByteArray ba => Blowfish -> IV Blowfish -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> Blowfish -> iv -> CryptoFailable (AEAD Blowfish) Source #

BlockCipher Blowfish128 Source # |

Instance details

Defined in Crypto.Cipher.Blowfish

Methods

blockSize :: Blowfish128 -> Int Source #

ecbEncrypt :: ByteArray ba => Blowfish128 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => Blowfish128 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => Blowfish128 -> IV Blowfish128 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => Blowfish128 -> IV Blowfish128 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => Blowfish128 -> IV Blowfish128 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => Blowfish128 -> IV Blowfish128 -> ba -> ba Source #

ctrCombine :: ByteArray ba => Blowfish128 -> IV Blowfish128 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> Blowfish128 -> iv -> CryptoFailable (AEAD Blowfish128) Source #

BlockCipher Blowfish256 Source # |

Instance details

Defined in Crypto.Cipher.Blowfish

Methods

blockSize :: Blowfish256 -> Int Source #

ecbEncrypt :: ByteArray ba => Blowfish256 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => Blowfish256 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => Blowfish256 -> IV Blowfish256 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => Blowfish256 -> IV Blowfish256 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => Blowfish256 -> IV Blowfish256 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => Blowfish256 -> IV Blowfish256 -> ba -> ba Source #

ctrCombine :: ByteArray ba => Blowfish256 -> IV Blowfish256 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> Blowfish256 -> iv -> CryptoFailable (AEAD Blowfish256) Source #

BlockCipher Blowfish448 Source # |

Instance details

Defined in Crypto.Cipher.Blowfish

Methods

blockSize :: Blowfish448 -> Int Source #

ecbEncrypt :: ByteArray ba => Blowfish448 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => Blowfish448 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => Blowfish448 -> IV Blowfish448 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => Blowfish448 -> IV Blowfish448 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => Blowfish448 -> IV Blowfish448 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => Blowfish448 -> IV Blowfish448 -> ba -> ba Source #

ctrCombine :: ByteArray ba => Blowfish448 -> IV Blowfish448 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> Blowfish448 -> iv -> CryptoFailable (AEAD Blowfish448) Source #

BlockCipher Blowfish64 Source # |

Instance details

Defined in Crypto.Cipher.Blowfish

Methods

blockSize :: Blowfish64 -> Int Source #

ecbEncrypt :: ByteArray ba => Blowfish64 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => Blowfish64 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => Blowfish64 -> IV Blowfish64 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => Blowfish64 -> IV Blowfish64 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => Blowfish64 -> IV Blowfish64 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => Blowfish64 -> IV Blowfish64 -> ba -> ba Source #

ctrCombine :: ByteArray ba => Blowfish64 -> IV Blowfish64 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> Blowfish64 -> iv -> CryptoFailable (AEAD Blowfish64) Source #

BlockCipher CAST5 Source # |

Instance details

Defined in Crypto.Cipher.CAST5

Methods

blockSize :: CAST5 -> Int Source #

ecbEncrypt :: ByteArray ba => CAST5 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => CAST5 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => CAST5 -> IV CAST5 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => CAST5 -> IV CAST5 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => CAST5 -> IV CAST5 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => CAST5 -> IV CAST5 -> ba -> ba Source #

ctrCombine :: ByteArray ba => CAST5 -> IV CAST5 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> CAST5 -> iv -> CryptoFailable (AEAD CAST5) Source #

BlockCipher Camellia128 Source # |

Instance details

Defined in Crypto.Cipher.Camellia

Methods

blockSize :: Camellia128 -> Int Source #

ecbEncrypt :: ByteArray ba => Camellia128 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => Camellia128 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => Camellia128 -> IV Camellia128 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => Camellia128 -> IV Camellia128 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => Camellia128 -> IV Camellia128 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => Camellia128 -> IV Camellia128 -> ba -> ba Source #

ctrCombine :: ByteArray ba => Camellia128 -> IV Camellia128 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> Camellia128 -> iv -> CryptoFailable (AEAD Camellia128) Source #

BlockCipher DES Source # |

Instance details

Defined in Crypto.Cipher.DES

Methods

blockSize :: DES -> Int Source #

ecbEncrypt :: ByteArray ba => DES -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => DES -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => DES -> IV DES -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => DES -> IV DES -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => DES -> IV DES -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => DES -> IV DES -> ba -> ba Source #

ctrCombine :: ByteArray ba => DES -> IV DES -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> DES -> iv -> CryptoFailable (AEAD DES) Source #

BlockCipher DES_EDE2 Source # |

Instance details

Defined in Crypto.Cipher.TripleDES

Methods

blockSize :: DES_EDE2 -> Int Source #

ecbEncrypt :: ByteArray ba => DES_EDE2 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => DES_EDE2 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => DES_EDE2 -> IV DES_EDE2 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => DES_EDE2 -> IV DES_EDE2 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => DES_EDE2 -> IV DES_EDE2 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => DES_EDE2 -> IV DES_EDE2 -> ba -> ba Source #

ctrCombine :: ByteArray ba => DES_EDE2 -> IV DES_EDE2 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> DES_EDE2 -> iv -> CryptoFailable (AEAD DES_EDE2) Source #

BlockCipher DES_EDE3 Source # |

Instance details

Defined in Crypto.Cipher.TripleDES

Methods

blockSize :: DES_EDE3 -> Int Source #

ecbEncrypt :: ByteArray ba => DES_EDE3 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => DES_EDE3 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => DES_EDE3 -> IV DES_EDE3 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => DES_EDE3 -> IV DES_EDE3 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => DES_EDE3 -> IV DES_EDE3 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => DES_EDE3 -> IV DES_EDE3 -> ba -> ba Source #

ctrCombine :: ByteArray ba => DES_EDE3 -> IV DES_EDE3 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> DES_EDE3 -> iv -> CryptoFailable (AEAD DES_EDE3) Source #

BlockCipher DES_EEE2 Source # |

Instance details

Defined in Crypto.Cipher.TripleDES

Methods

blockSize :: DES_EEE2 -> Int Source #

ecbEncrypt :: ByteArray ba => DES_EEE2 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => DES_EEE2 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => DES_EEE2 -> IV DES_EEE2 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => DES_EEE2 -> IV DES_EEE2 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => DES_EEE2 -> IV DES_EEE2 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => DES_EEE2 -> IV DES_EEE2 -> ba -> ba Source #

ctrCombine :: ByteArray ba => DES_EEE2 -> IV DES_EEE2 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> DES_EEE2 -> iv -> CryptoFailable (AEAD DES_EEE2) Source #

BlockCipher DES_EEE3 Source # |

Instance details

Defined in Crypto.Cipher.TripleDES

Methods

blockSize :: DES_EEE3 -> Int Source #

ecbEncrypt :: ByteArray ba => DES_EEE3 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => DES_EEE3 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => DES_EEE3 -> IV DES_EEE3 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => DES_EEE3 -> IV DES_EEE3 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => DES_EEE3 -> IV DES_EEE3 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => DES_EEE3 -> IV DES_EEE3 -> ba -> ba Source #

ctrCombine :: ByteArray ba => DES_EEE3 -> IV DES_EEE3 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> DES_EEE3 -> iv -> CryptoFailable (AEAD DES_EEE3) Source #

BlockCipher Twofish128 Source # |

Instance details

Defined in Crypto.Cipher.Twofish

Methods

blockSize :: Twofish128 -> Int Source #

ecbEncrypt :: ByteArray ba => Twofish128 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => Twofish128 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => Twofish128 -> IV Twofish128 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => Twofish128 -> IV Twofish128 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => Twofish128 -> IV Twofish128 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => Twofish128 -> IV Twofish128 -> ba -> ba Source #

ctrCombine :: ByteArray ba => Twofish128 -> IV Twofish128 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> Twofish128 -> iv -> CryptoFailable (AEAD Twofish128) Source #

BlockCipher Twofish192 Source # |

Instance details

Defined in Crypto.Cipher.Twofish

Methods

blockSize :: Twofish192 -> Int Source #

ecbEncrypt :: ByteArray ba => Twofish192 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => Twofish192 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => Twofish192 -> IV Twofish192 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => Twofish192 -> IV Twofish192 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => Twofish192 -> IV Twofish192 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => Twofish192 -> IV Twofish192 -> ba -> ba Source #

ctrCombine :: ByteArray ba => Twofish192 -> IV Twofish192 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> Twofish192 -> iv -> CryptoFailable (AEAD Twofish192) Source #

BlockCipher Twofish256 Source # |

Instance details

Defined in Crypto.Cipher.Twofish

Methods

blockSize :: Twofish256 -> Int Source #

ecbEncrypt :: ByteArray ba => Twofish256 -> ba -> ba Source #

ecbDecrypt :: ByteArray ba => Twofish256 -> ba -> ba Source #

cbcEncrypt :: ByteArray ba => Twofish256 -> IV Twofish256 -> ba -> ba Source #

cbcDecrypt :: ByteArray ba => Twofish256 -> IV Twofish256 -> ba -> ba Source #

cfbEncrypt :: ByteArray ba => Twofish256 -> IV Twofish256 -> ba -> ba Source #

cfbDecrypt :: ByteArray ba => Twofish256 -> IV Twofish256 -> ba -> ba Source #

ctrCombine :: ByteArray ba => Twofish256 -> IV Twofish256 -> ba -> ba Source #

aeadInit :: ByteArrayAccess iv => AEADMode -> Twofish256 -> iv -> CryptoFailable (AEAD Twofish256) Source #

class BlockCipher cipher => BlockCipher128 cipher where Source #

class of block cipher with a 128 bits block size

Minimal complete definition

Nothing

Methods

xtsEncrypt Source #

Arguments

:: ByteArray ba |
=> (cipher, cipher) |
-> IV cipher | Usually represent the Data Unit (e.g. disk sector)
-> DataUnitOffset | Offset in the data unit in number of blocks
-> ba | Plaintext
-> ba | Ciphertext

encrypt using the XTS mode.

input need to be a multiple of the blocksize, and the cipher need to process 128 bits block only

xtsDecrypt Source #

Arguments

:: ByteArray ba |
=> (cipher, cipher) |
-> IV cipher | Usually represent the Data Unit (e.g. disk sector)
-> DataUnitOffset | Offset in the data unit in number of blocks
-> ba | Ciphertext
-> ba | Plaintext

decrypt using the XTS mode.

input need to be a multiple of the blocksize, and the cipher need to process 128 bits block only

#### Instances

Instances details

BlockCipher128 AES128 Source # |
Instance details Defined in Crypto.Cipher.AES Methods xtsEncrypt :: ByteArray ba => (AES128, AES128) -> IV AES128 -> DataUnitOffset -> ba -> ba Source # xtsDecrypt :: ByteArray ba => (AES128, AES128) -> IV AES128 -> DataUnitOffset -> ba -> ba Source #
BlockCipher128 AES192 Source # |
Instance details Defined in Crypto.Cipher.AES Methods xtsEncrypt :: ByteArray ba => (AES192, AES192) -> IV AES192 -> DataUnitOffset -> ba -> ba Source # xtsDecrypt :: ByteArray ba => (AES192, AES192) -> IV AES192 -> DataUnitOffset -> ba -> ba Source #
BlockCipher128 AES256 Source # |
Instance details Defined in Crypto.Cipher.AES Methods xtsEncrypt :: ByteArray ba => (AES256, AES256) -> IV AES256 -> DataUnitOffset -> ba -> ba Source # xtsDecrypt :: ByteArray ba => (AES256, AES256) -> IV AES256 -> DataUnitOffset -> ba -> ba Source #

class Cipher cipher => StreamCipher cipher where Source #

Symmetric stream cipher class

Methods

streamCombine :: ByteArray ba => cipher -> ba -> (ba, cipher) Source #

Combine using the stream cipher

type DataUnitOffset = Word32 Source #

Offset inside an XTS data unit, measured in block size.

data KeySizeSpecifier Source #

Different specifier for key size in bytes

Constructors

KeySizeRange Int Int | in the range [min,max]
KeySizeEnum [Int] | one of the specified values
KeySizeFixed Int | a specific size

#### Instances

Instances details

Show KeySizeSpecifier Source # |
Instance details Defined in Crypto.Cipher.Types.Base Methods showsPrec :: Int -> KeySizeSpecifier -> ShowS Source # show :: KeySizeSpecifier -> String Source # showList :: [KeySizeSpecifier] -> ShowS Source #
Eq KeySizeSpecifier Source # |
Instance details Defined in Crypto.Cipher.Types.Base Methods (==) :: KeySizeSpecifier -> KeySizeSpecifier -> Bool Source # (/=) :: KeySizeSpecifier -> KeySizeSpecifier -> Bool Source #

# AEAD functions

data AEADMode Source #

AEAD Mode

Constructors

AEAD_OCB |
AEAD_CCM Int CCM_M CCM_L |
AEAD_EAX |
AEAD_CWC |
AEAD_GCM |

#### Instances

Instances details

Show AEADMode Source # |
Instance details Defined in Crypto.Cipher.Types.Base Methods showsPrec :: Int -> AEADMode -> ShowS Source # show :: AEADMode -> String Source # showList :: [AEADMode] -> ShowS Source #
Eq AEADMode Source # |
Instance details Defined in Crypto.Cipher.Types.Base Methods (==) :: AEADMode -> AEADMode -> Bool Source # (/=) :: AEADMode -> AEADMode -> Bool Source #

data CCM_M Source #

Constructors

CCM_M4 |
CCM_M6 |
CCM_M8 |
CCM_M10 |
CCM_M12 |
CCM_M14 |
CCM_M16 |

#### Instances

Instances details

Show CCM_M Source # |
Instance details Defined in Crypto.Cipher.Types.Base Methods showsPrec :: Int -> CCM_M -> ShowS Source # show :: CCM_M -> String Source # showList :: [CCM_M] -> ShowS Source #
Eq CCM_M Source # |
Instance details Defined in Crypto.Cipher.Types.Base Methods (==) :: CCM_M -> CCM_M -> Bool Source # (/=) :: CCM_M -> CCM_M -> Bool Source #

data CCM_L Source #

Constructors

CCM_L2 |
CCM_L3 |
CCM_L4 |

#### Instances

Instances details

Show CCM_L Source # |
Instance details Defined in Crypto.Cipher.Types.Base Methods showsPrec :: Int -> CCM_L -> ShowS Source # show :: CCM_L -> String Source # showList :: [CCM_L] -> ShowS Source #
Eq CCM_L Source # |
Instance details Defined in Crypto.Cipher.Types.Base Methods (==) :: CCM_L -> CCM_L -> Bool Source # (/=) :: CCM_L -> CCM_L -> Bool Source #

data AEADModeImpl st Source #

AEAD Implementation

Constructors

AEADModeImpl |

Fields

- aeadImplAppendHeader :: forall ba. ByteArrayAccess ba => st -> ba -> st
- aeadImplEncrypt :: forall ba. ByteArray ba => st -> ba -> (ba, st)
- aeadImplDecrypt :: forall ba. ByteArray ba => st -> ba -> (ba, st)
- aeadImplFinalize :: st -> Int -> AuthTag

data AEAD cipher Source #

Authenticated Encryption with Associated Data algorithms

Constructors

forall st. AEAD |

Fields

- aeadModeImpl :: AEADModeImpl st
- aeadState :: !st

aeadAppendHeader :: ByteArrayAccess aad => AEAD cipher -> aad -> AEAD cipher Source #

Append some header information to an AEAD context

aeadEncrypt :: ByteArray ba => AEAD cipher -> ba -> (ba, AEAD cipher) Source #

Encrypt some data and update the AEAD context

aeadDecrypt :: ByteArray ba => AEAD cipher -> ba -> (ba, AEAD cipher) Source #

Decrypt some data and update the AEAD context

aeadFinalize :: AEAD cipher -> Int -> AuthTag Source #

Finalize the AEAD context and return the authentication tag

aeadSimpleEncrypt Source #

Arguments

:: (ByteArrayAccess aad, ByteArray ba) |
=> AEAD a | A new AEAD Context
-> aad | Optional Authentication data header
-> ba | Optional Plaintext
-> Int | Tag length
-> (AuthTag, ba) | Authentication tag and ciphertext

Simple AEAD encryption

aeadSimpleDecrypt Source #

Arguments

:: (ByteArrayAccess aad, ByteArray ba) |
=> AEAD a | A new AEAD Context
-> aad | Optional Authentication data header
-> ba | Ciphertext
-> AuthTag | The authentication tag
-> Maybe ba | Plaintext

Simple AEAD decryption

# Initial Vector type and constructor

data IV c Source #

an IV parametrized by the cipher

#### Instances

Instances details

Eq (IV c) Source # |
Instance details Defined in Crypto.Cipher.Types.Block Methods (==) :: IV c -> IV c -> Bool Source # (/=) :: IV c -> IV c -> Bool Source #
BlockCipher c => ByteArrayAccess (IV c) Source # |
Instance details Defined in Crypto.Cipher.Types.Block Methods length :: IV c -> Int Source # withByteArray :: IV c -> (Ptr p -> IO a) -> IO a Source # copyByteArrayToPtr :: IV c -> Ptr p -> IO () Source #

makeIV :: (ByteArrayAccess b, BlockCipher c) => b -> Maybe (IV c) Source #

Create an IV for a specified block cipher

nullIV :: BlockCipher c => IV c Source #

Create an IV that is effectively representing the number 0

ivAdd :: IV c -> Int -> IV c Source #

Increment an IV by a number.

Assume the IV is in Big Endian format.

# Authentification Tag

newtype AuthTag Source #

Authentication Tag for AE cipher mode

Constructors

AuthTag |

Fields

- unAuthTag :: Bytes

#### Instances

Instances details

Show AuthTag Source # |
Instance details Defined in Crypto.Cipher.Types.Base Methods showsPrec :: Int -> AuthTag -> ShowS Source # show :: AuthTag -> String Source # showList :: [AuthTag] -> ShowS Source #
NFData AuthTag Source # |
Instance details Defined in Crypto.Cipher.Types.Base Methods rnf :: AuthTag -> () Source #
Eq AuthTag Source # |
Instance details Defined in Crypto.Cipher.Types.Base Methods (==) :: AuthTag -> AuthTag -> Bool Source # (/=) :: AuthTag -> AuthTag -> Bool Source #
ByteArrayAccess AuthTag Source # |
Instance details Defined in Crypto.Cipher.Types.Base Methods length :: AuthTag -> Int Source # withByteArray :: AuthTag -> (Ptr p -> IO a) -> IO a Source # copyByteArrayToPtr :: AuthTag -> Ptr p -> IO () Source #