openmls/key_packages/
errors.rs

1//! # Key Package errors
2//!
3//! `KeyPackageError` are thrown on errors handling `KeyPackage`s.
4
5use thiserror::Error;
6
7use crate::{ciphersuite::signable::SignatureError, error::LibraryError};
8
9/// KeyPackage verify error
10#[derive(Error, Debug, PartialEq, Clone)]
11pub enum KeyPackageVerifyError {
12    /// See [`LibraryError`] for more details.
13    #[error(transparent)]
14    LibraryError(#[from] LibraryError),
15    /// The lifetime of the leaf node is not valid.
16    #[error("The lifetime of the leaf node is not valid.")]
17    InvalidLifetime,
18    /// The lifetime of the leaf node is missing.
19    #[error("The lifetime of the leaf node is missing.")]
20    MissingLifetime,
21    /// A key package extension is not supported in the leaf's capabilities.
22    #[error("A key package extension is not supported in the leaf's capabilities.")]
23    UnsupportedExtension,
24    /// The key package signature is not valid.
25    #[error("The key package signature is not valid.")]
26    InvalidSignature,
27    /// The leaf node signature is not valid.
28    #[error("The leaf node signature is not valid.")]
29    InvalidLeafNodeSignature,
30    /// Invalid LeafNode source type
31    #[error("Invalid LeafNode source type")]
32    InvalidLeafNodeSourceType,
33    /// The init key and the encryption key are equal.
34    #[error("The init key and the encryption key are equal.")]
35    InitKeyEqualsEncryptionKey,
36    /// The protocol version is not valid.
37    #[error("The protocol version is not valid.")]
38    InvalidProtocolVersion,
39}
40
41/// KeyPackage extension support error
42#[derive(Error, Debug, PartialEq, Eq, Clone)]
43pub enum KeyPackageExtensionSupportError {
44    /// The key package does not support all required extensions.
45    #[error("The key package does not support all required extensions.")]
46    UnsupportedExtension,
47}
48
49/// KeyPackage new error
50#[derive(Error, Debug, PartialEq, Clone)]
51pub enum KeyPackageNewError {
52    /// See [`LibraryError`] for more details.
53    #[error(transparent)]
54    LibraryError(#[from] LibraryError),
55    /// The ciphersuite does not match the signature scheme.
56    #[error("The ciphersuite does not match the signature scheme.")]
57    CiphersuiteSignatureSchemeMismatch,
58    /// Accessing storage failed.
59    #[error("Accessing storage failed.")]
60    StorageError,
61    /// See [`SignatureError`] for more details.
62    #[error(transparent)]
63    SignatureError(#[from] SignatureError),
64}