cryptonite-0.10: 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_MacKeyInvalid
  - | CryptoError_AuthenticationTagSizeInvalid
- 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_AEADModeNotSupported |
CryptoError_SecretKeySizeInvalid |
CryptoError_SecretKeyStructureInvalid |
CryptoError_PublicKeySizeInvalid |
CryptoError_SharedSecretSizeInvalid |
CryptoError_MacKeyInvalid |
CryptoError_AuthenticationTagSizeInvalid |

Instances

Enum CryptoError Source |
Eq CryptoError Source |
Data CryptoError Source |
Show CryptoError Source |
Exception CryptoError 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

Monad CryptoFailable Source |
Functor CryptoFailable Source |
Applicative CryptoFailable Source |
Eq a => Eq (CryptoFailable a) Source |
Show a => Show (CryptoFailable a) Source |

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