#[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
NotOperational
A service was invoked while the module was not in the
Operational state.
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.
ConditionalTestFailed
A conditional self-test (e.g. DRBG CRNGT, pairwise consistency)
failed during operation. The module is now in the Error state.
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.
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.