Skip to main content

core_crypto/mls/credential/
error.rs

1//! MLS credential errors
2
3// We allow missing documentation in the error module because the types are generally self-descriptive.
4#![allow(missing_docs)]
5
6use core_crypto_keystore::Sha256Hash;
7use openmls::prelude::SignaturePublicKey;
8
9pub(crate) type Result<T, E = Error> = core::result::Result<T, E>;
10
11#[derive(Debug, thiserror::Error)]
12pub enum Error {
13    #[error("decoding X509 certificate")]
14    DecodeX509(#[source] x509_cert::der::Error),
15    #[error("client presented an invalid identity")]
16    InvalidIdentity,
17    #[error("No credential found for public key {0:?}")]
18    CredentialNotFound(SignaturePublicKey),
19    #[error("No credential found matching public key hash {0}")]
20    CredentialRefNotFound(Sha256Hash),
21    #[error("missing PKI environment")]
22    MissingPKIEnvironment,
23    /// Unsupported credential type.
24    ///
25    /// Supported credential types:
26    ///
27    /// - basic
28    /// - x509
29    #[error("unsupported credential type (variant {0}")]
30    UnsupportedCredentialType(u16),
31    #[error("the signature scheme {0:?} was not present in the provided x509 identity")]
32    SignatureSchemeNotPresentInX509Identity(openmls::prelude::SignatureScheme),
33    /// This operation is not supported.
34    ///
35    /// There are some operations which must be implemented to satisfy a trait,
36    /// but for which we cannot offer a real implementation. Those raise this error.
37    ///
38    /// Where possible, a short workaround is included.
39    #[error("unsupported operation. prefer `{0}`")]
40    UnsupportedOperation(&'static str),
41    #[error("unsupported algorithm")]
42    UnsupportedAlgorithm,
43    #[error(transparent)]
44    UnknownCipherSuite(#[from] crate::mls::UnknownCipherSuite),
45    #[error(transparent)]
46    Keystore(#[from] crate::KeystoreError),
47    #[error(transparent)]
48    OpenMls(#[from] crate::OpenMlsError),
49    #[error(transparent)]
50    Recursive(#[from] crate::RecursiveError),
51    #[error(transparent)]
52    Tls(#[from] crate::TlsCodecError),
53}