A pure interface to AES
- data Mode
- data Direction
- type Key = ByteString
- type IV = ByteString
- newIV :: IO IV
- randomKey :: IO Key
- crypt :: Mode -> Key -> IV -> Direction -> ByteString -> ByteString
- encryptMsg :: Mode -> Key -> ByteString -> IO ByteString
- encryptMsg' :: Mode -> Key -> IV -> ByteString -> ByteString
- decryptMsg :: Mode -> Key -> ByteString -> ByteString
- decryptMsg' :: Mode -> Key -> ByteString -> Either String ByteString
Documentation
type Key = ByteStringSource
type IV = ByteStringSource
:: Mode | |
-> Key | The AES key - 16, 24 or 32 bytes |
-> IV | |
-> Direction | |
-> ByteString | Bytestring to encrypt/decrypt |
-> ByteString |
Encryption/decryption for lazy bytestrings. The input string is zero-padded to a multiple of 16. It is your obligation to separate encode the length of the string.
Properties: x == y => crypt mode key iv dir x == crypt mode key iv dir y take (length x) (crypt mode key iv Decrypt (crypt mode key iv Encrypt x)) == x
encryptMsg :: Mode -> Key -> ByteString -> IO ByteStringSource
Encrypt a bytestring using a random seed (IV). Since the seed is random, this function is tainted by IO.
encryptMsg' :: Mode -> Key -> IV -> ByteString -> ByteStringSource
Encrypt a ByteString using a given seed (IV). The resulting ByteString contains both the seed and the original length of the input (before padding).
decryptMsg :: Mode -> Key -> ByteString -> ByteStringSource
decryptMsg' :: Mode -> Key -> ByteString -> Either String ByteStringSource