AES-0.2.0: Fast AES encryption/decryption for bytestringsSource codeContentsIndex
Codec.Crypto.AES.Monad
Description
An occasionally pure, monadic interface to AES
Synopsis
type AES s a = AEST (ST s) a
data Mode
= ECB
| CBC
| CFB
| OFB
| CTR
data Direction
= Encrypt
| Decrypt
class Cryptable a where
crypt :: a -> AES s a
runAEST :: MonadUnsafeIO m => Mode -> ByteString -> ByteString -> Direction -> AEST m a -> m (a, ByteString)
runAES :: Mode -> ByteString -> ByteString -> Direction -> (forall s. AES s a) -> (a, ByteString)
Documentation
type AES s a = AEST (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.

For OFB and CTR, Encrypt and Decrypt are the same operation. For CTR, the IV is the initial value of the counter.

Constructors
ECB
CBC
CFB
OFB
CTR
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
runAESTSource
:: MonadUnsafeIO m
=> ModeThe AES key - 16, 24 or 32 bytes
-> ByteStringThe IV, 16 bytes
-> ByteString
-> Direction
-> AEST m a
-> m (a, ByteString)
Run an AES computation
runAESSource
::
=> ModeThe AES key - 16, 24 or 32 bytes
-> ByteStringThe IV, 16 bytes
-> ByteString
-> Direction
-> forall s. AES s a
-> (a, ByteString)
Run an AES computation
Produced by Haddock version 2.6.0