Skip to main content

CryptoServiceError

Enum CryptoServiceError 

Source
pub enum CryptoServiceError<HalError>
where HalError: Debug,
{ Atecc(AteccError<HalError>), InvalidFormat(FormatError), PinIncorrect { tries_remaining: u8, }, PinBlocked, PukIncorrect { tries_remaining: u8, }, Bricked, PinRequired, NotProvisioned, InvalidSlot { slot: Slot, }, EmergencyResetNotPermitted { pin_tries_remaining: u8, puk_tries_remaining: u8, }, }
Expand description

Error returned by crate::CryptoService methods.

Variants§

§

Atecc(AteccError<HalError>)

Underlying driver error.

§

InvalidFormat(FormatError)

PIN or PUK format was rejected (wrong length or non-digit character).

§

PinIncorrect

PIN verification failed. Tries remaining counter is included.

Fields

§tries_remaining: u8

Number of attempts the user has left before the slot is blocked.

§

PinBlocked

PIN slot is hardware-blocked. Only PUK reset can recover.

§

PukIncorrect

PUK was wrong. After crate::slots::PUK_MAX_RETRIES failures the chip is bricked.

Fields

§tries_remaining: u8

Number of PUK attempts the user has left before the chip is bricked.

§

Bricked

PUK retry count exhausted. The chip is permanently unusable.

§

PinRequired

A signing operation was requested but the PIN session is not active.

§

NotProvisioned

The chip has not been provisioned yet (config zone is unlocked, or SHA-256 hashes are not stored in the expected slots).

§

InvalidSlot

The caller specified a slot index that is invalid for the requested operation (out of policy, e.g. provision_slot on an ECC slot, or sign on a slot not configured for ECC).

Fields

§slot: Slot

The slot the caller tried to use.

§

EmergencyResetNotPermitted

The caller asked for crate::CryptoService::emergency_reset but the precondition (both PIN and PUK batches fully exhausted) is not met. The user must use the normal recovery paths (unblock_pin) instead.

Fields

§pin_tries_remaining: u8

Number of PIN attempts the user still has in the current batch.

§puk_tries_remaining: u8

Number of PUK attempts the user still has in the current batch.

Implementations§

Source§

impl<HalError> CryptoServiceError<HalError>
where HalError: Debug,

Source

pub fn atecc_kind(&self) -> Option<AteccErrorKind>

Return the non-generic [AteccErrorKind] if this error wraps a driver-level failure.

Returns None for variants that originated above the driver layer (PIN/PUK failures, format errors, session policy violations).

Intended for layers that must serialize the error over a wire format without naming the concrete HalError type, in particular the firmware’s USB-HID dispatcher.

Trait Implementations§

Source§

impl<HalError> Debug for CryptoServiceError<HalError>
where HalError: Debug + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<HalError> From<AteccError<HalError>> for CryptoServiceError<HalError>
where HalError: Debug,

Source§

fn from(err: AteccError<HalError>) -> Self

Converts to this type from the input type.
Source§

impl<HalError> From<FormatError> for CryptoServiceError<HalError>
where HalError: Debug,

Source§

fn from(err: FormatError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<HalError> Freeze for CryptoServiceError<HalError>
where HalError: Freeze,

§

impl<HalError> RefUnwindSafe for CryptoServiceError<HalError>
where HalError: RefUnwindSafe,

§

impl<HalError> Send for CryptoServiceError<HalError>
where HalError: Send,

§

impl<HalError> Sync for CryptoServiceError<HalError>
where HalError: Sync,

§

impl<HalError> Unpin for CryptoServiceError<HalError>
where HalError: Unpin,

§

impl<HalError> UnsafeUnpin for CryptoServiceError<HalError>
where HalError: UnsafeUnpin,

§

impl<HalError> UnwindSafe for CryptoServiceError<HalError>
where HalError: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.