pub enum Error {
Show 13 variants
InvalidKeyLength {
label: &'static str,
expected: usize,
got: usize,
},
InvalidPrefix {
label: &'static str,
},
TooShort {
label: &'static str,
},
MacVerificationFailed {
label: &'static str,
},
DecryptionFailed {
label: &'static str,
},
EncryptionFailed {
label: &'static str,
},
UnknownIdentifier {
kind: &'static str,
identifier: String,
},
InvalidMasterKey {
got: usize,
},
InvalidKey {
label: &'static str,
},
InvalidIterations,
InvalidOutputLength {
requested: usize,
max: usize,
},
InvalidHex,
UnsupportedNationalAlgorithm {
name: &'static str,
hint: &'static str,
},
}Expand description
库统一错误。
Variants§
InvalidKeyLength
密钥长度不符合算法要求。
InvalidPrefix
密文前缀不是本算法 / 本格式版本的标识。
TooShort
密文长度不足(缺少 IV / MAC / tag)。
MacVerificationFailed
encrypt-then-MAC 的 MAC 校验失败:密钥不对或密文被改,没有第三种解释。
DecryptionFailed
认证加密(GCM / XChaCha20-Poly1305)解密失败:密钥不对或密文被改。
EncryptionFailed
加密失败(一般不应发生)。
UnknownIdentifier
标识未注册到注册表。
InvalidMasterKey
主密钥必须是 32 字节。
InvalidKey
密钥材质非法(十六进制、长度或曲线点校验失败)。
InvalidIterations
PBKDF2 迭代次数必须为正。
InvalidOutputLength
请求的输出长度非法(为 0 或超过算法上限)。
InvalidHex
十六进制字符串非法(奇数长度或含非十六进制字符)。
UnsupportedNationalAlgorithm
国密算法(SM1 / SM7 / SM9)本库不提供实现。
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
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()
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
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