pub enum NonceError {
QuotaExceeded,
InvalidSize {
expected: u32,
received: u32,
},
Generic(Error),
}
Expand description
Errors that can occur during nonce (number used once) operations.
These errors handle both Web Crypto API random generation errors and nonce validation errors.
Variants§
QuotaExceeded
Indicates that the requested nonce length exceeds the maximum allowed size.
This error occurs when trying to generate a nonce larger than 65536 bytes, which is the maximum size allowed by the Web Crypto API’s getRandomValues(). This limit exists as a security measure to prevent excessive entropy extraction.
Note: Most cryptographic algorithms use much smaller nonces (typically 12 or 16 bytes), so this error should rarely occur in practice.
InvalidSize
Indicates that the provided nonce size doesn’t match the algorithm’s requirements.
This error occurs when:
- Creating a nonce from existing data
- The provided data length doesn’t match the algorithm’s specified nonce size
§Fields
expected
- The nonce size required by the algorithmreceived
- The actual size of the provided nonce data
For example, if AES-GCM requires a 12-byte nonce but 16 bytes were provided, this error would be returned with expected=12, received=16.
Generic(Error)
A wrapper for other types of errors that may occur during nonce operations.
This includes general Web Crypto API errors and other unexpected failures that might occur during nonce generation or handling.
Trait Implementations§
Source§impl Clone for NonceError
impl Clone for NonceError
Source§fn clone(&self) -> NonceError
fn clone(&self) -> NonceError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more