openmls/schedule/
errors.rsuse openmls_traits::types::CryptoError;
use thiserror::Error;
use crate::{
error::LibraryError,
schedule::psk::{PreSharedKeyId, PskType, ResumptionPskUsage},
};
#[derive(Error, Debug, PartialEq, Clone)]
pub enum PskError {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error("More than 2^16 PSKs were provided.")]
TooManyKeys,
#[error("The PSK could not be found in the store.")]
KeyNotFound,
#[error("Failed to write PSK storage.")]
Storage,
#[error("Type mismatch. Expected {allowed:?}, got {got:?}.")]
TypeMismatch {
allowed: Vec<PskType>,
got: PskType,
},
#[error("Usage mismatch. Expected either of `{allowed:?}`, got `{got:?}`.")]
UsageMismatch {
allowed: Vec<ResumptionPskUsage>,
got: ResumptionPskUsage,
},
#[error("Nonce length mismatch. Expected either of `{expected:?}`, got `{got:?}`.")]
NonceLengthMismatch {
expected: usize,
got: usize,
},
#[error("Duplicate PSK ID. First detected duplicate is `{first:?}`.")]
Duplicate {
first: PreSharedKeyId,
},
}
#[derive(Error, Debug, PartialEq, Clone)]
pub(crate) enum ErrorState {
#[error("Expected to be in initial state.")]
Init,
#[error("Expected to be in epoch state.")]
Context,
}
#[derive(Error, Debug, PartialEq, Clone)]
pub(crate) enum KeyScheduleError {
#[error(transparent)]
LibraryError(#[from] LibraryError),
#[error(transparent)]
InvalidState(#[from] ErrorState),
#[error(transparent)]
CryptoError(#[from] CryptoError),
}
#[cfg(any(feature = "test-utils", test))]
#[derive(Error, Debug, PartialEq, Eq, Clone)]
pub enum KsTestVectorError {
#[error("The computed joiner secret doesn't match the one in the test vector.")]
JoinerSecretMismatch,
#[error("The computed welcome secret doesn't match the one in the test vector.")]
WelcomeSecretMismatch,
#[error("The computed init secret doesn't match the one in the test vector.")]
InitSecretMismatch,
#[error("The group context doesn't match the one in the test vector.")]
GroupContextMismatch,
#[error("The computed sender data secret doesn't match the one in the test vector.")]
SenderDataSecretMismatch,
#[error("The computed encryption secret doesn't match the one in the test vector.")]
EncryptionSecretMismatch,
#[error("The computed exporter secret doesn't match the one in the test vector.")]
ExporterSecretMismatch,
#[error("The computed epoch authenticator doesn't match the one in the test vector.")]
EpochAuthenticatorMismatch,
#[error("The computed external secret doesn't match the one in the test vector.")]
ExternalSecretMismatch,
#[error("The computed confirmation key doesn't match the one in the test vector.")]
ConfirmationKeyMismatch,
#[error("The computed membership key doesn't match the one in the test vector.")]
MembershipKeyMismatch,
#[error("The computed resumption psk doesn't match the one in the test vector.")]
ResumptionPskMismatch,
#[error("The computed external public key doesn't match the one in the test vector.")]
ExternalPubMismatch,
#[error("The computed exporter secret doesn't match the on ein the test vector.")]
ExporterMismatch,
}