mls_crypto_provider/
error.rs1#[derive(Debug, thiserror::Error)]
2pub enum MlsProviderError {
3 #[error(transparent)]
4 KeystoreError(#[from] core_crypto_keystore::CryptoKeystoreError),
5 #[error("The provided entropy seed has an incorrect length: expected {expected}, found {actual}")]
6 EntropySeedLengthError { actual: usize, expected: usize },
7 #[error("CSPRNG lock is poisoned")]
8 RngLockPoison,
9 #[error("Unable to collect enough randomness.")]
10 UnsufficientEntropy,
11 #[error("An error occured while generating a X509 certificate")]
12 CertificateGenerationError,
13 #[error("This ciphersuite isn't supported as of now")]
14 UnsupportedSignatureScheme,
15 #[error(transparent)]
16 SignatureError(#[from] signature::Error),
17 #[error("{0}")]
18 StringError(String),
19}
20
21#[allow(clippy::from_over_into)]
22impl Into<String> for MlsProviderError {
23 fn into(self) -> String {
24 self.to_string()
25 }
26}
27
28impl Clone for MlsProviderError {
31 fn clone(&self) -> Self {
32 Self::StringError(self.to_string())
33 }
34}
35
36impl PartialEq for MlsProviderError {
39 fn eq(&self, other: &Self) -> bool {
40 match (self, other) {
41 (
43 MlsProviderError::EntropySeedLengthError { expected, actual },
44 MlsProviderError::EntropySeedLengthError {
45 expected: expected2,
46 actual: actual2,
47 },
48 ) => expected == expected2 && actual == actual2,
49 (MlsProviderError::StringError(s), MlsProviderError::StringError(s2)) => s == s2,
50 (MlsProviderError::RngLockPoison, MlsProviderError::RngLockPoison) => true,
51 (MlsProviderError::UnsufficientEntropy, MlsProviderError::UnsufficientEntropy) => true,
52 (MlsProviderError::CertificateGenerationError, MlsProviderError::CertificateGenerationError) => true,
53 (MlsProviderError::UnsupportedSignatureScheme, MlsProviderError::UnsupportedSignatureScheme) => true,
54 _ => false,
55 }
56 }
57}
58
59pub type MlsProviderResult<T> = Result<T, MlsProviderError>;