GitHub

crypto_error

API reference for crypto_error.

The CryptoError every pyfect.crypto module fails with (Effect's effect/crypto/CryptoError).

module and method name the operation ("Aead", "decrypt"); reason says what went wrong: InvalidArgument, InvalidKey, DecryptionFailed, Unsupported or NotExtractable. Match a reason with catch_reason::

aead.decrypt(key, data, nonce=nonce).pipe(
    fx.catch_reason(CryptoError, DecryptionFailed, lambda _r, _e: fx.succeed(None))
)

Map the error before it reaches a client: sending crypto failure detail to clients is how oracles leak.

Types

TypeDefinitionDescription
ReasonTagtype ReasonTag = Literal['InvalidArgument', 'InvalidKey', 'DecryptionFailed', 'Unsupported', 'NotExtractable']
AnyReasontype AnyReason = InvalidArgument | InvalidKey | DecryptionFailed | Unsupported | NotExtractable

Classes

Functions

is_crypto_error

is_crypto_error(u) -> bool
ParameterTypeDescription
uobject

Returns bool

def is_crypto_error(u: object) -> bool:
    return isinstance(u, CryptoError)

is_crypto_error_reason

is_crypto_error_reason(u) -> bool
ParameterTypeDescription
uobject

Returns bool

def is_crypto_error_reason(u: object) -> bool:
    return isinstance(u, CryptoErrorReason)