-- |
-- Module      : Crypto.PubKey.RSA.Types
-- License     : BSD-style
-- Maintainer  : Vincent Hanquez <vincent@snarc.org>
-- Stability   : experimental
-- Portability : Good
--
module Crypto.PubKey.RSA.Types
    ( Error(..)
    , Blinder(..)
    ) where

-- | Blinder which is used to obfuscate the timing
-- of the decryption primitive (used by decryption and signing).
data Blinder = Blinder !Integer !Integer
             deriving (Int -> Blinder -> ShowS
[Blinder] -> ShowS
Blinder -> String
(Int -> Blinder -> ShowS)
-> (Blinder -> String) -> ([Blinder] -> ShowS) -> Show Blinder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Blinder] -> ShowS
$cshowList :: [Blinder] -> ShowS
show :: Blinder -> String
$cshow :: Blinder -> String
showsPrec :: Int -> Blinder -> ShowS
$cshowsPrec :: Int -> Blinder -> ShowS
Show,Blinder -> Blinder -> Bool
(Blinder -> Blinder -> Bool)
-> (Blinder -> Blinder -> Bool) -> Eq Blinder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Blinder -> Blinder -> Bool
$c/= :: Blinder -> Blinder -> Bool
== :: Blinder -> Blinder -> Bool
$c== :: Blinder -> Blinder -> Bool
Eq)

-- | error possible during encryption, decryption or signing.
data Error =
      MessageSizeIncorrect -- ^ the message to decrypt is not of the correct size (need to be == private_size)
    | MessageTooLong       -- ^ the message to encrypt is too long
    | MessageNotRecognized -- ^ the message decrypted doesn't have a PKCS15 structure (0 2 .. 0 msg)
    | SignatureTooLong     -- ^ the message's digest is too long
    | InvalidParameters    -- ^ some parameters lead to breaking assumptions.
    deriving (Int -> Error -> ShowS
[Error] -> ShowS
Error -> String
(Int -> Error -> ShowS)
-> (Error -> String) -> ([Error] -> ShowS) -> Show Error
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Error] -> ShowS
$cshowList :: [Error] -> ShowS
show :: Error -> String
$cshow :: Error -> String
showsPrec :: Int -> Error -> ShowS
$cshowsPrec :: Int -> Error -> ShowS
Show,Error -> Error -> Bool
(Error -> Error -> Bool) -> (Error -> Error -> Bool) -> Eq Error
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Error -> Error -> Bool
$c/= :: Error -> Error -> Bool
== :: Error -> Error -> Bool
$c== :: Error -> Error -> Bool
Eq)