Skip to main content

openmls/framing/
errors.rs

1//! # Framing errors.
2//!
3//! This module contains errors related to message framing operations.
4
5use crate::error::LibraryError;
6use thiserror::Error;
7
8// === Public ===
9
10// Re-export errors
11pub use crate::tree::secret_tree::SecretTreeError;
12
13/// Message decryption error
14#[derive(Error, Debug, PartialEq, Clone)]
15pub enum MessageDecryptionError {
16    /// See [`LibraryError`] for more details.
17    #[error(transparent)]
18    LibraryError(#[from] LibraryError),
19    /// Couldn't find a ratcheting secret for the given sender and generation.
20    #[error("Couldn't find a ratcheting secret for the given sender and generation.")]
21    GenerationOutOfBound,
22    /// An error occurred during AEAD decryption.
23    #[error("An error occurred during AEAD decryption.")]
24    AeadError,
25    /// The WireFormat was not PrivateMessage.
26    #[error("The WireFormat was not PrivateMessage.")]
27    WrongWireFormat,
28    /// The content is malformed.
29    #[error("The content is malformed.")]
30    MalformedContent,
31    /// See [`SecretTreeError`] for more details.
32    #[error(transparent)]
33    SecretTreeError(#[from] SecretTreeError),
34    /// Virtual-clients reuse-guard inversion failed.
35    #[cfg(feature = "virtual-clients-draft")]
36    #[error(transparent)]
37    VirtualClientsError(#[from] crate::components::vc_derivation_info::VirtualClientsError),
38}
39
40/// Message encryption error
41#[derive(Error, Debug, PartialEq, Clone)]
42pub enum MessageEncryptionError<StorageError> {
43    /// See [`LibraryError`] for more details.
44    #[error(transparent)]
45    LibraryError(#[from] LibraryError),
46    /// The WireFormat was not PrivateMessage.
47    #[error("The WireFormat was not PrivateMessage.")]
48    WrongWireFormat,
49    /// See [`SecretTreeError`] for more details.
50    #[error(transparent)]
51    SecretTreeError(#[from] SecretTreeError),
52    /// Error reading from or writing to storage
53    #[error("Error reading from or writing to storage: {0}")]
54    StorageError(StorageError),
55    /// Virtual-clients reuse-guard derivation failed.
56    #[cfg(feature = "virtual-clients-draft")]
57    #[error(transparent)]
58    VirtualClientsError(#[from] crate::components::vc_derivation_info::VirtualClientsError),
59}
60
61/// MlsMessage error
62#[derive(Error, Debug, Clone)]
63pub enum MlsMessageError {
64    /// The message could not be decoded.
65    #[error("The message could not be decoded.")]
66    UnableToDecode,
67    /// The message (or one of its parts) is too large to be encoded.
68    #[error("The message (or one of its parts) is too large to be encoded.")]
69    UnableToEncode,
70}
71
72/// ProtocolMessage error
73#[derive(Error, Debug, Clone)]
74pub enum ProtocolMessageError {
75    /// Wrong wire format
76    #[error("Wrong wire format")]
77    WrongWireFormat,
78}