    {-# LANGUAGE DeriveDataTypeable #-}
    -- |Type aliases used throughout the crypto-api modules.
    module Crypto.Types where

    import qualified Control.Exception      as X
    import           Data.Data
    import           Data.Typeable
    import           Data.ByteString        as B
    import           Data.ByteString.Lazy   as L

    -- |Initilization Vectors for BlockCipher implementations (IV k) are
    -- used for various modes and guarrenteed to be blockSize bits long.
    -- The common ways to obtain an IV are to generate one ('getIV' or
    -- 'getIVIO') or to use one provided with the ciphertext (using the
    -- 'Serialize' instance of IV).
    --
    -- 'zeroIV' also exists and is of particular use for starting 'ctr'
    -- mode with a fresh key.
    data IV k = IV { forall k. IV k -> ByteString
    initializationVector :: {-# UNPACK #-} !B.ByteString
                   } deriving (IV k -> IV k -> Bool
    (IV k -> IV k -> Bool) -> (IV k -> IV k -> Bool) -> Eq (IV k)
    forall k. IV k -> IV k -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: forall k. IV k -> IV k -> Bool
    == :: IV k -> IV k -> Bool
    $c/= :: forall k. IV k -> IV k -> Bool
    /= :: IV k -> IV k -> Bool
    Eq, Eq (IV k)
    Eq (IV k) =>
    (IV k -> IV k -> Ordering)
    -> (IV k -> IV k -> Bool)
    -> (IV k -> IV k -> Bool)
    -> (IV k -> IV k -> Bool)
    -> (IV k -> IV k -> Bool)
    -> (IV k -> IV k -> IV k)
    -> (IV k -> IV k -> IV k)
    -> Ord (IV k)
    IV k -> IV k -> Bool
    IV k -> IV k -> Ordering
    IV k -> IV k -> IV k
    forall k. Eq (IV k)
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    forall k. IV k -> IV k -> Bool
    forall k. IV k -> IV k -> Ordering
    forall k. IV k -> IV k -> IV k
    $ccompare :: forall k. IV k -> IV k -> Ordering
    compare :: IV k -> IV k -> Ordering
    $c< :: forall k. IV k -> IV k -> Bool
    < :: IV k -> IV k -> Bool
    $c<= :: forall k. IV k -> IV k -> Bool
    <= :: IV k -> IV k -> Bool
    $c> :: forall k. IV k -> IV k -> Bool
    > :: IV k -> IV k -> Bool
    $c>= :: forall k. IV k -> IV k -> Bool
    >= :: IV k -> IV k -> Bool
    $cmax :: forall k. IV k -> IV k -> IV k
    max :: IV k -> IV k -> IV k
    $cmin :: forall k. IV k -> IV k -> IV k
    min :: IV k -> IV k -> IV k
    Ord, Int -> IV k -> ShowS
    [IV k] -> ShowS
    IV k -> String
    (Int -> IV k -> ShowS)
    -> (IV k -> String) -> ([IV k] -> ShowS) -> Show (IV k)
    forall k. Int -> IV k -> ShowS
    forall k. [IV k] -> ShowS
    forall k. IV k -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: forall k. Int -> IV k -> ShowS
    showsPrec :: Int -> IV k -> ShowS
    $cshow :: forall k. IV k -> String
    show :: IV k -> String
    $cshowList :: forall k. [IV k] -> ShowS
    showList :: [IV k] -> ShowS
    Show)

    -- |The length of a field (usually a ByteString) in bits
    type BitLength = Int

    -- |The length fo a field in bytes.
    type ByteLength = Int

    data BlockCipherError = InputTooLong String
                          | AuthenticationFailed String
                          | Other String
      deriving (BlockCipherError -> BlockCipherError -> Bool
    (BlockCipherError -> BlockCipherError -> Bool)
    -> (BlockCipherError -> BlockCipherError -> Bool)
    -> Eq BlockCipherError
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: BlockCipherError -> BlockCipherError -> Bool
    == :: BlockCipherError -> BlockCipherError -> Bool
    $c/= :: BlockCipherError -> BlockCipherError -> Bool
    /= :: BlockCipherError -> BlockCipherError -> Bool
    Eq, Eq BlockCipherError
    Eq BlockCipherError =>
    (BlockCipherError -> BlockCipherError -> Ordering)
    -> (BlockCipherError -> BlockCipherError -> Bool)
    -> (BlockCipherError -> BlockCipherError -> Bool)
    -> (BlockCipherError -> BlockCipherError -> Bool)
    -> (BlockCipherError -> BlockCipherError -> Bool)
    -> (BlockCipherError -> BlockCipherError -> BlockCipherError)
    -> (BlockCipherError -> BlockCipherError -> BlockCipherError)
    -> Ord BlockCipherError
    BlockCipherError -> BlockCipherError -> Bool
    BlockCipherError -> BlockCipherError -> Ordering
    BlockCipherError -> BlockCipherError -> BlockCipherError
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: BlockCipherError -> BlockCipherError -> Ordering
    compare :: BlockCipherError -> BlockCipherError -> Ordering
    $c< :: BlockCipherError -> BlockCipherError -> Bool
    < :: BlockCipherError -> BlockCipherError -> Bool
    $c<= :: BlockCipherError -> BlockCipherError -> Bool
    <= :: BlockCipherError -> BlockCipherError -> Bool
    $c> :: BlockCipherError -> BlockCipherError -> Bool
    > :: BlockCipherError -> BlockCipherError -> Bool
    $c>= :: BlockCipherError -> BlockCipherError -> Bool
    >= :: BlockCipherError -> BlockCipherError -> Bool
    $cmax :: BlockCipherError -> BlockCipherError -> BlockCipherError
    max :: BlockCipherError -> BlockCipherError -> BlockCipherError
    $cmin :: BlockCipherError -> BlockCipherError -> BlockCipherError
    min :: BlockCipherError -> BlockCipherError -> BlockCipherError
    Ord, Int -> BlockCipherError -> ShowS
    [BlockCipherError] -> ShowS
    BlockCipherError -> String
    (Int -> BlockCipherError -> ShowS)
    -> (BlockCipherError -> String)
    -> ([BlockCipherError] -> ShowS)
    -> Show BlockCipherError
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> BlockCipherError -> ShowS
    showsPrec :: Int -> BlockCipherError -> ShowS
    $cshow :: BlockCipherError -> String
    show :: BlockCipherError -> String
    $cshowList :: [BlockCipherError] -> ShowS
    showList :: [BlockCipherError] -> ShowS
    Show, ReadPrec [BlockCipherError]
    ReadPrec BlockCipherError
    Int -> ReadS BlockCipherError
    ReadS [BlockCipherError]
    (Int -> ReadS BlockCipherError)
    -> ReadS [BlockCipherError]
    -> ReadPrec BlockCipherError
    -> ReadPrec [BlockCipherError]
    -> Read BlockCipherError
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS BlockCipherError
    readsPrec :: Int -> ReadS BlockCipherError
    $creadList :: ReadS [BlockCipherError]
    readList :: ReadS [BlockCipherError]
    $creadPrec :: ReadPrec BlockCipherError
    readPrec :: ReadPrec BlockCipherError
    $creadListPrec :: ReadPrec [BlockCipherError]
    readListPrec :: ReadPrec [BlockCipherError]
    Read, Typeable BlockCipherError
    Typeable BlockCipherError =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> BlockCipherError -> c BlockCipherError)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c BlockCipherError)
    -> (BlockCipherError -> Constr)
    -> (BlockCipherError -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c BlockCipherError))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c BlockCipherError))
    -> ((forall b. Data b => b -> b)
        -> BlockCipherError -> BlockCipherError)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> BlockCipherError -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> BlockCipherError -> r)
    -> (forall u.
        (forall d. Data d => d -> u) -> BlockCipherError -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> BlockCipherError -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d)
        -> BlockCipherError -> m BlockCipherError)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> BlockCipherError -> m BlockCipherError)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> BlockCipherError -> m BlockCipherError)
    -> Data BlockCipherError
    BlockCipherError -> Constr
    BlockCipherError -> DataType
    (forall b. Data b => b -> b)
    -> BlockCipherError -> BlockCipherError
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u.
    Int -> (forall d. Data d => d -> u) -> BlockCipherError -> u
    forall u. (forall d. Data d => d -> u) -> BlockCipherError -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BlockCipherError -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BlockCipherError -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> BlockCipherError -> m BlockCipherError
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> BlockCipherError -> m BlockCipherError
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BlockCipherError
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BlockCipherError -> c BlockCipherError
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BlockCipherError)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c BlockCipherError)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BlockCipherError -> c BlockCipherError
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> BlockCipherError -> c BlockCipherError
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BlockCipherError
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c BlockCipherError
    $ctoConstr :: BlockCipherError -> Constr
    toConstr :: BlockCipherError -> Constr
    $cdataTypeOf :: BlockCipherError -> DataType
    dataTypeOf :: BlockCipherError -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BlockCipherError)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c BlockCipherError)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c BlockCipherError)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c BlockCipherError)
    $cgmapT :: (forall b. Data b => b -> b)
    -> BlockCipherError -> BlockCipherError
    gmapT :: (forall b. Data b => b -> b)
    -> BlockCipherError -> BlockCipherError
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BlockCipherError -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> BlockCipherError -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BlockCipherError -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> BlockCipherError -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> BlockCipherError -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> BlockCipherError -> [u]
    $cgmapQi :: forall u.
    Int -> (forall d. Data d => d -> u) -> BlockCipherError -> u
    gmapQi :: forall u.
    Int -> (forall d. Data d => d -> u) -> BlockCipherError -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> BlockCipherError -> m BlockCipherError
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> BlockCipherError -> m BlockCipherError
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> BlockCipherError -> m BlockCipherError
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> BlockCipherError -> m BlockCipherError
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> BlockCipherError -> m BlockCipherError
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> BlockCipherError -> m BlockCipherError
    Data, Typeable)

    instance X.Exception BlockCipherError