cipher-aes128-0.7.0.3: AES and common modes using AES-NI when available.

Safe HaskellNone
LanguageHaskell2010

Crypto.Cipher.AES128

Contents

Synopsis

Key types with crypto-api instances

class Serialize k => BlockCipher k where

Minimal complete definition

blockSize, encryptBlock, decryptBlock, buildKey, keyLength

Methods

blockSize :: Tagged * k BitLength

encryptBlock :: k -> ByteString -> ByteString

decryptBlock :: k -> ByteString -> ByteString

buildKey :: ByteString -> Maybe k

keyLength :: Tagged * k BitLength

ecb :: k -> ByteString -> ByteString

unEcb :: k -> ByteString -> ByteString

cbc :: k -> IV k -> ByteString -> (ByteString, IV k)

unCbc :: k -> IV k -> ByteString -> (ByteString, IV k)

ctr :: k -> IV k -> ByteString -> (ByteString, IV k)

unCtr :: k -> IV k -> ByteString -> (ByteString, IV k)

ctrLazy :: k -> IV k -> ByteString -> (ByteString, IV k)

unCtrLazy :: k -> IV k -> ByteString -> (ByteString, IV k)

cfb :: k -> IV k -> ByteString -> (ByteString, IV k)

unCfb :: k -> IV k -> ByteString -> (ByteString, IV k)

ofb :: k -> IV k -> ByteString -> (ByteString, IV k)

unOfb :: k -> IV k -> ByteString -> (ByteString, IV k)

cbcLazy :: k -> IV k -> ByteString -> (ByteString, IV k)

unCbcLazy :: k -> IV k -> ByteString -> (ByteString, IV k)

sivLazy :: k -> k -> [ByteString] -> ByteString -> Maybe ByteString

unSivLazy :: k -> k -> [ByteString] -> ByteString -> Maybe ByteString

siv :: k -> k -> [ByteString] -> ByteString -> Maybe ByteString

unSiv :: k -> k -> [ByteString] -> ByteString -> Maybe ByteString

ecbLazy :: k -> ByteString -> ByteString

unEcbLazy :: k -> ByteString -> ByteString

cfbLazy :: k -> IV k -> ByteString -> (ByteString, IV k)

unCfbLazy :: k -> IV k -> ByteString -> (ByteString, IV k)

ofbLazy :: k -> IV k -> ByteString -> (ByteString, IV k)

unOfbLazy :: k -> IV k -> ByteString -> (ByteString, IV k)

zeroIV :: BlockCipher k => IV k

GCM Operations

makeGCMCtx :: AES_GCM k => ByteString -> Maybe (GCMCtx k) Source

Given key material produce a context useful for GCM operations

aesKeyToGCM :: AES_GCM k => k -> GCMCtx k Source

Given an AESKey produce a GCM Context.

data GCMCtx k Source

A tuple of key and precomputed data for use by GCM

data AuthTag Source

Constructors

AuthTag 

Instances

encryptGCM Source

Arguments

:: AES_GCM k 
=> GCMCtx k 
-> ByteString

IV

-> ByteString

Plaintext

-> ByteString

AAD

-> (ByteString, AuthTag) 

Encrypts multiple-of-block-sized input, returning a bytestring and tag.

decryptGCM Source

Arguments

:: AES_GCM k 
=> GCMCtx k 
-> ByteString

IV

-> ByteString

Ciphertext

-> ByteString

AAD

-> (ByteString, AuthTag)

Plaintext and incremented context (or an error)

Decrypts multiple-of-block-sized input, returing a bytestring of the [ctr, ct, tag].