synta_certificate/crypto/
errors.rs1#[derive(Debug)]
14pub struct PrivateKeyError(pub Box<dyn std::error::Error + Send + Sync + 'static>);
15
16impl std::fmt::Display for PrivateKeyError {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 self.0.fmt(f)
19 }
20}
21
22impl std::error::Error for PrivateKeyError {
23 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
24 self.0.source()
25 }
26}
27
28impl PrivateKeyError {
29 pub fn new<E: std::error::Error + Send + Sync + 'static>(e: E) -> Self {
31 Self(Box::new(e))
32 }
33}
34
35#[derive(Debug)]
39pub struct NoCryptoError;
40
41impl std::fmt::Display for NoCryptoError {
42 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
43 f.write_str(
44 "no crypto backend configured; cannot decrypt PKCS#12 encrypted bags \
45 (enable the 'openssl' feature or provide a Pkcs12Decryptor)",
46 )
47 }
48}
49
50impl std::error::Error for NoCryptoError {}
51
52#[derive(Debug)]
59pub struct NoEncryptorError;
60
61impl std::fmt::Display for NoEncryptorError {
62 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
63 f.write_str(
64 "no crypto backend configured; cannot encrypt content \
65 (enable the 'openssl' feature or provide an Encryptor implementation)",
66 )
67 }
68}
69
70impl std::error::Error for NoEncryptorError {}
71
72#[derive(Debug)]
78pub struct NoSignerError;
79
80impl std::fmt::Display for NoSignerError {
81 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
82 f.write_str(
83 "no certificate signer configured; cannot sign certificates \
84 (enable the 'openssl' feature or provide a CertificateSigner implementation)",
85 )
86 }
87}
88
89impl std::error::Error for NoSignerError {}
90
91#[derive(Debug)]
97pub struct NoSignatureVerifierError;
98
99impl std::fmt::Display for NoSignatureVerifierError {
100 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
101 f.write_str(
102 "no signature verifier configured; cannot verify certificate signatures \
103 (enable the 'openssl' feature or provide a SignatureVerifier implementation)",
104 )
105 }
106}
107
108impl std::error::Error for NoSignatureVerifierError {}
109
110#[derive(Debug)]
116pub struct NoKeyIdHasherError;
117
118impl std::fmt::Display for NoKeyIdHasherError {
119 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
120 f.write_str(
121 "no crypto backend configured: enable the 'openssl' feature \
122 for SubjectKeyIdentifier / AuthorityKeyIdentifier hashing",
123 )
124 }
125}
126
127impl std::error::Error for NoKeyIdHasherError {}
128
129#[derive(Debug)]
135pub struct NoEnvelopedDataDecryptorError;
136
137impl std::fmt::Display for NoEnvelopedDataDecryptorError {
138 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
139 f.write_str(
140 "no crypto backend configured; cannot decrypt EnvelopedData \
141 (enable the 'openssl' feature or provide an EnvelopedDataDecryptor implementation)",
142 )
143 }
144}
145
146impl std::error::Error for NoEnvelopedDataDecryptorError {}