| Portability | good |
|---|---|
| Stability | stable |
| Maintainer | Vincent Hanquez <vincent@snarc.org> |
| Safe Haskell | None |
Crypto.Cipher.AES
Contents
Description
- data AES
- data AES128
- data AES192
- data AES256
- initAES :: Byteable b => b -> AES
- initKey :: Byteable b => b -> AES
- genCTR :: Byteable iv => AES -> iv -> Int -> ByteString
- encryptECB :: AES -> ByteString -> ByteString
- encryptCBC :: Byteable iv => AES -> iv -> ByteString -> ByteString
- encryptCTR :: Byteable iv => AES -> iv -> ByteString -> ByteString
- encryptXTS :: Byteable iv => (AES, AES) -> iv -> Word32 -> ByteString -> ByteString
- encryptGCM :: Byteable iv => AES -> iv -> ByteString -> ByteString -> (ByteString, AuthTag)
- decryptECB :: AES -> ByteString -> ByteString
- decryptCBC :: Byteable iv => AES -> iv -> ByteString -> ByteString
- decryptCTR :: Byteable iv => AES -> iv -> ByteString -> ByteString
- decryptXTS :: Byteable iv => (AES, AES) -> iv -> Word32 -> ByteString -> ByteString
- decryptGCM :: Byteable iv => AES -> iv -> ByteString -> ByteString -> (ByteString, AuthTag)
data types
creation
initAES :: Byteable b => b -> AESSource
initialize key
rounds need to be 10 12 14. any other values will cause undefined behavior
misc
Arguments
| :: Byteable iv | |
| => AES | 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 :: AES -> ByteString -> ByteStringSource
encrypt using Electronic Code Book (ECB)
encryptCBC :: Byteable iv => AES -> iv -> ByteString -> ByteStringSource
encrypt using Cipher Block Chaining (CBC)
encryptCTR :: Byteable iv => AES -> iv -> ByteString -> ByteStringSource
encrypt using Counter mode (CTR)
in CTR mode encryption and decryption is the same operation.
encryptXTS :: Byteable iv => (AES, AES) -> 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
Arguments
| :: Byteable iv | |
| => AES | Key |
| -> iv | initial vector |
| -> ByteString | data to authenticate (AAD) |
| -> ByteString | data to encrypt |
| -> (ByteString, AuthTag) | 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 :: AES -> ByteString -> ByteStringSource
decrypt using Electronic Code Book (ECB)
decryptCBC :: Byteable iv => AES -> iv -> ByteString -> ByteStringSource
decrypt using Cipher block chaining (CBC)
decryptCTR :: Byteable iv => AES -> iv -> ByteString -> ByteStringSource
decrypt using Counter mode (CTR).
in CTR mode encryption and decryption is the same operation.
decryptXTS :: Byteable iv => (AES, AES) -> iv -> Word32 -> ByteString -> ByteStringSource
decrypt using XTS
decryptGCM :: Byteable iv => AES -> iv -> ByteString -> ByteString -> (ByteString, AuthTag)Source
decrypt using Galois Counter Mode (GCM)