AES-0.0.1: Fast AES encryption/decryption for bytestringsSource codeContentsIndex
Codec.Crypto.AES.ST
Description
A pure interface to AES, in the lazy ST monad.
Synopsis
type AES s a = ReaderT AESCtx (WriterT ByteString (ST s)) a
data Mode
= ECB
| CBC
| CFB
data Direction
= Encrypt
| Decrypt
class Cryptable a where
crypt :: a -> AES s a
execAES :: Mode -> ByteString -> ByteString -> Direction -> (forall s. AES s a) -> ByteString
runAES :: Mode -> ByteString -> ByteString -> Direction -> (forall s. AES s a) -> (a, ByteString)
liftST :: ST s a -> AES s a
Documentation
type AES s a = ReaderT AESCtx (WriterT ByteString (ST s)) aSource
data Mode Source

Modes ECB and CBC can only handle full 16-byte frames. This means the length of every strict bytestring passed in must be a multiple of 16; when using lazy bytestrings, its component strict bytestrings must all satisfy this.

Other modes can handle bytestrings of any length, by storing overflow for later. However, the total length of bytestrings passed in must still be a multiple of 16, or the overflow will be lost.

In addition to the existing modes, a small amount of extra code could add support for CTR

Constructors
ECB
CBC
CFB
data Direction Source
Constructors
Encrypt
Decrypt
class Cryptable a whereSource

A class of things that can be crypted

The crypt function returns incremental results as well as appending them to the result bytestring.

Methods
crypt :: a -> AES s aSource
show/hide Instances
execAESSource
:: Mode
-> ByteStringThe AES key - 16, 24 or 32 bytes
-> ByteStringThe IV, 16 bytes
-> Direction
-> (forall s. AES s a)
-> ByteString
Compute an AES computation, discarding the ST return value
runAESSource
:: Mode
-> ByteStringThe AES key - 16, 24 or 32 bytes
-> ByteStringThe IV, 16 bytes
-> Direction
-> (forall s. AES s a)
-> (a, ByteString)
Compute an AES computation, returning the ST return value along with the crypted data
liftST :: ST s a -> AES s aSource
Before you use this, recall that AES uses the lazy ST monad.
Produced by Haddock version 2.7.2