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

Portabilitygood
Stabilitystable
MaintainerVincent Hanquez <vincent@snarc.org>
Safe HaskellNone

Crypto.Cipher.AES

Contents

Description

 

Synopsis

data types

data Key Source

AES Key

newtype IV Source

AES IV

Constructors

IV ByteString 

creation

initKey :: ByteString -> KeySource

initialize key

keyOfCtx :: Key -> ByteStringSource

return the user key from the Key context

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)