Crypto.Error

crypton-1.0.0: Cryptography Primitives sink

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | Stable
Portability | Excellent
Safe Haskell | None
Language | Haskell2010

Crypto.Error

Description

Synopsis

- throwCryptoError :: CryptoFailable a -> a
- data CryptoError
  - = CryptoError_KeySizeInvalid
  - | CryptoError_IvSizeInvalid
  - | CryptoError_SeedSizeInvalid
  - | CryptoError_AEADModeNotSupported
  - | CryptoError_SecretKeySizeInvalid
  - | CryptoError_SecretKeyStructureInvalid
  - | CryptoError_PublicKeySizeInvalid
  - | CryptoError_SharedSecretSizeInvalid
  - | CryptoError_EcScalarOutOfBounds
  - | CryptoError_PointSizeInvalid
  - | CryptoError_PointFormatInvalid
  - | CryptoError_PointFormatUnsupported
  - | CryptoError_PointCoordinatesInvalid
  - | CryptoError_ScalarMultiplicationInvalid
  - | CryptoError_MacKeyInvalid
  - | CryptoError_AuthenticationTagSizeInvalid
  - | CryptoError_PrimeSizeInvalid
  - | CryptoError_SaltTooSmall
  - | CryptoError_OutputLengthTooSmall
  - | CryptoError_OutputLengthTooBig
- data CryptoFailable a
  - = CryptoPassed a
  - | CryptoFailed CryptoError
- throwCryptoErrorIO :: CryptoFailable a -> IO a
- onCryptoFailure :: (CryptoError -> r) -> (a -> r) -> CryptoFailable a -> r
- eitherCryptoError :: CryptoFailable a -> Either CryptoError a
- maybeCryptoError :: CryptoFailable a -> Maybe a

# Documentation

throwCryptoError :: CryptoFailable a -> a #

Same as `throwCryptoErrorIO` but throw the error asynchronously.

data CryptoError #

Enumeration of all possible errors that can be found in this library

Constructors

CryptoError_KeySizeInvalid |
CryptoError_IvSizeInvalid |
CryptoError_SeedSizeInvalid |
CryptoError_AEADModeNotSupported |
CryptoError_SecretKeySizeInvalid |
CryptoError_SecretKeyStructureInvalid |
CryptoError_PublicKeySizeInvalid |
CryptoError_SharedSecretSizeInvalid |
CryptoError_EcScalarOutOfBounds |
CryptoError_PointSizeInvalid |
CryptoError_PointFormatInvalid |
CryptoError_PointFormatUnsupported |
CryptoError_PointCoordinatesInvalid |
CryptoError_ScalarMultiplicationInvalid |
CryptoError_MacKeyInvalid |
CryptoError_AuthenticationTagSizeInvalid |
CryptoError_PrimeSizeInvalid |
CryptoError_SaltTooSmall |
CryptoError_OutputLengthTooSmall |
CryptoError_OutputLengthTooBig |

#### Instances

Instances details

Data CryptoError # |
Instance details Defined in Crypto.Error.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CryptoError -> c CryptoError # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CryptoError # toConstr :: CryptoError -> Constr # dataTypeOf :: CryptoError -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CryptoError) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CryptoError) # gmapT :: (forall b. Data b => b -> b) -> CryptoError -> CryptoError # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CryptoError -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CryptoError -> r # gmapQ :: (forall d. Data d => d -> u) -> CryptoError -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> CryptoError -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> CryptoError -> m CryptoError # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CryptoError -> m CryptoError # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CryptoError -> m CryptoError #
Enum CryptoError # |
Instance details Defined in Crypto.Error.Types Methods succ :: CryptoError -> CryptoError # pred :: CryptoError -> CryptoError # toEnum :: Int -> CryptoError # fromEnum :: CryptoError -> Int # enumFrom :: CryptoError -> [CryptoError] # enumFromThen :: CryptoError -> CryptoError -> [CryptoError] # enumFromTo :: CryptoError -> CryptoError -> [CryptoError] # enumFromThenTo :: CryptoError -> CryptoError -> CryptoError -> [CryptoError] #
Exception CryptoError # |
Instance details Defined in Crypto.Error.Types Methods toException :: CryptoError -> SomeException # fromException :: SomeException -> Maybe CryptoError # displayException :: CryptoError -> String #
Show CryptoError # |
Instance details Defined in Crypto.Error.Types Methods showsPrec :: Int -> CryptoError -> ShowS # show :: CryptoError -> String # showList :: [CryptoError] -> ShowS #
Eq CryptoError # |
Instance details Defined in Crypto.Error.Types Methods (==) :: CryptoError -> CryptoError -> Bool # (/=) :: CryptoError -> CryptoError -> Bool #

data CryptoFailable a #

A simple Either like type to represent a computation that can fail

2 possibles values are:

- `CryptoPassed` : The computation succeeded, and contains the result of the computation
- `CryptoFailed` : The computation failed, and contains the cryptographic error associated

Constructors

CryptoPassed a |
CryptoFailed CryptoError |

#### Instances

Instances details

Applicative CryptoFailable # |
Instance details Defined in Crypto.Error.Types Methods pure :: a -> CryptoFailable a # (<*>) :: CryptoFailable (a -> b) -> CryptoFailable a -> CryptoFailable b # liftA2 :: (a -> b -> c) -> CryptoFailable a -> CryptoFailable b -> CryptoFailable c # (*>) :: CryptoFailable a -> CryptoFailable b -> CryptoFailable b # (<*) :: CryptoFailable a -> CryptoFailable b -> CryptoFailable a #
Functor CryptoFailable # |
Instance details Defined in Crypto.Error.Types Methods fmap :: (a -> b) -> CryptoFailable a -> CryptoFailable b # (<$) :: a -> CryptoFailable b -> CryptoFailable a #
Monad CryptoFailable # |
Instance details Defined in Crypto.Error.Types Methods (>>=) :: CryptoFailable a -> (a -> CryptoFailable b) -> CryptoFailable b # (>>) :: CryptoFailable a -> CryptoFailable b -> CryptoFailable b # return :: a -> CryptoFailable a #
MonadFailure CryptoFailable # |
Instance details Defined in Crypto.Error.Types Associated Types
type Failure CryptoFailable |
Instance details Defined in Crypto.Error.Types type Failure CryptoFailable = CryptoError
Methods mFail :: Failure CryptoFailable -> CryptoFailable () #
Show a => Show (CryptoFailable a) # |
Instance details Defined in Crypto.Error.Types Methods showsPrec :: Int -> CryptoFailable a -> ShowS # show :: CryptoFailable a -> String # showList :: [CryptoFailable a] -> ShowS #
Eq a => Eq (CryptoFailable a) # |
Instance details Defined in Crypto.Error.Types Methods (==) :: CryptoFailable a -> CryptoFailable a -> Bool # (/=) :: CryptoFailable a -> CryptoFailable a -> Bool #
type Failure CryptoFailable # |
Instance details Defined in Crypto.Error.Types type Failure CryptoFailable = CryptoError

throwCryptoErrorIO :: CryptoFailable a -> IO a #

Throw an CryptoError as exception on CryptoFailed result, otherwise return the computed value

onCryptoFailure :: (CryptoError -> r) -> (a -> r) -> CryptoFailable a -> r #

Simple `either` like combinator for CryptoFailable type

eitherCryptoError :: CryptoFailable a -> Either CryptoError a #

Transform a CryptoFailable to an Either

maybeCryptoError :: CryptoFailable a -> Maybe a #

Transform a CryptoFailable to a Maybe