File: Types.hs

package info (click to toggle)
haskell-crypto-api 0.13.3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 248 kB
  • sloc: haskell: 2,142; ansic: 10; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 1,190 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{-# 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 { initializationVector :: {-# UNPACK #-} !B.ByteString
               } deriving (Eq, Ord, 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 (Eq, Ord, Show, Read, Data, Typeable)

instance X.Exception BlockCipherError