rust_ev_crypto_primitives/basic_crypto_functions/
mod.rs1mod aes;
20mod argon2;
21mod certificate;
22mod hash;
23mod rand;
24mod signature;
25
26pub use aes::Decrypter;
27pub use argon2::*;
28pub use certificate::*;
29pub use hash::*;
30pub(crate) use rand::*;
31pub use signature::*;
32
33use openssl::error::ErrorStack;
34use std::{io, path::PathBuf};
35use thiserror::Error;
36
37#[derive(Error, Debug)]
39pub enum BasisCryptoError {
40 #[error("Path is not a directory {path}")]
41 Dir { path: String },
42 #[error("IO error caused by {source}: {msg}")]
43 IO { msg: String, source: io::Error },
44 #[error("Keystore error {msg} caused by {source}")]
45 Keystore { msg: String, source: ErrorStack },
46 #[error("Keystore has a wrong format: {0}")]
47 KeystoreWrongFormat(String),
48 #[error("Keystore {0} has no secret key")]
49 KeyStoreMissingSecretKey(PathBuf),
50 #[error("Keystore {0} has no certificate for the secret key")]
51 KeyStoreMissingCertSecretKey(PathBuf),
52 #[error("Keystore {0} has no list of CA")]
53 KeyStoreMissingCAList(PathBuf),
54 #[error("The ca with name {name} is not present in the Keystore {path}")]
55 KeyStoreMissingCA { path: PathBuf, name: String },
56 #[error("Error reading public key in the certificate {name} caused by {source}")]
57 CertificateErrorPK { name: String, source: ErrorStack },
58 #[error("Error of time during time check of the certificate {name} caused by {source}")]
59 CertificateErrorTime { name: String, source: ErrorStack },
60 #[error("Digest (Fingerprint) error caused by {source}: {msg}")]
61 CertificateDigest { msg: String, source: ErrorStack },
62 #[error("PublicKey error caused by {source}: {msg}")]
63 PublicKeyError { msg: String, source: ErrorStack },
64 #[error("Secretkey error caused by {source}: {msg}")]
65 SecretKeyError { msg: String, source: ErrorStack },
66 #[error("{msg} caused by {source}")]
67 SignatureVerify { msg: String, source: ErrorStack },
68 #[error("{msg} caused by {source}")]
69 Sign { msg: String, source: ErrorStack },
70 #[error("Hash error caused by {source}: {msg}")]
71 HashError { msg: String, source: ErrorStack },
72 #[error("Buffer Hash error caused by {source}: {msg}")]
73 BufferHashError { msg: String, source: std::io::Error },
74 #[error("Argon2 error caused by {argon2_error_source}: {msg}")]
75 Argon2Error {
76 msg: String,
77 argon2_error_source: Argon2Error,
78 },
79 #[error("Random error caused by {source}: {msg}")]
80 RandomError { msg: String, source: ErrorStack },
81 #[error("Secretkey error caused by {source}: {msg}")]
82 AesGcmError { msg: String, source: ErrorStack },
83}