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


-- | Symmetrical block and stream ciphers.
--   
--   Symmetrical block and stream ciphers.
@package cryptocipher
@version 0.6.2


-- | All the cipher functionalities are available through the BlockCipher
--   and StreamCipher classes.
--   
--   A simplified example (with simplified error handling):
--   
--   <pre>
--   import Crypto.Cipher
--   import Data.ByteString (ByteString)
--   import qualified Data.ByteString as B
--   
--   initAES256 :: ByteString -&gt; AES256
--   initAES256 = either (error . show) cipherInit . makeKey
--   
--   cbcEncryption :: AES256 -&gt; ByteString -&gt; ByteString -&gt; ByteString
--   cbcEncryption ctx ivRaw plainText = cbcEncrypt ctx iv plainText
--     where iv = maybe (error "invalid IV") id $ ivRaw
--   </pre>
module Crypto.Cipher

-- | Symmetric cipher class.
class Cipher cipher
cipherInit :: Cipher cipher => Key cipher -> cipher
cipherName :: Cipher cipher => cipher -> String
cipherKeySize :: Cipher cipher => cipher -> KeySizeSpecifier

-- | Symmetric block cipher class
class Cipher cipher => BlockCipher cipher
blockSize :: BlockCipher cipher => cipher -> Int
ecbEncrypt :: BlockCipher cipher => cipher -> ByteString -> ByteString
ecbDecrypt :: BlockCipher cipher => cipher -> ByteString -> ByteString
cbcEncrypt :: BlockCipher cipher => cipher -> IV cipher -> ByteString -> ByteString
cbcDecrypt :: BlockCipher cipher => cipher -> IV cipher -> ByteString -> ByteString
cfbEncrypt :: BlockCipher cipher => cipher -> IV cipher -> ByteString -> ByteString
cfbDecrypt :: BlockCipher cipher => cipher -> IV cipher -> ByteString -> ByteString
ctrCombine :: BlockCipher cipher => cipher -> IV cipher -> ByteString -> ByteString
xtsEncrypt :: BlockCipher cipher => (cipher, cipher) -> IV cipher -> DataUnitOffset -> ByteString -> ByteString
xtsDecrypt :: BlockCipher cipher => (cipher, cipher) -> IV cipher -> DataUnitOffset -> ByteString -> ByteString
aeadInit :: (BlockCipher cipher, Byteable iv) => AEADMode -> cipher -> iv -> Maybe (AEAD cipher)

-- | Symmetric stream cipher class
class Cipher cipher => StreamCipher cipher
streamCombine :: StreamCipher cipher => cipher -> ByteString -> (ByteString, cipher)

-- | a Key parametrized by the cipher
data Key c :: * -> *

-- | Create a Key for a specified cipher
makeKey :: (ToSecureMem b, Cipher c) => b -> Either KeyError (Key c)

-- | an IV parametrized by the cipher
data IV c :: * -> *

-- | Create an IV for a specified block cipher
makeIV :: (Byteable b, BlockCipher c) => b -> Maybe (IV c)

-- | Create an IV that is effectively representing the number 0
nullIV :: BlockCipher c => IV c

-- | Increment an IV by a number.
--   
--   Assume the IV is in Big Endian format.
ivAdd :: BlockCipher c => IV c -> Int -> IV c

-- | Authenticated Encryption with Associated Data algorithms
data AEAD cipher :: * -> *

-- | Append associated data into the AEAD state
aeadAppendHeader :: BlockCipher a => AEAD a -> ByteString -> AEAD a

-- | Encrypt input and append into the AEAD state
aeadEncrypt :: BlockCipher a => AEAD a -> ByteString -> (ByteString, AEAD a)

-- | Decrypt input and append into the AEAD state
aeadDecrypt :: BlockCipher a => AEAD a -> ByteString -> (ByteString, AEAD a)

-- | Finalize the AEAD state and create an authentification tag
aeadFinalize :: BlockCipher a => AEAD a -> Int -> AuthTag

-- | AES with 128 bit key
data AES128 :: *

-- | AES with 192 bit key
data AES192 :: *

-- | AES with 256 bit key
data AES256 :: *

-- | variable keyed blowfish state
data Blowfish :: *

-- | 64 bit keyed blowfish state
data Blowfish64 :: *

-- | 128 bit keyed blowfish state
data Blowfish128 :: *

-- | 256 bit keyed blowfish state
data Blowfish256 :: *

-- | 448 bit keyed blowfish state
data Blowfish448 :: *

-- | DES Context
data DES :: *

-- | 3DES with 3 different keys used all in the same direction
data DES_EEE3 :: *

-- | 3DES with 3 different keys used in alternative direction
data DES_EDE3 :: *

-- | 3DES where the first and third keys are equal, used in the same
--   direction
data DES_EEE2 :: *

-- | 3DES where the first and third keys are equal, used in alternative
--   direction
data DES_EDE2 :: *

-- | Camellia block cipher with 128 bit key
data Camellia128 :: *
