mls_crypto_provider/
error.rs1#[derive(Debug, thiserror::Error)]
18pub enum MlsProviderError {
19 #[error(transparent)]
20 KeystoreError(#[from] core_crypto_keystore::CryptoKeystoreError),
21 #[error("The provided entropy seed has an incorrect length: expected {expected}, found {actual}")]
22 EntropySeedLengthError { actual: usize, expected: usize },
23 #[error("CSPRNG lock is poisoned")]
24 RngLockPoison,
25 #[error("Unable to collect enough randomness.")]
26 UnsufficientEntropy,
27 #[error("An error occured while generating a X509 certificate")]
28 CertificateGenerationError,
29 #[error("This ciphersuite isn't supported as of now")]
30 UnsupportedSignatureScheme,
31 #[error(transparent)]
32 SignatureError(#[from] signature::Error),
33 #[error("{0}")]
34 StringError(String),
35}
36
37#[allow(clippy::from_over_into)]
38impl Into<String> for MlsProviderError {
39 fn into(self) -> String {
40 self.to_string()
41 }
42}
43
44impl Clone for MlsProviderError {
47 fn clone(&self) -> Self {
48 Self::StringError(self.to_string())
49 }
50}
51
52impl PartialEq for MlsProviderError {
55 fn eq(&self, other: &Self) -> bool {
56 match (self, other) {
57 (
59 MlsProviderError::EntropySeedLengthError { expected, actual },
60 MlsProviderError::EntropySeedLengthError {
61 expected: expected2,
62 actual: actual2,
63 },
64 ) => expected == expected2 && actual == actual2,
65 (MlsProviderError::StringError(s), MlsProviderError::StringError(s2)) => s == s2,
66 (MlsProviderError::RngLockPoison, MlsProviderError::RngLockPoison) => true,
67 (MlsProviderError::UnsufficientEntropy, MlsProviderError::UnsufficientEntropy) => true,
68 (MlsProviderError::CertificateGenerationError, MlsProviderError::CertificateGenerationError) => true,
69 (MlsProviderError::UnsupportedSignatureScheme, MlsProviderError::UnsupportedSignatureScheme) => true,
70 _ => false,
71 }
72 }
73}
74
75pub type MlsProviderResult<T> = Result<T, MlsProviderError>;