Files
spacedrive/core/src/crypto/error.rs
jake 7abc116d0f [ENG-440] Crypto Refactor (#2115)
* rebase: `crates/crypto` into current `main`

* refactor: remove `mnemonic` module

* feat: disable secure erase temporarily

* fix: tsc

* fix: tsc due to unused import

* fix: remove `cli` crypto info

* deps: update

* chore: remove dead comment

* refactor: remove `bincode` feature

* refactor: give `keyring` a dedicated feature so it's not reliant on `sys` as well

* fix: remove `aes-gcm` as it's no longer supported

* refactor: remove dead comment

* fix: update `keyring` imports

* refactor: change tests to `aes-256-gcm`

* feat: make `Key` a `Box<>` internally to ensure it's heap allocated (and fix tests)

* chore: clippy

* fix: hashing tests now that `const` keys aren't available

this will be cleaned up with test vectors and `include_bytes!()`

* chore: clippy

* refactor: remove dead code

* test: bring back `encrypt_with_invalid_nonce` test

* fix: secret service keyring

* fix: `zbus` build issues

* doc: update comment for clearer reasoning

* fix: cargo fmt

* fix: use bytes directly

* deps: update lockfile

* fix: secret service keyring

* fix: comment out windows keyring for now

* fix: use session keyring if no keyring backend

* fix: completely remove keyring module if no keyring is available for that OS

* fix: clippy

* fix: move iimport to correct conditional compilation

* fix: fmt
2024-03-07 08:00:37 +00:00

63 lines
1.6 KiB
Rust

use std::num::TryFromIntError;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, KeyManagerError>;
impl From<KeyManagerError> for rspc::Error {
fn from(value: KeyManagerError) -> Self {
Self::new(rspc::ErrorCode::InternalServerError, value.to_string())
}
}
#[derive(Debug, Error)]
pub enum KeyManagerError {
// #[error("crypto error: {0}")]
// Crypto(#[from] sd_crypto::Error),
#[error("the key specified was not found")]
KeyNotFound,
#[error("the key manager is locked")]
Locked,
#[error("the key is already mounted")]
AlreadyMounted,
#[error("key not mounted")]
NotMounted,
#[error("the key is already queued")]
AlreadyQueued,
#[error("there was an error during a conversion")]
Conversion,
#[error("there was an error converting ints")]
IntConversion(#[from] TryFromIntError),
#[error("the test vector failed (password is likely incorrect)")]
IncorrectPassword,
#[error("there was an issue while unlocking the key manager")]
Unlock,
#[error("an unsupported operation was attempted")]
Unsupported,
#[error("the word provided is too short")]
WordTooShort,
#[error("the specified file already exists and would be overwritten")]
FileAlreadyExists,
#[error("the specified file doesn't exist")]
FileDoesntExist,
#[error("the specified file is too large")]
FileTooLarge,
#[error("this action would delete the last root key (and make the key manager unusable)")]
LastRootKey,
#[error("database error: {0}")]
Database(#[from] prisma_client_rust::QueryError),
#[error("async IO error: {0}")]
IoAsync(#[from] tokio::io::Error),
#[error("error while converting a UUID: {0}")]
Uuid(#[from] uuid::Error),
}