crypton-0.34: Cryptography Primitives sink

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

Crypto.Error

Description

Synopsis

- 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
- throwCryptoError :: CryptoFailable a -> a
- onCryptoFailure :: (CryptoError -> r) -> (a -> r) -> CryptoFailable a -> r
- eitherCryptoError :: CryptoFailable a -> Either CryptoError a
- maybeCryptoError :: CryptoFailable a -> Maybe a

# Documentation

data CryptoError Source #

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 Source # |

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 Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CryptoError Source #

toConstr :: CryptoError -> Constr Source #

dataTypeOf :: CryptoError -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CryptoError) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CryptoError) Source #

gmapT :: (forall b. Data b => b -> b) -> CryptoError -> CryptoError Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CryptoError -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CryptoError -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> CryptoError -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CryptoError -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CryptoError -> m CryptoError Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CryptoError -> m CryptoError Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CryptoError -> m CryptoError Source #

Enum CryptoError Source # |

Instance details

Defined in Crypto.Error.Types

Methods

succ :: CryptoError -> CryptoError Source #

pred :: CryptoError -> CryptoError Source #

toEnum :: Int -> CryptoError Source #

fromEnum :: CryptoError -> Int Source #

enumFrom :: CryptoError -> [CryptoError] Source #

enumFromThen :: CryptoError -> CryptoError -> [CryptoError] Source #

enumFromTo :: CryptoError -> CryptoError -> [CryptoError] Source #

enumFromThenTo :: CryptoError -> CryptoError -> CryptoError -> [CryptoError] Source #

Exception CryptoError Source # |
Instance details Defined in Crypto.Error.Types Methods toException :: CryptoError -> SomeException Source # fromException :: SomeException -> Maybe CryptoError Source # displayException :: CryptoError -> String Source #
Show CryptoError Source # |
Instance details Defined in Crypto.Error.Types Methods showsPrec :: Int -> CryptoError -> ShowS Source # show :: CryptoError -> String Source # showList :: [CryptoError] -> ShowS Source #
Eq CryptoError Source # |
Instance details Defined in Crypto.Error.Types Methods (==) :: CryptoError -> CryptoError -> Bool Source # (/=) :: CryptoError -> CryptoError -> Bool Source #

data CryptoFailable a Source #

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 Source # |

Instance details

Defined in Crypto.Error.Types

Methods

pure :: a -> CryptoFailable a Source #

(<*>) :: CryptoFailable (a -> b) -> CryptoFailable a -> CryptoFailable b Source #

liftA2 :: (a -> b -> c) -> CryptoFailable a -> CryptoFailable b -> CryptoFailable c Source #

(*>) :: CryptoFailable a -> CryptoFailable b -> CryptoFailable b Source #

(<*) :: CryptoFailable a -> CryptoFailable b -> CryptoFailable a Source #

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

throwCryptoErrorIO :: CryptoFailable a -> IO a Source #

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

throwCryptoError :: CryptoFailable a -> a Source #

Same as `throwCryptoErrorIO` but throw the error asynchronously.

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

Simple `either` like combinator for CryptoFailable type

eitherCryptoError :: CryptoFailable a -> Either CryptoError a Source #

Transform a CryptoFailable to an Either

maybeCryptoError :: CryptoFailable a -> Maybe a Source #

Transform a CryptoFailable to a Maybe