Skip to main content

KemAlg

Enum KemAlg 

Source
#[repr(u8)]
pub enum KemAlg { X25519HkdfSha256 = 1, P256HkdfSha256 = 2, RsaOaepSha256 = 3, XWing = 4, MlKem768P256 = 5, }
Expand description

Key encapsulation mechanism. Specified per slot, not per file.

Variants§

§

X25519HkdfSha256 = 1

Author → server and author → recipient.

§

P256HkdfSha256 = 2

Server → device. P-256 specifically, not X25519: Microsoft Platform Crypto Provider does not provide X25519; TPM 2.0 offers ECDH P-256 and RSA.

§

RsaOaepSha256 = 3

Fallback for TPMs without ECDH support.

§

XWing = 4

X25519 and ML-KEM-768 hybrid using X-Wing: a post-quantum half alongside a classical half. Mechanism: crate::xwing; normative form: docs/format.md, “VERSION 3 OPENED”, item 1 (the item itself is in version 4).

Targets a SOFTWARE key: X-Wing is defined over X25519, while a TPM key is P-256. Post-quantum protection and hardware binding of the recipient are currently mutually exclusive; see docs/threat-model.md §2.

§

MlKem768P256 = 5

ECDH P-256 and ML-KEM-768 hybrid: MLKEM768-P256. Mechanism: crate::mlkem_p256; normative form: docs/format.md, version 5.

The difference from Self::XWing is not strength but WHERE the classical half resides: Platform Crypto Provider supports P-256 but not X25519. Thus the fifth mechanism is the only one combining post-quantum protection with TPM key non-exportability rather than making them mutually exclusive.

Implementations§

Source§

impl KemAlg

Source

pub fn ensure_supported(self) -> Result<(), CryptoError>

Whether the build can execute the declared mechanism: ONE name for this question.

The name was not introduced for neatness. “Is this mechanism executable?” was answered separately by the fingerprint table (kdf::device_fpr), header length tables, and the client’s share-B issuance branch; the answers agreed only through the editor’s memory. Such a set can diverge exactly once: in the direction of “somewhere a mechanism this build cannot execute was considered executable”.

The answer comes from seal::supports_kem rather than being duplicated here: the match without _ must sit BESIDE THE IMPLEMENTATION, so adding a KemAlg member breaks the build at the code responsible for executing it. This is the Result form of the same answer, for callers needing rejection rather than bool, following SigAlg::ensure_supported.

§Errors

CryptoError::UnsupportedAlgorithm: the registry has the number but the build lacks the mechanism.

Source

pub fn from_u8(v: u8) -> Result<Self, CryptoError>

Parse an identifier from a file.

§Why this has NO second boundary, unlike its neighbors

AeadAlg::from_u8, SigAlg::from_u8, and TreeHashAlg::from_u8 call ensure_supported during parsing: an unimplemented header algorithm must reject the FILE, the earlier the better. For kem_id, the consequence differs normatively: docs/format.md §3.3 and §3.5 require SKIPPING a slot with an unimplemented or unknown mechanism rather than rejecting the file; a usable slot for this recipient may be adjacent. Rejection built in here would move “skip or reject” from the caller’s level into number parsing, which knows nothing about slots.

The boundary therefore remains a separate Self::ensure_supported call, while parsing answers only “is this number in the registry?”.

Trait Implementations§

Source§

impl Clone for KemAlg

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 KemAlg

Source§

impl Debug for KemAlg

Source§

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

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

impl Eq for KemAlg

Source§

impl PartialEq for KemAlg

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 KemAlg

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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, 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.