cryptonite-0.23: Cryptography Primitives sink

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

Crypto.Error

Description

Synopsis

- data CryptoError
  - = CryptoError_KeySizeInvalid
  - | CryptoError_IvSizeInvalid
  - | CryptoError_AEADModeNotSupported
  - | CryptoError_SecretKeySizeInvalid
  - | CryptoError_SecretKeyStructureInvalid
  - | CryptoError_PublicKeySizeInvalid
  - | CryptoError_SharedSecretSizeInvalid
  - | CryptoError_EcScalarOutOfBounds
  - | CryptoError_PointSizeInvalid
  - | CryptoError_PointFormatInvalid
  - | CryptoError_PointFormatUnsupported
  - | CryptoError_PointCoordinatesInvalid
  - | 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 #

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

Constructors

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

Instances

Enum CryptoError # |
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] #
Eq CryptoError # |
Methods (==) :: CryptoError -> CryptoError -> Bool # (/=) :: CryptoError -> CryptoError -> Bool #
Data CryptoError # |
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 :: (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 #
Show CryptoError # |
Methods showsPrec :: Int -> CryptoError -> ShowS # show :: CryptoError -> String # showList :: [CryptoError] -> ShowS #
Exception CryptoError # |
Methods toException :: CryptoError -> SomeException # fromException :: SomeException -> Maybe CryptoError # displayException :: CryptoError -> String #

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

Monad CryptoFailable # |
Methods (>>=) :: CryptoFailable a -> (a -> CryptoFailable b) -> CryptoFailable b # (>>) :: CryptoFailable a -> CryptoFailable b -> CryptoFailable b # return :: a -> CryptoFailable a # fail :: String -> CryptoFailable a #
Functor CryptoFailable # |
Methods fmap :: (a -> b) -> CryptoFailable a -> CryptoFailable b # (<$) :: a -> CryptoFailable b -> CryptoFailable a #
Applicative CryptoFailable # |
Methods pure :: a -> CryptoFailable a # (<*>) :: CryptoFailable (a -> b) -> CryptoFailable a -> CryptoFailable b # (*>) :: CryptoFailable a -> CryptoFailable b -> CryptoFailable b # (<*) :: CryptoFailable a -> CryptoFailable b -> CryptoFailable a #
Eq a => Eq (CryptoFailable a) # |
Methods (==) :: CryptoFailable a -> CryptoFailable a -> Bool # (/=) :: CryptoFailable a -> CryptoFailable a -> Bool #
Show a => Show (CryptoFailable a) # |
Methods showsPrec :: Int -> CryptoFailable a -> ShowS # show :: CryptoFailable a -> String # showList :: [CryptoFailable a] -> ShowS #

throwCryptoErrorIO :: CryptoFailable a -> IO a #

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

throwCryptoError :: CryptoFailable a -> a #

Same as `throwCryptoErrorIO` but throw the error asynchronously.

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