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


-- | AES and common modes using AES-NI when available.
--   
--   Cipher-aes128 is an implementation of AES and common modes of
--   operation. It borrows Hanquez's C AES code (see 'cipher-aes') but is
--   unique due to including compile-time detection of NI compiler support,
--   a slightly more functional interface for GCM operations, exposure of
--   <a>Ptr</a> based operations via the .Internal module, and build-in
--   crypto-api support. Cipher-aes128 was originally developed as
--   "'cipher-aes' plus trampolines", which has since been adopted into
--   cipher-aes.
@package cipher-aes128
@version 0.7.0.6

module Crypto.Cipher.AES128.Internal
data AESKey128
AESKey128 :: !RawKey128 -> ForeignPtr AESKeyStruct -> AESKey128
[rawKey128] :: AESKey128 -> !RawKey128
[expandedKey128] :: AESKey128 -> ForeignPtr AESKeyStruct
data AESKey192
AESKey192 :: !RawKey192 -> ForeignPtr AESKeyStruct -> AESKey192
[rawKey192] :: AESKey192 -> !RawKey192
[expandedKey192] :: AESKey192 -> ForeignPtr AESKeyStruct
data AESKey256
AESKey256 :: !RawKey256 -> ForeignPtr AESKeyStruct -> AESKey256
[rawKey256] :: AESKey256 -> !RawKey256
[expandedKey256] :: AESKey256 -> ForeignPtr AESKeyStruct
data RawKey128
RKey128 :: {-# UNPACK #-} !Word64 -> RawKey128
[lowK128, highK128] :: RawKey128 -> {-# UNPACK #-} !Word64
data RawKey192
RKey192 :: {-# UNPACK #-} !Word64 -> RawKey192
[lowK192, midK192, highK192] :: RawKey192 -> {-# UNPACK #-} !Word64
data RawKey256
RKey256 :: {-# UNPACK #-} !Word64 -> RawKey256
[aK256, bK256, cK256, dK256] :: RawKey256 -> {-# UNPACK #-} !Word64
data GCM k
GCM :: GCMpc -> k -> ForeignPtr CTXStruct -> GCM k
[_gcmFP] :: GCM k -> GCMpc
[_keyFP] :: GCM k -> k
[_ctxFP2] :: GCM k -> ForeignPtr CTXStruct
data GCMpc
generateKey128 :: Ptr Word64 -> IO (Maybe AESKey128)
generateKey192 :: Ptr Word64 -> IO (Maybe AESKey192)
generateKey256 :: Ptr Word64 -> IO (Maybe AESKey256)
generateGCM :: GetExpanded k => k -> IO (GCM k)
precomputeGCMdata :: GetExpanded k => k -> GCMpc
encryptECB :: GetExpanded k => k -> Ptr Word8 -> Ptr Word8 -> Int -> IO ()
decryptECB :: GetExpanded k => k -> Ptr Word8 -> Ptr Word8 -> Int -> IO ()
encryptCTR :: GetExpanded k => k -> Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> Int -> IO ()
decryptCTR :: GetExpanded k => k -> Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> Int -> IO ()
encryptGCM :: GetExpanded k => k -> GCMpc -> Ptr Word8 -> Word32 -> Ptr Word8 -> Word32 -> Ptr Word8 -> Word32 -> Ptr Word8 -> Ptr Word8 -> IO ()
decryptGCM :: GetExpanded k => k -> GCMpc -> Ptr Word8 -> Word32 -> Ptr Word8 -> Word32 -> Ptr Word8 -> Word32 -> Ptr Word8 -> Ptr Word8 -> IO ()
cipherOnlyGCM :: GetExpanded k => GCM k -> Ptr Word8 -> Ptr Word8 -> Int -> IO ()
decipherOnlyGCM :: GetExpanded k => GCM k -> Ptr Word8 -> Ptr Word8 -> Int -> IO ()
finishGCM :: GetExpanded k => GCM k -> Ptr Word8 -> IO ()
aadGCM :: GetExpanded k => GCM k -> Ptr Word8 -> Int -> IO ()
class GetExpanded a
instance Crypto.Cipher.AES128.Internal.GetExpanded Crypto.Cipher.AES128.Internal.AESKey256
instance Crypto.Cipher.AES128.Internal.GetExpanded Crypto.Cipher.AES128.Internal.AESKey192
instance Crypto.Cipher.AES128.Internal.GetExpanded Crypto.Cipher.AES128.Internal.AESKey128

module Crypto.Cipher.AES128
data AESKey128
data AESKey192
data AESKey256

-- | The BlockCipher class is intended as the generic interface targeted by
--   maintainers of Haskell cipher implementations.
--   
--   Minimum complete definition: blockSize, encryptBlock, decryptBlock,
--   buildKey, and keyLength.
--   
--   Instances must handle unaligned data
class Serialize k => BlockCipher k
blockSize :: BlockCipher k => Tagged k BitLength
encryptBlock :: BlockCipher k => k -> ByteString -> ByteString
decryptBlock :: BlockCipher k => k -> ByteString -> ByteString
buildKey :: BlockCipher k => ByteString -> Maybe k
keyLength :: BlockCipher k => Tagged k BitLength

-- | Electronic Cookbook (encryption)
ecb :: BlockCipher k => k -> ByteString -> ByteString

-- | Electronic Cookbook (decryption)
unEcb :: BlockCipher k => k -> ByteString -> ByteString

-- | Cipherblock Chaining (encryption)
cbc :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Cipherblock Chaining (decryption)
unCbc :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Counter (encryption)
ctr :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Counter (decryption)
unCtr :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Counter (encryption)
ctrLazy :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Counter (decryption)
unCtrLazy :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Ciphertext feedback (encryption)
cfb :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Ciphertext feedback (decryption)
unCfb :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Output feedback (encryption)
ofb :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Output feedback (decryption)
unOfb :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Cipher block chaining encryption for lazy bytestrings
cbcLazy :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Cipher block chaining decryption for lazy bytestrings
unCbcLazy :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | SIV (Synthetic IV) mode for lazy bytestrings. The third argument is
--   the optional list of bytestrings to be authenticated but not encrypted
--   As required by the specification this algorithm may return nothing
--   when certain constraints aren't met.
sivLazy :: BlockCipher k => k -> k -> [ByteString] -> ByteString -> Maybe ByteString

-- | SIV (Synthetic IV) for lazy bytestrings. The third argument is the
--   optional list of bytestrings to be authenticated but not encrypted. As
--   required by the specification this algorithm may return nothing when
--   authentication fails.
unSivLazy :: BlockCipher k => k -> k -> [ByteString] -> ByteString -> Maybe ByteString

-- | SIV (Synthetic IV) mode for strict bytestrings. First argument is the
--   optional list of bytestrings to be authenticated but not encrypted. As
--   required by the specification this algorithm may return nothing when
--   certain constraints aren't met.
siv :: BlockCipher k => k -> k -> [ByteString] -> ByteString -> Maybe ByteString

-- | SIV (Synthetic IV) for strict bytestrings First argument is the
--   optional list of bytestrings to be authenticated but not encrypted As
--   required by the specification this algorithm may return nothing when
--   authentication fails.
unSiv :: BlockCipher k => k -> k -> [ByteString] -> ByteString -> Maybe ByteString

-- | Cook book mode - not really a mode at all. If you don't know what
--   you're doing, don't use this mode^H^H^H^H library.
ecbLazy :: BlockCipher k => k -> ByteString -> ByteString

-- | ECB decrypt, complementary to <a>ecb</a>.
unEcbLazy :: BlockCipher k => k -> ByteString -> ByteString

-- | Ciphertext feed-back encryption mode for lazy bytestrings (with s ==
--   blockSize)
cfbLazy :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Ciphertext feed-back decryption mode for lazy bytestrings (with s ==
--   blockSize)
unCfbLazy :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Output feedback mode for lazy bytestrings
ofbLazy :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Output feedback mode for lazy bytestrings
unOfbLazy :: BlockCipher k => k -> IV k -> ByteString -> (ByteString, IV k)

-- | Build a symmetric key using the system entropy (see <a>Entropy</a>)
buildKeyIO :: BlockCipher k => IO k

-- | Obtain an <a>IV</a> made only of zeroes
zeroIV :: BlockCipher k => IV k

-- | Given key material produce a context useful for GCM operations
makeGCMCtx :: AES_GCM k => ByteString -> Maybe (GCMCtx k)

-- | Given an AESKey produce a GCM Context.
aesKeyToGCM :: AES_GCM k => k -> GCMCtx k

-- | A tuple of key and precomputed data for use by GCM
data GCMCtx k
data AuthTag
AuthTag :: ByteString -> AuthTag
[unAuthTag] :: AuthTag -> ByteString
class (BlockCipher k, GetExpanded k) => AES_GCM k

-- | Encrypts multiple-of-block-sized input, returning a bytestring and
--   tag.
encryptGCM :: AES_GCM k => GCMCtx k -> ByteString -> ByteString -> ByteString -> (ByteString, AuthTag)

-- | Decrypts multiple-of-block-sized input, returing a bytestring of the
--   [ctr, ct, tag].
decryptGCM :: AES_GCM k => GCMCtx k -> ByteString -> ByteString -> ByteString -> (ByteString, AuthTag)
instance Crypto.Cipher.AES128.AES_GCM Crypto.Cipher.AES128.Internal.AESKey128
instance Crypto.Cipher.AES128.AES_GCM Crypto.Cipher.AES128.Internal.AESKey192
instance Crypto.Cipher.AES128.AES_GCM Crypto.Cipher.AES128.Internal.AESKey256
instance GHC.Classes.Eq Crypto.Cipher.AES128.AuthTag
instance Data.Serialize.Serialize Crypto.Cipher.AES128.Internal.AESKey128
instance Data.Serialize.Serialize Crypto.Cipher.AES128.Internal.AESKey192
instance Data.Serialize.Serialize Crypto.Cipher.AES128.Internal.AESKey256
instance Crypto.Classes.BlockCipher Crypto.Cipher.AES128.Internal.AESKey128
instance Crypto.Classes.BlockCipher Crypto.Cipher.AES128.Internal.AESKey192
instance Crypto.Classes.BlockCipher Crypto.Cipher.AES128.Internal.AESKey256
