pub enum CryptoError {
InvalidKeyFormat(String),
KeyNotFound,
VerificationFailed,
DecryptionFailed(String),
SigningFailed(String),
EncryptionFailed(String),
UnsupportedAlgorithm(String),
Other(String),
}Expand description
Errors specific to cryptographic operations.
These errors occur within SignatureVerifier,
Decryptor, and related crypto implementations.
CryptoError automatically converts to Claim169Error when returned
from the main decoding functions.
§Implementing Custom Crypto
When implementing custom cryptographic backends, return appropriate
CryptoError variants:
ⓘ
impl SignatureVerifier for MyHsmVerifier {
fn verify(&self, algorithm: Algorithm, key_id: Option<&[u8]>,
data: &[u8], signature: &[u8]) -> CryptoResult<()> {
if !self.has_key(key_id) {
return Err(CryptoError::KeyNotFound);
}
if !self.supports_algorithm(algorithm) {
return Err(CryptoError::UnsupportedAlgorithm(format!("{:?}", algorithm)));
}
// ... perform verification
if !valid {
return Err(CryptoError::VerificationFailed);
}
Ok(())
}
}Variants§
InvalidKeyFormat(String)
Invalid key format
KeyNotFound
Key not found
VerificationFailed
Signature verification failed
DecryptionFailed(String)
Decryption failed
SigningFailed(String)
Signing failed (for custom signer callbacks)
EncryptionFailed(String)
Encryption failed (for custom encryptor callbacks)
UnsupportedAlgorithm(String)
Unsupported algorithm
Other(String)
Generic crypto error
Trait Implementations§
Source§impl Debug for CryptoError
impl Debug for CryptoError
Source§impl Display for CryptoError
impl Display for CryptoError
Source§impl Error for CryptoError
impl Error for CryptoError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<CryptoError> for Claim169Error
impl From<CryptoError> for Claim169Error
Source§fn from(err: CryptoError) -> Self
fn from(err: CryptoError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for CryptoError
impl RefUnwindSafe for CryptoError
impl Send for CryptoError
impl Sync for CryptoError
impl Unpin for CryptoError
impl UnwindSafe for CryptoError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more