pub enum Error {
EncapsulateError,
DecapsulateError,
LowEntropyKey,
InvalidFormat,
}kem only.Expand description
Errors that can occur during KWing encapsulation or decapsulation.
All variants implement core::fmt::Display and core::error::Error
(on Rust ≥ 1.81 / when std is available) for ergonomic error propagation.
§Example
use b_wing::{KWing, KemError};
let bad_pk = vec![0u8; 10]; // wrong size
assert_eq!(
KWing::encapsulate(&[0u8; 128], &bad_pk),
Err(KemError::InvalidFormat),
);Variants§
EncapsulateError
One of the three underlying encapsulation primitives returned an error.
This is unexpected under normal operation; it indicates a bug in the caller-supplied seed or an upstream library fault.
DecapsulateError
One of the three underlying decapsulation primitives returned an error.
This typically indicates that the ciphertext was produced by a different key pair, or that it has been corrupted / tampered with.
LowEntropyKey
The X25519 Diffie-Hellman output was an all-zero (non-contributory) point.
This is a known mathematical degenerate case for Curve25519. KWing rejects it to prevent a class of small-subgroup attacks in which an attacker supplies a low-order public key.
InvalidFormat
A key, ciphertext, or seed was the wrong length or could not be parsed.
The expected sizes are KWing::ENCAPSULATION_KEY_SIZE and
KWing::CIPHERTEXT_SIZE respectively.