HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulecrypton-1.0.4Haskell2010

Crypto.Cipher.Types

Symmetric cipher basic types

  • 9 types
  • 4 classes
  • 9 values
  • Packagecrypton-1.0.4
  • Exports22
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceTypes.hs

Cipher classes

6 declarations
classclass Cipher cipher where
#

Symmetric cipher class.

Methods

Instances19Cipher, …
classclass Cipher cipher => BlockCipher cipher where
#

Symmetric block cipher class

Methods

  • blockSize :: cipher -> Int

    Return the size of block required for this block cipher

  • ecbEncrypt :: ByteArray ba => cipher -> ba -> ba

    Encrypt blocks

    the input string need to be multiple of the block size

  • ecbDecrypt :: ByteArray ba => cipher -> ba -> ba

    Decrypt blocks

    the input string need to be multiple of the block size

  • cbcEncrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba

    encrypt using the CBC mode.

    input need to be a multiple of the blocksize

  • cbcDecrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba

    decrypt using the CBC mode.

    input need to be a multiple of the blocksize

  • cfbEncrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba

    encrypt using the CFB mode.

    input need to be a multiple of the blocksize

  • cfbDecrypt :: ByteArray ba => cipher -> IV cipher -> ba -> ba

    decrypt using the CFB mode.

    input need to be a multiple of the blocksize

  • ctrCombine :: ByteArray ba => cipher -> IV cipher -> ba -> ba

    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)

    Initialize a new AEAD State

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

Instances19BlockCipher, …
classclass BlockCipher cipher => BlockCipher128 cipher where
#

class of block cipher with a 128 bits block size

Methods

  • xtsEncrypt :: ByteArray ba => (cipher, cipher) -> IV cipher -> DataUnitOffset -> ba -> ba

    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 :: ByteArray ba => (cipher, cipher) -> IV cipher -> DataUnitOffset -> ba -> ba

    decrypt using the XTS mode.

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

Instances4BlockCipher128

AEAD functions

11 declarations

Initial Vector type and constructor

4 declarations
datadata IV c
#

an IV parametrized by the cipher

Instances2Eq, ByteArrayAccess
valuenullIV :: BlockCipher c => IV c
#

Create an IV that is effectively representing the number 0

valueivAdd :: IV c -> Int -> IV c
#

Increment an IV by a number.

Assume the IV is in Big Endian format.

Authentification Tag

1 declaration