1use core::fmt;
4use der::asn1::ObjectIdentifier;
5
6pub type Result<T> = core::result::Result<T, Error>;
8
9#[derive(Copy, Clone, Debug, Eq, PartialEq)]
11#[non_exhaustive]
12pub enum Error {
13 AlgorithmParametersInvalid {
15 oid: ObjectIdentifier,
17 },
18
19 DecryptFailed,
21
22 EncryptFailed,
24
25 #[cfg(feature = "pbes2")]
27 NoPbes1CryptSupport,
28
29 UnsupportedAlgorithm {
34 oid: ObjectIdentifier,
36 },
37}
38
39impl fmt::Display for Error {
40 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41 match self {
42 Error::AlgorithmParametersInvalid { oid } => {
43 write!(f, "PKCS#5 parameters for algorithm {} are invalid", oid)
44 }
45 Error::DecryptFailed => f.write_str("PKCS#5 decryption failed"),
46 Error::EncryptFailed => f.write_str("PKCS#5 encryption failed"),
47 #[cfg(feature = "pbes2")]
48 Error::NoPbes1CryptSupport => {
49 f.write_str("PKCS#5 encryption/decryption unsupported for PBES1 (won't fix)")
50 }
51 Error::UnsupportedAlgorithm { oid } => {
52 write!(f, "PKCS#5 algorithm {} is unsupported", oid)
53 }
54 }
55 }
56}