Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error { NotOperational { current: State, }, SelfTestFailed { test: &'static str, }, ConditionalTestFailed { reason: &'static str, }, IntegrityNotAttested, AlreadyInitialized, AlreadyFailed, InvalidInput, AlgorithmRestricted { service: Service, }, NotImplemented, EntropyInputTooShort, NonceTooShort, }
Expand description

Errors surfaced by the module boundary.

Every variant is constructed with a &'static str description so that formatting is allocation-free; this lets the module report failures even from no_std contexts and from within the self-test runner itself.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

NotOperational

A service was invoked while the module was not in the Operational state.

Fields

§current: State

The state the module was actually in when the call arrived.

§

SelfTestFailed

A power-up self-test failed. The module is now in the Error state.

test is THREAD_ID_CHECK when no self-test could run because the platform gave the initialising thread no id the module can record.

Fields

§test: &'static str

Name of the failing test, supplied by its SelfTest implementation.

§

ConditionalTestFailed

A conditional self-test (e.g. DRBG CRNGT, pairwise consistency) failed during operation. The module is now in the Error state.

Fields

§reason: &'static str

Short description of the failing check.

§

IntegrityNotAttested

The pre-operational self-test sequence completed without the software integrity test having been performed. The module is now in the State::IntegrityUnverified state.

This is an integration fault rather than a finding about the module: the test inventory handed to initialize_with_tests did not include oxicrypt_integrity::KATS.

§

AlreadyInitialized

initialize_with_tests or initialize_with_profile was called on a module that is already Operational, or that becomes Operational when the initialisation another thread is running completes. The module is ready; nothing was re-run.

§

AlreadyFailed

initialize_with_tests or initialize_with_profile was called on a module whose initialisation has already failed, so that it is in Error or IntegrityUnverified, including when the initialisation another thread was running fails while this call waits. A failed initialisation is terminal: no self-test is re-run, nothing resets the state, and only a process restart starts the module again.

§

InvalidInput

A cryptographic service was called with input bytes that do not encode a valid domain element (for example, a scalar that is zero or not less than the group order, or a point that is not a canonical encoding on the curve). This is distinct from a self-test failure: the module is still operational; the caller supplied out-of-range bytes. Algorithm primitives should return this rather than silently substituting a default.

§

AlgorithmRestricted

A service was invoked that is not permitted under the active AlgorithmProfile. The module is still operational — the algorithm exists but is restricted by policy. Switch to a less restrictive profile (which requires a process restart) or use an alternative algorithm that is permitted.

Fields

§service: Service

The specific service that was blocked.

§

NotImplemented

A service was invoked for an algorithm that exists in the Service enum but whose implementation has not yet been completed. Stub crates return this. The algorithm is recognized by the profile system and its gate will pass if the profile permits it, but the actual cryptographic operation is not yet available.

§

EntropyInputTooShort

A DRBG instantiate call was given an entropy input shorter than the minimum entropy input length (min_length) for the instantiated security strength (SP 800-90A Rev. 1 §8.6.3, Tables 2 and 3). Distinct from Error::InvalidInput, which a DRBG returns for over-long input, and CTR_DRBG without a derivation function for seed material that is not exactly seedlen bytes.

§

NonceTooShort

A DRBG instantiate call was given a nonce shorter than security_strength / 2 bits for the instantiated security strength. The floor is the module’s nonce check, which SP 800-90A Rev. 1 §9.1 step 8 permits; a nonce of that length can meet §8.6.7(a), and a shorter one that would meet only §8.6.7(b), the uniqueness condition, is refused.

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Error

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Eq for Error

Source§

impl PartialEq for Error

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.