use core::fmt;
use der::asn1::ObjectIdentifier;
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum Error {
AlgorithmParametersInvalid {
oid: ObjectIdentifier,
},
DecryptFailed,
EncryptFailed,
#[cfg(feature = "pbes2")]
NoPbes1CryptSupport,
UnsupportedAlgorithm {
oid: ObjectIdentifier,
},
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::AlgorithmParametersInvalid { oid } => {
write!(f, "PKCS#5 parameters for algorithm {} are invalid", oid)
}
Error::DecryptFailed => f.write_str("PKCS#5 decryption failed"),
Error::EncryptFailed => f.write_str("PKCS#5 encryption failed"),
#[cfg(feature = "pbes2")]
Error::NoPbes1CryptSupport => {
f.write_str("PKCS#5 encryption/decryption unsupported for PBES1 (won't fix)")
}
Error::UnsupportedAlgorithm { oid } => {
write!(f, "PKCS#5 algorithm {} is unsupported", oid)
}
}
}
}