-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Fast AES cipher implementation with advanced mode of operations
--   
--   Fast AES cipher implementation with advanced mode of operations.
--   
--   The modes of operations available are ECB (Electronic code book), CBC
--   (Cipher block chaining), CTR (Counter), XTS (XEX with ciphertext
--   stealing), GCM (Galois Counter Mode).
--   
--   The AES implementation uses AES-NI when available (on x86 and x86-64
--   architecture), but fallback gracefully to a software C implementation.
--   
--   The software implementation uses S-Boxes, which might suffer for cache
--   timing issues. However do notes that most other known software
--   implementations, including very popular one (openssl, gnutls) also
--   uses same implementation. If it matters for your case, you should make
--   sure you have AES-NI available, or you'll need to use a different
--   implementation.
@package cipher-aes
@version 0.1.8


module Crypto.Cipher.AES

-- | AES Key
data Key

-- | AES IV
newtype IV
IV :: ByteString -> IV

-- | initialize key
initKey :: ByteString -> Key

-- | return the user key from the Key context
keyOfCtx :: Key -> 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.
genCTR :: Key -> IV -> Int -> ByteString

-- | encrypt using Electronic Code Book (ECB)
encryptECB :: Key -> ByteString -> ByteString

-- | encrypt using Cipher Block Chaining (CBC)
encryptCBC :: Key -> IV -> ByteString -> ByteString

-- | encrypt using Counter mode (CTR)
--   
--   in CTR mode encryption and decryption is the same operation.
encryptCTR :: Key -> IV -> ByteString -> ByteString

-- | encrypt using XTS
--   
--   the first key is the normal block encryption key the second key is
--   used for the initial block tweak
encryptXTS :: (Key, Key) -> IV -> Word32 -> ByteString -> ByteString

-- | 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.
encryptGCM :: Key -> IV -> ByteString -> ByteString -> (ByteString, ByteString)

-- | decrypt using Electronic Code Book (ECB)
decryptECB :: Key -> ByteString -> ByteString

-- | decrypt using Cipher block chaining (CBC)
decryptCBC :: Key -> IV -> ByteString -> ByteString

-- | decrypt using Counter mode (CTR).
--   
--   in CTR mode encryption and decryption is the same operation.
decryptCTR :: Key -> IV -> ByteString -> ByteString

-- | decrypt using XTS
decryptXTS :: (Key, Key) -> IV -> Word32 -> ByteString -> ByteString

-- | decrypt using Galois Counter Mode (GCM)
decryptGCM :: Key -> IV -> ByteString -> ByteString -> (ByteString, ByteString)
instance Storable GCM
