mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2025-12-11 20:15:30 +01:00
* add crypto crate with some functionality * formatting * add `argon2id` parameter levels * add descriptive comments * add stream decryption objects * add `StreamEncryptor` struct * add `StreamDecryptor` * general cleanup * add `thiserror` and error handling * add header structs * add basic serialization functionality * advance serialization * finish serialization * clean up serialization and use `impl` * finalise deserialization * add stream helper functions and remove old code * add AAD creation and retrieval * add important comment * add `ChaCha20Rng` as a CSPRNG * cleanup and crate-wide clippy lints * apply nursery lints * add in-memory encryption objects * rename `utils` to `objects` * move (de)serialization rules to separate file * add header-write helper function * add password hash helper function * add `decrypt_master_key` function * cleanup, formatting, linting * move keyslots to separate file, and rename them * add basic comments * remove `secrecy` dependency and import `protected` * add `to_array` helper function * `sd_crypto` -> `sd-crypto` * remove manual drops * add clippy allows * add `new()` for `Keyslot` and `FileHeader` * remove license * zeroize read buffer on error * magic bytes are now `ballapp` Co-authored-by: Brendan Allan <brendonovich@outlook.com> Co-authored-by: Jamie Pine <32987599+jamiepine@users.noreply.github.com>
31 lines
882 B
Rust
31 lines
882 B
Rust
use thiserror::Error;
|
|
|
|
/// This enum defines all possible errors that this crate can give
|
|
#[derive(Error, Debug)]
|
|
pub enum Error {
|
|
#[error("not enough bytes were written to the output file")]
|
|
WriteMismatch,
|
|
#[error("there was an error hashing the password")]
|
|
PasswordHash,
|
|
#[error("I/O error: {0}")]
|
|
Io(#[from] std::io::Error),
|
|
#[error("error while encrypting")]
|
|
Encrypt,
|
|
#[error("error while decrypting")]
|
|
Decrypt,
|
|
#[error("nonce length mismatch")]
|
|
NonceLengthMismatch,
|
|
#[error("invalid file header")]
|
|
FileHeader,
|
|
#[error("error initialising stream encryption/decryption")]
|
|
StreamModeInit,
|
|
#[error("error initialising in-memory encryption/decryption")]
|
|
MemoryModeInit,
|
|
#[error("wrong password provided")]
|
|
IncorrectPassword,
|
|
#[error("no keyslots available")]
|
|
NoKeyslots,
|
|
#[error("mismatched data length while converting vec to array")]
|
|
VecArrSizeMismatch,
|
|
}
|