openmls/key_packages/
errors.rs1use openmls_traits::types::Ciphersuite;
6use thiserror::Error;
7
8use crate::{
9 ciphersuite::signable::SignatureError,
10 error::LibraryError,
11 extensions::ExtensionType,
12 prelude::ExtensionTypeNotValidInKeyPackageError,
13 treesync::{errors::LifetimeError, node::leaf_node::LeafNodeBuildError},
14};
15
16#[derive(Error, Debug, PartialEq, Clone)]
18pub enum KeyPackageVerifyError {
19 #[error(transparent)]
21 LibraryError(#[from] LibraryError),
22 #[error(transparent)]
24 LifetimeError(#[from] LifetimeError),
25 #[error("The lifetime of the leaf node is missing.")]
27 MissingLifetime,
28 #[error("A key package extension is not supported in the leaf's capabilities.")]
30 UnsupportedExtension,
31 #[error("The key package signature is not valid.")]
33 InvalidSignature,
34 #[error("The leaf node signature is not valid.")]
36 InvalidLeafNodeSignature,
37 #[error("Invalid LeafNode source type")]
39 InvalidLeafNodeSourceType,
40 #[error("The init key and the encryption key are equal.")]
42 InitKeyEqualsEncryptionKey,
43 #[error("The protocol version is not valid.")]
45 InvalidProtocolVersion,
46 #[error("Ciphersuite {0:?} is not supported by the crypto provider.")]
48 UnsupportedCiphersuite(Ciphersuite),
49 #[error(transparent)]
51 ExtensionTypeNotValidInKeyPackage(#[from] ExtensionTypeNotValidInKeyPackageError),
52 #[cfg(feature = "extensions-draft")]
54 #[error("The last_resort_key_package component data must be empty.")]
55 MalformedLastResortComponent,
56}
57
58#[derive(Error, Debug, PartialEq, Eq, Clone)]
60pub enum KeyPackageExtensionSupportError {
61 #[error("The key package does not support all required extensions.")]
63 UnsupportedExtension,
64}
65
66#[derive(Error, Debug, PartialEq, Clone)]
68pub enum KeyPackageNewError {
69 #[error(transparent)]
71 LibraryError(#[from] LibraryError),
72 #[error("The ciphersuite does not match the signature scheme.")]
74 CiphersuiteSignatureSchemeMismatch,
75 #[error("Ciphersuite {0:?} is not supported by the crypto provider.")]
77 UnsupportedCiphersuite(Ciphersuite),
78 #[error("Accessing storage failed.")]
80 StorageError,
81 #[error(
84 "The LeafNode capabilities do not advertise the {0:?} extension required by a last-resort KeyPackage."
85 )]
86 MissingLastResortCapability(ExtensionType),
87 #[error(transparent)]
89 SignatureError(#[from] SignatureError),
90 #[error(transparent)]
92 LeafNodeBuild(#[from] LeafNodeBuildError),
93 #[cfg(feature = "virtual-clients-draft")]
95 #[error(transparent)]
96 VirtualClientsError(#[from] crate::components::vc_derivation_info::VirtualClientsError),
97 #[cfg(feature = "virtual-clients-draft")]
99 #[error("A virtual-clients KeyPackage batch must request at least one KeyPackage.")]
100 EmptyBatch,
101}