1#![allow(clippy::module_name_repetitions)]
2
3use ps_deflate::PsDeflateError;
4use ps_ecc::DecodeError;
5use ps_hash::HashError;
6use thiserror::Error;
7
8#[derive(Clone, Debug, Error)]
9pub enum EncryptionError {
10 #[error("Encryption/Decryption failure (from chacha20poly1305)")]
11 ChaChaError,
12 #[error(transparent)]
13 EccError(#[from] ps_ecc::EncodeError),
14 #[error(transparent)]
15 HashError(#[from] HashError),
16 #[error(transparent)]
17 PsDeflateError(#[from] PsDeflateError),
18}
19
20#[derive(Clone, Debug, Error)]
21pub enum DecryptionError {
22 #[error("Encryption/Decryption failure (from chacha20poly1305)")]
23 ChaChaError,
24 #[error(transparent)]
25 EccError(#[from] DecodeError),
26 #[error(transparent)]
27 PsDeflateError(#[from] PsDeflateError),
28}
29
30#[derive(Error, Debug, Clone)]
31pub enum PsCypherError {
32 #[error(transparent)]
33 DecryptionError(#[from] DecryptionError),
34 #[error(transparent)]
35 EncryptionError(#[from] EncryptionError),
36}
37
38impl From<chacha20poly1305::Error> for EncryptionError {
39 fn from(_error: chacha20poly1305::Error) -> Self {
40 Self::ChaChaError
41 }
42}
43
44impl From<chacha20poly1305::Error> for DecryptionError {
45 fn from(_error: chacha20poly1305::Error) -> Self {
46 Self::ChaChaError
47 }
48}