use core::fmt;
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Error {
BadDer,
BadDerTime,
CaUsedAsEndEntity,
CertExpired,
CertNotValidForName,
CertNotValidYet,
EndEntityUsedAsCa,
ExtensionValueInvalid,
InvalidCertValidity,
InvalidSignatureForPublicKey,
NameConstraintViolation,
PathLenConstraintViolated,
SignatureAlgorithmMismatch,
RequiredEkuNotFound,
UnknownIssuer,
UnsupportedCertVersion,
MissingOrMalformedExtensions,
UnsupportedCriticalExtension,
UnsupportedSignatureAlgorithmForPublicKey,
UnsupportedSignatureAlgorithm,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}
#[cfg(feature = "std")]
impl ::std::error::Error for Error {}
pub(crate) enum InternalError {
MaximumSignatureChecksExceeded,
MaximumPathBuildCallsExceeded,
}
impl InternalError {
fn is_fatal(&self) -> bool {
matches!(
self,
Self::MaximumSignatureChecksExceeded | Self::MaximumPathBuildCallsExceeded
)
}
}
pub(crate) enum ErrorOrInternalError {
Error(Error),
InternalError(InternalError),
}
impl ErrorOrInternalError {
pub fn is_fatal(&self) -> bool {
match self {
ErrorOrInternalError::Error(_) => false,
ErrorOrInternalError::InternalError(e) => e.is_fatal(),
}
}
}
impl From<InternalError> for ErrorOrInternalError {
fn from(value: InternalError) -> Self {
Self::InternalError(value)
}
}
impl From<Error> for ErrorOrInternalError {
fn from(error: Error) -> Self {
Self::Error(error)
}
}