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

Safe HaskellNone

Crypto.Cipher.AES128

Synopsis

Documentation

class Serialize k => BlockCipher k where

The BlockCipher class is intended as the generic interface targeted by maintainers of Haskell cipher implementations.

Minimum complete definition: blockSize, encryptBlock, decryptBlock, buildKey, and keyLength.

Instances must handle unaligned data

Methods

blockSize

Arguments

:: Tagged * k BitLength

The size of a single block; the smallest unit on which the cipher operates.

encryptBlock

Arguments

:: k 
-> ByteString 
-> ByteString

encrypt data of size n*blockSize where n elem [0..] (ecb encryption)

decryptBlock

Arguments

:: k 
-> ByteString 
-> ByteString

decrypt data of size n*blockSize where n elem [0..] (ecb decryption)

buildKey

Arguments

:: ByteString 
-> Maybe k

smart constructor for keys from a bytestring.

keyLength

Arguments

:: Tagged * k BitLength

length of the cryptographic key

ecb :: k -> ByteString -> ByteString

Electronic Cookbook (encryption)

unEcb :: k -> ByteString -> ByteString

Electronic Cookbook (decryption)

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

Cipherblock Chaining (encryption)

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

Cipherblock Chaining (decryption)

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

Counter (encryption)

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

Counter (decryption)

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

Counter (encryption)

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

Counter (decryption)

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

Ciphertext feedback (encryption)

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

Ciphertext feedback (decryption)

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

Output feedback (encryption)

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

Output feedback (decryption)

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

Cipher block chaining encryption for lazy bytestrings

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

Cipher block chaining decryption for lazy bytestrings

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

SIV (Synthetic IV) mode for lazy bytestrings. The third argument is the optional list of bytestrings to be authenticated but not encrypted As required by the specification this algorithm may return nothing when certain constraints aren't met.

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

SIV (Synthetic IV) for lazy bytestrings. The third argument is the optional list of bytestrings to be authenticated but not encrypted. As required by the specification this algorithm may return nothing when authentication fails.

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

SIV (Synthetic IV) mode for strict bytestrings. First argument is the optional list of bytestrings to be authenticated but not encrypted. As required by the specification this algorithm may return nothing when certain constraints aren't met.

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

SIV (Synthetic IV) for strict bytestrings First argument is the optional list of bytestrings to be authenticated but not encrypted As required by the specification this algorithm may return nothing when authentication fails.

ecbLazy :: k -> ByteString -> ByteString

Cook book mode - not really a mode at all. If you don't know what you're doing, don't use this mode^H^H^H^H library.

unEcbLazy :: k -> ByteString -> ByteString

ECB decrypt, complementary to ecb.

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

Ciphertext feed-back encryption mode for lazy bytestrings (with s == blockSize)

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

Ciphertext feed-back decryption mode for lazy bytestrings (with s == blockSize)

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

Output feedback mode for lazy bytestrings

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

Output feedback mode for lazy bytestrings

buildKeyIO :: BlockCipher k => IO k

Build a symmetric key using the system entropy (see Random)

zeroIV :: BlockCipher k => IV k

Obtain an IV made only of zeroes