Crypto.Cipher.Types

cryptonite-0.19: Cryptography Primitives sink

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | Stable
Portability | Excellent
Safe Haskell | None
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
- class Cipher cipher => BlockCipher cipher where
- class BlockCipher cipher => BlockCipher128 cipher where
- class Cipher cipher => StreamCipher cipher where
- type DataUnitOffset = Word32
- data KeySizeSpecifier
  - = KeySizeRange Int Int
  - | KeySizeEnum [Int]
  - | KeySizeFixed Int
- data AEADMode
  - = AEAD_OCB
  - | AEAD_CCM
  - | AEAD_EAX
  - | AEAD_CWC
  - | AEAD_GCM
- 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 = 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 :: BlockCipher c => IV c -> Int -> IV c
- newtype AuthTag = AuthTag {
  - unAuthTag :: Bytes
  }

# Cipher classes

class Cipher cipher where #

Symmetric cipher class.

Minimal complete definition

cipherInit, cipherName, cipherKeySize

Methods

cipherInit :: ByteArray key => key -> CryptoFailable 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

Instances

Cipher Blowfish448 # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable Blowfish448 # cipherName :: Blowfish448 -> String # cipherKeySize :: Blowfish448 -> KeySizeSpecifier #
Cipher Blowfish256 # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable Blowfish256 # cipherName :: Blowfish256 -> String # cipherKeySize :: Blowfish256 -> KeySizeSpecifier #
Cipher Blowfish128 # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable Blowfish128 # cipherName :: Blowfish128 -> String # cipherKeySize :: Blowfish128 -> KeySizeSpecifier #
Cipher Blowfish64 # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable Blowfish64 # cipherName :: Blowfish64 -> String # cipherKeySize :: Blowfish64 -> KeySizeSpecifier #
Cipher Blowfish # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable Blowfish # cipherName :: Blowfish -> String # cipherKeySize :: Blowfish -> KeySizeSpecifier #
Cipher Camellia128 # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable Camellia128 # cipherName :: Camellia128 -> String # cipherKeySize :: Camellia128 -> KeySizeSpecifier #
Cipher DES # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable DES # cipherName :: DES -> String # cipherKeySize :: DES -> KeySizeSpecifier #
Cipher DES_EDE2 # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable DES_EDE2 # cipherName :: DES_EDE2 -> String # cipherKeySize :: DES_EDE2 -> KeySizeSpecifier #
Cipher DES_EEE2 # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable DES_EEE2 # cipherName :: DES_EEE2 -> String # cipherKeySize :: DES_EEE2 -> KeySizeSpecifier #
Cipher DES_EDE3 # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable DES_EDE3 # cipherName :: DES_EDE3 -> String # cipherKeySize :: DES_EDE3 -> KeySizeSpecifier #
Cipher DES_EEE3 # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable DES_EEE3 # cipherName :: DES_EEE3 -> String # cipherKeySize :: DES_EEE3 -> KeySizeSpecifier #
Cipher AES256 # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable AES256 # cipherName :: AES256 -> String # cipherKeySize :: AES256 -> KeySizeSpecifier #
Cipher AES192 # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable AES192 # cipherName :: AES192 -> String # cipherKeySize :: AES192 -> KeySizeSpecifier #
Cipher AES128 # |
Methods cipherInit :: ByteArray key => key -> CryptoFailable AES128 # cipherName :: AES128 -> String # cipherKeySize :: AES128 -> KeySizeSpecifier #

class Cipher cipher => BlockCipher cipher where #

Symmetric block cipher class

Minimal complete definition

blockSize, ecbEncrypt, ecbDecrypt

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.

Instances

BlockCipher Blowfish448 # |
Methods blockSize :: Blowfish448 -> Int # ecbEncrypt :: ByteArray ba => Blowfish448 -> ba -> ba # ecbDecrypt :: ByteArray ba => Blowfish448 -> ba -> ba # cbcEncrypt :: ByteArray ba => Blowfish448 -> IV Blowfish448 -> ba -> ba # cbcDecrypt :: ByteArray ba => Blowfish448 -> IV Blowfish448 -> ba -> ba # cfbEncrypt :: ByteArray ba => Blowfish448 -> IV Blowfish448 -> ba -> ba # cfbDecrypt :: ByteArray ba => Blowfish448 -> IV Blowfish448 -> ba -> ba # ctrCombine :: ByteArray ba => Blowfish448 -> IV Blowfish448 -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> Blowfish448 -> iv -> CryptoFailable (AEAD Blowfish448) #
BlockCipher Blowfish256 # |
Methods blockSize :: Blowfish256 -> Int # ecbEncrypt :: ByteArray ba => Blowfish256 -> ba -> ba # ecbDecrypt :: ByteArray ba => Blowfish256 -> ba -> ba # cbcEncrypt :: ByteArray ba => Blowfish256 -> IV Blowfish256 -> ba -> ba # cbcDecrypt :: ByteArray ba => Blowfish256 -> IV Blowfish256 -> ba -> ba # cfbEncrypt :: ByteArray ba => Blowfish256 -> IV Blowfish256 -> ba -> ba # cfbDecrypt :: ByteArray ba => Blowfish256 -> IV Blowfish256 -> ba -> ba # ctrCombine :: ByteArray ba => Blowfish256 -> IV Blowfish256 -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> Blowfish256 -> iv -> CryptoFailable (AEAD Blowfish256) #
BlockCipher Blowfish128 # |
Methods blockSize :: Blowfish128 -> Int # ecbEncrypt :: ByteArray ba => Blowfish128 -> ba -> ba # ecbDecrypt :: ByteArray ba => Blowfish128 -> ba -> ba # cbcEncrypt :: ByteArray ba => Blowfish128 -> IV Blowfish128 -> ba -> ba # cbcDecrypt :: ByteArray ba => Blowfish128 -> IV Blowfish128 -> ba -> ba # cfbEncrypt :: ByteArray ba => Blowfish128 -> IV Blowfish128 -> ba -> ba # cfbDecrypt :: ByteArray ba => Blowfish128 -> IV Blowfish128 -> ba -> ba # ctrCombine :: ByteArray ba => Blowfish128 -> IV Blowfish128 -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> Blowfish128 -> iv -> CryptoFailable (AEAD Blowfish128) #
BlockCipher Blowfish64 # |
Methods blockSize :: Blowfish64 -> Int # ecbEncrypt :: ByteArray ba => Blowfish64 -> ba -> ba # ecbDecrypt :: ByteArray ba => Blowfish64 -> ba -> ba # cbcEncrypt :: ByteArray ba => Blowfish64 -> IV Blowfish64 -> ba -> ba # cbcDecrypt :: ByteArray ba => Blowfish64 -> IV Blowfish64 -> ba -> ba # cfbEncrypt :: ByteArray ba => Blowfish64 -> IV Blowfish64 -> ba -> ba # cfbDecrypt :: ByteArray ba => Blowfish64 -> IV Blowfish64 -> ba -> ba # ctrCombine :: ByteArray ba => Blowfish64 -> IV Blowfish64 -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> Blowfish64 -> iv -> CryptoFailable (AEAD Blowfish64) #
BlockCipher Blowfish # |
Methods blockSize :: Blowfish -> Int # ecbEncrypt :: ByteArray ba => Blowfish -> ba -> ba # ecbDecrypt :: ByteArray ba => Blowfish -> ba -> ba # cbcEncrypt :: ByteArray ba => Blowfish -> IV Blowfish -> ba -> ba # cbcDecrypt :: ByteArray ba => Blowfish -> IV Blowfish -> ba -> ba # cfbEncrypt :: ByteArray ba => Blowfish -> IV Blowfish -> ba -> ba # cfbDecrypt :: ByteArray ba => Blowfish -> IV Blowfish -> ba -> ba # ctrCombine :: ByteArray ba => Blowfish -> IV Blowfish -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> Blowfish -> iv -> CryptoFailable (AEAD Blowfish) #
BlockCipher Camellia128 # |
Methods blockSize :: Camellia128 -> Int # ecbEncrypt :: ByteArray ba => Camellia128 -> ba -> ba # ecbDecrypt :: ByteArray ba => Camellia128 -> ba -> ba # cbcEncrypt :: ByteArray ba => Camellia128 -> IV Camellia128 -> ba -> ba # cbcDecrypt :: ByteArray ba => Camellia128 -> IV Camellia128 -> ba -> ba # cfbEncrypt :: ByteArray ba => Camellia128 -> IV Camellia128 -> ba -> ba # cfbDecrypt :: ByteArray ba => Camellia128 -> IV Camellia128 -> ba -> ba # ctrCombine :: ByteArray ba => Camellia128 -> IV Camellia128 -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> Camellia128 -> iv -> CryptoFailable (AEAD Camellia128) #
BlockCipher DES # |
Methods blockSize :: DES -> Int # ecbEncrypt :: ByteArray ba => DES -> ba -> ba # ecbDecrypt :: ByteArray ba => DES -> ba -> ba # cbcEncrypt :: ByteArray ba => DES -> IV DES -> ba -> ba # cbcDecrypt :: ByteArray ba => DES -> IV DES -> ba -> ba # cfbEncrypt :: ByteArray ba => DES -> IV DES -> ba -> ba # cfbDecrypt :: ByteArray ba => DES -> IV DES -> ba -> ba # ctrCombine :: ByteArray ba => DES -> IV DES -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> DES -> iv -> CryptoFailable (AEAD DES) #
BlockCipher DES_EDE2 # |
Methods blockSize :: DES_EDE2 -> Int # ecbEncrypt :: ByteArray ba => DES_EDE2 -> ba -> ba # ecbDecrypt :: ByteArray ba => DES_EDE2 -> ba -> ba # cbcEncrypt :: ByteArray ba => DES_EDE2 -> IV DES_EDE2 -> ba -> ba # cbcDecrypt :: ByteArray ba => DES_EDE2 -> IV DES_EDE2 -> ba -> ba # cfbEncrypt :: ByteArray ba => DES_EDE2 -> IV DES_EDE2 -> ba -> ba # cfbDecrypt :: ByteArray ba => DES_EDE2 -> IV DES_EDE2 -> ba -> ba # ctrCombine :: ByteArray ba => DES_EDE2 -> IV DES_EDE2 -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> DES_EDE2 -> iv -> CryptoFailable (AEAD DES_EDE2) #
BlockCipher DES_EEE2 # |
Methods blockSize :: DES_EEE2 -> Int # ecbEncrypt :: ByteArray ba => DES_EEE2 -> ba -> ba # ecbDecrypt :: ByteArray ba => DES_EEE2 -> ba -> ba # cbcEncrypt :: ByteArray ba => DES_EEE2 -> IV DES_EEE2 -> ba -> ba # cbcDecrypt :: ByteArray ba => DES_EEE2 -> IV DES_EEE2 -> ba -> ba # cfbEncrypt :: ByteArray ba => DES_EEE2 -> IV DES_EEE2 -> ba -> ba # cfbDecrypt :: ByteArray ba => DES_EEE2 -> IV DES_EEE2 -> ba -> ba # ctrCombine :: ByteArray ba => DES_EEE2 -> IV DES_EEE2 -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> DES_EEE2 -> iv -> CryptoFailable (AEAD DES_EEE2) #
BlockCipher DES_EDE3 # |
Methods blockSize :: DES_EDE3 -> Int # ecbEncrypt :: ByteArray ba => DES_EDE3 -> ba -> ba # ecbDecrypt :: ByteArray ba => DES_EDE3 -> ba -> ba # cbcEncrypt :: ByteArray ba => DES_EDE3 -> IV DES_EDE3 -> ba -> ba # cbcDecrypt :: ByteArray ba => DES_EDE3 -> IV DES_EDE3 -> ba -> ba # cfbEncrypt :: ByteArray ba => DES_EDE3 -> IV DES_EDE3 -> ba -> ba # cfbDecrypt :: ByteArray ba => DES_EDE3 -> IV DES_EDE3 -> ba -> ba # ctrCombine :: ByteArray ba => DES_EDE3 -> IV DES_EDE3 -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> DES_EDE3 -> iv -> CryptoFailable (AEAD DES_EDE3) #
BlockCipher DES_EEE3 # |
Methods blockSize :: DES_EEE3 -> Int # ecbEncrypt :: ByteArray ba => DES_EEE3 -> ba -> ba # ecbDecrypt :: ByteArray ba => DES_EEE3 -> ba -> ba # cbcEncrypt :: ByteArray ba => DES_EEE3 -> IV DES_EEE3 -> ba -> ba # cbcDecrypt :: ByteArray ba => DES_EEE3 -> IV DES_EEE3 -> ba -> ba # cfbEncrypt :: ByteArray ba => DES_EEE3 -> IV DES_EEE3 -> ba -> ba # cfbDecrypt :: ByteArray ba => DES_EEE3 -> IV DES_EEE3 -> ba -> ba # ctrCombine :: ByteArray ba => DES_EEE3 -> IV DES_EEE3 -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> DES_EEE3 -> iv -> CryptoFailable (AEAD DES_EEE3) #
BlockCipher AES256 # |
Methods blockSize :: AES256 -> Int # ecbEncrypt :: ByteArray ba => AES256 -> ba -> ba # ecbDecrypt :: ByteArray ba => AES256 -> ba -> ba # cbcEncrypt :: ByteArray ba => AES256 -> IV AES256 -> ba -> ba # cbcDecrypt :: ByteArray ba => AES256 -> IV AES256 -> ba -> ba # cfbEncrypt :: ByteArray ba => AES256 -> IV AES256 -> ba -> ba # cfbDecrypt :: ByteArray ba => AES256 -> IV AES256 -> ba -> ba # ctrCombine :: ByteArray ba => AES256 -> IV AES256 -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> AES256 -> iv -> CryptoFailable (AEAD AES256) #
BlockCipher AES192 # |
Methods blockSize :: AES192 -> Int # ecbEncrypt :: ByteArray ba => AES192 -> ba -> ba # ecbDecrypt :: ByteArray ba => AES192 -> ba -> ba # cbcEncrypt :: ByteArray ba => AES192 -> IV AES192 -> ba -> ba # cbcDecrypt :: ByteArray ba => AES192 -> IV AES192 -> ba -> ba # cfbEncrypt :: ByteArray ba => AES192 -> IV AES192 -> ba -> ba # cfbDecrypt :: ByteArray ba => AES192 -> IV AES192 -> ba -> ba # ctrCombine :: ByteArray ba => AES192 -> IV AES192 -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> AES192 -> iv -> CryptoFailable (AEAD AES192) #
BlockCipher AES128 # |
Methods blockSize :: AES128 -> Int # ecbEncrypt :: ByteArray ba => AES128 -> ba -> ba # ecbDecrypt :: ByteArray ba => AES128 -> ba -> ba # cbcEncrypt :: ByteArray ba => AES128 -> IV AES128 -> ba -> ba # cbcDecrypt :: ByteArray ba => AES128 -> IV AES128 -> ba -> ba # cfbEncrypt :: ByteArray ba => AES128 -> IV AES128 -> ba -> ba # cfbDecrypt :: ByteArray ba => AES128 -> IV AES128 -> ba -> ba # ctrCombine :: ByteArray ba => AES128 -> IV AES128 -> ba -> ba # aeadInit :: ByteArrayAccess iv => AEADMode -> AES128 -> iv -> CryptoFailable (AEAD AES128) #

class 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

Instances

BlockCipher128 AES256 # |
Methods xtsEncrypt :: ByteArray ba => (AES256, AES256) -> IV AES256 -> DataUnitOffset -> ba -> ba # xtsDecrypt :: ByteArray ba => (AES256, AES256) -> IV AES256 -> DataUnitOffset -> ba -> ba #
BlockCipher128 AES192 # |
Methods xtsEncrypt :: ByteArray ba => (AES192, AES192) -> IV AES192 -> DataUnitOffset -> ba -> ba # xtsDecrypt :: ByteArray ba => (AES192, AES192) -> IV AES192 -> DataUnitOffset -> ba -> ba #
BlockCipher128 AES128 # |
Methods xtsEncrypt :: ByteArray ba => (AES128, AES128) -> IV AES128 -> DataUnitOffset -> ba -> ba # xtsDecrypt :: ByteArray ba => (AES128, AES128) -> IV AES128 -> DataUnitOffset -> ba -> ba #

class Cipher cipher => StreamCipher cipher where #

Symmetric stream cipher class

Minimal complete definition

streamCombine

Methods

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

Combine using the stream cipher

type DataUnitOffset = Word32 #

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

data KeySizeSpecifier #

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

Eq KeySizeSpecifier # |
Methods (==) :: KeySizeSpecifier -> KeySizeSpecifier -> Bool # (/=) :: KeySizeSpecifier -> KeySizeSpecifier -> Bool #
Show KeySizeSpecifier # |
Methods showsPrec :: Int -> KeySizeSpecifier -> ShowS # show :: KeySizeSpecifier -> String # showList :: [KeySizeSpecifier] -> ShowS #

# AEAD functions

data AEADMode #

AEAD Mode

Constructors

AEAD_OCB |
AEAD_CCM |
AEAD_EAX |
AEAD_CWC |
AEAD_GCM |

Instances

Eq AEADMode # |
Methods (==) :: AEADMode -> AEADMode -> Bool # (/=) :: AEADMode -> AEADMode -> Bool #
Show AEADMode # |
Methods showsPrec :: Int -> AEADMode -> ShowS # show :: AEADMode -> String # showList :: [AEADMode] -> ShowS #

data AEADModeImpl st #

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 #

Authenticated Encryption with Associated Data algorithms

Constructors

AEAD |
Fields aeadModeImpl :: AEADModeImpl st aeadState :: st

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

Append some header information to an AEAD context

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

Encrypt some data and update the AEAD context

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

Decrypt some data and update the AEAD context

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

Finalize the AEAD context and return the authentication tag

aeadSimpleEncrypt #

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 #

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 #

an IV parametrized by the cipher

Instances

Eq (IV c) # |
Methods (==) :: IV c -> IV c -> Bool # (/=) :: IV c -> IV c -> Bool #
BlockCipher c => ByteArrayAccess (IV c) # |
Methods length :: IV c -> Int # withByteArray :: IV c -> (Ptr p -> IO a) -> IO a #

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

Create an IV for a specified block cipher

nullIV :: BlockCipher c => IV c #

Create an IV that is effectively representing the number 0

ivAdd :: BlockCipher c => IV c -> Int -> IV c #

Increment an IV by a number.

Assume the IV is in Big Endian format.

# Authentification Tag

newtype AuthTag #

Authentication Tag for AE cipher mode

Constructors

AuthTag |
Fields unAuthTag :: Bytes

Instances

Eq AuthTag # |
Methods (==) :: AuthTag -> AuthTag -> Bool # (/=) :: AuthTag -> AuthTag -> Bool #
Show AuthTag # |
Methods showsPrec :: Int -> AuthTag -> ShowS # show :: AuthTag -> String # showList :: [AuthTag] -> ShowS #
ByteArrayAccess AuthTag # |
Methods length :: AuthTag -> Int # withByteArray :: AuthTag -> (Ptr p -> IO a) -> IO a #