1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#![no_std]
#![deny(unsafe_code)]
#![deny(missing_docs)]
pub mod ecdh;
pub mod dh;
pub mod digest;
pub mod signatures;
pub mod constants;
use core::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CryptoError {
ECCError,
InvalidEncoding,
SignatureError,
#[doc(hidden)]
__Nonexhaustive,
}
pub type Result<T> = core::result::Result<T, CryptoError>;
impl fmt::Display for CryptoError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&CryptoError::ECCError => write!(f, "EC Crypto operation failed"),
&CryptoError::InvalidEncoding => write!(f, "Invalid encoding"),
&CryptoError::SignatureError => write!(f, "Signature Error"),
&CryptoError::__Nonexhaustive => unreachable!(),
}
}
}
impl From<p256::elliptic_curve::Error> for CryptoError {
fn from(_error: p256::elliptic_curve::Error) -> Self {
CryptoError::ECCError
}
}