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