cryptonite-0.9: 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

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

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 |
Functor CryptoFailable |
Applicative CryptoFailable |
Eq a => Eq (CryptoFailable a) |
Show a => Show (CryptoFailable a) |

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