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#
| Type | Definition | Description |
|---|---|---|
ReasonTag | type ReasonTag = Literal['InvalidArgument', 'InvalidKey', 'DecryptionFailed', 'Unsupported', 'NotExtractable'] | |
AnyReason | type AnyReason = InvalidArgument | InvalidKey | DecryptionFailed | Unsupported | NotExtractable |
Classes#
Functions#
is_crypto_error#
is_crypto_error(u) -> bool| Parameter | Type | Description |
|---|---|---|
u | object |
Returns bool
def is_crypto_error(u: object) -> bool:
return isinstance(u, CryptoError)is_crypto_error_reason#
is_crypto_error_reason(u) -> bool| Parameter | Type | Description |
|---|---|---|
u | object |
Returns bool
def is_crypto_error_reason(u: object) -> bool:
return isinstance(u, CryptoErrorReason)