License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Stability | stable |
Portability | good |
Safe Haskell | None |
Language | Haskell98 |
Crypto.Cipher.AES
Description
Synopsis
- data AES
- data AES128
- data AES192
- data AES256
- data AESIV
- aesIV_ :: ByteString -> AESIV
- data AESGCM
- initAES :: Byteable b => b -> AES
- initKey :: Byteable b => b -> AES
- genCTR :: Byteable iv => AES -> iv -> Int -> ByteString
- genCounter :: AES -> AESIV -> Int -> (ByteString, AESIV)
- 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)
- encryptOCB :: 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)
- decryptOCB :: Byteable iv => AES -> iv -> ByteString -> ByteString -> (ByteString, AuthTag)
block cipher data types
AES Context (pre-processed key)
Instances
AES with 128 bit key
Instances
AES with 192 bit key
Instances
AES with 256 bit key
Instances
IV
AES IV is always 16 bytes
Authenticated encryption block cipher types
AESGCM State
Instances
creation
initAES :: Byteable b => b -> AES Source #
Initialize a new context with a key
Key need to be of length 16, 24 or 32 bytes. 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.
genCounter :: AES -> AESIV -> Int -> (ByteString, AESIV) Source #
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.
Similiar to genCTR
but also return the next IV for continuation
encryption
encryptECB :: AES -> ByteString -> ByteString Source #
encrypt using Electronic Code Book (ECB)
Arguments
:: Byteable iv | |
=> AES | AES Context |
-> iv | Initial vector of AES block size |
-> ByteString | plaintext |
-> ByteString | ciphertext |
encrypt using Cipher Block Chaining (CBC)
Arguments
:: Byteable iv | |
=> AES | AES Context |
-> iv | initial vector of AES block size (usually representing a 128 bit integer) |
-> ByteString | plaintext input |
-> ByteString | ciphertext output |
encrypt using Counter mode (CTR)
in CTR mode encryption and decryption is the same operation.
Arguments
:: Byteable iv | |
=> (AES, AES) | AES cipher and tweak context |
-> iv | a 128 bits IV, typically a sector or a block offset in XTS |
-> Word32 | number of rounds to skip, also seen a 16 byte offset in the sector or block. |
-> ByteString | input to encrypt |
-> ByteString | output encrypted |
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 | AES Context |
-> iv | IV initial vector of any size |
-> 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.
Arguments
:: Byteable iv | |
=> AES | AES Context |
-> iv | IV initial vector of any size |
-> ByteString | data to authenticate (AAD) |
-> ByteString | data to encrypt |
-> (ByteString, AuthTag) | ciphertext and tag |
encrypt using OCB v3 return the encrypted bytestring and the tag associated
decryption
decryptECB :: AES -> ByteString -> ByteString Source #
decrypt using Electronic Code Book (ECB)
decryptCBC :: Byteable iv => AES -> iv -> ByteString -> ByteString Source #
decrypt using Cipher block chaining (CBC)
Arguments
:: Byteable iv | |
=> AES | AES Context |
-> iv | initial vector, usually representing a 128 bit integer |
-> ByteString | ciphertext input |
-> ByteString | plaintext output |
decrypt using Counter mode (CTR).
in CTR mode encryption and decryption is the same operation.
Arguments
:: Byteable iv | |
=> (AES, AES) | AES cipher and tweak context |
-> iv | a 128 bits IV, typically a sector or a block offset in XTS |
-> Word32 | number of rounds to skip, also seen a 16 byte offset in the sector or block. |
-> ByteString | input to decrypt |
-> ByteString | output decrypted |
decrypt using XTS