cipher-aes-0.1.2: Fast AES cipher implementation with advanced mode of operations

Safe HaskellNone

Crypto.Cipher.AES

Contents

Synopsis

data types

data Key Source

AES Key

newtype IV Source

AES IV

Constructors

IV ByteString 

creation

initKey :: ByteString -> KeySource

initialize key

misc

genCTRSource

Arguments

:: Key

Cipher Key.

-> IV

usually a 128 bit integer.

-> Int

length of bytes required.

-> ByteString 

generate a counter mode pad. this is generally xor-ed to an input to make the standard counter mode block operations.

if the length requested is not a multiple of the block cipher size, more data will be returned, so that the returned bytestring is a multiple of the block cipher size.

encryption

encryptECB :: Key -> ByteString -> ByteStringSource

encrypt using Electronic Code Book (ECB)

encryptCBC :: Key -> IV -> ByteString -> ByteStringSource

encrypt using Cipher Block Chaining (CBC)

encryptCTR :: Key -> IV -> ByteString -> ByteStringSource

encrypt using Counter mode (CTR)

in CTR mode encryption and decryption is the same operation.

encryptXTS :: (Key, Key) -> IV -> Word32 -> ByteString -> ByteStringSource

encrypt using XTS

the first key is the normal block encryption key the second key is used for the initial block tweak

encryptGCMSource

Arguments

:: Key

Key

-> IV

initial vector

-> ByteString

data to authenticate (AAD)

-> ByteString

data to encrypt

-> (ByteString, ByteString)

ciphertext and tag

encrypt using Galois counter mode (GCM) return the encrypted bytestring and the tag associated

note: encrypted data is identical to CTR mode in GCM, however a tag is also computed.

decryption

decryptECB :: Key -> ByteString -> ByteStringSource

decrypt using Electronic Code Book (ECB)

decryptCBC :: Key -> IV -> ByteString -> ByteStringSource

decrypt using Cipher block chaining (CBC)

decryptCTR :: Key -> IV -> ByteString -> ByteStringSource

decrypt using Counter mode (CTR).

in CTR mode encryption and decryption is the same operation.

decryptXTS :: (Key, Key) -> IV -> Word32 -> ByteString -> ByteStringSource

decrypt using XTS

decryptGCM :: Key -> IV -> ByteString -> ByteString -> (ByteString, ByteString)Source

decrypt using Galois Counter Mode (GCM)