Skip to main content

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