Skip to content

dhkem: add HpkeKemId trait; make X25519Kem fallible#360

Merged
tarcieri merged 1 commit into
masterfrom
dhkem/suite-id-support
Jul 9, 2026
Merged

dhkem: add HpkeKemId trait; make X25519Kem fallible#360
tarcieri merged 1 commit into
masterfrom
dhkem/suite-id-support

Conversation

@tarcieri

@tarcieri tarcieri commented Jul 9, 2026

Copy link
Copy Markdown
Member

Also adds a common Error type for the TryDecapsulate implementations to use.

The HpkeKemId trait makes it possible to associate one of the KEM IDs from RFC9180 §7.1 with a given type. The trait is now impl'd for all KEMs in that table we support (the only one we currently don't is X448).

The generic EncapsulationKey::encapsulate(_with_rng)_and_expand as well as DecapsulationKey::decapsulate_and_expand methods provide a convenient way to initialize an Expander from the shared key output by the KEM.

HPKE mandates an all-zero check for the X25519 output (occurs if the input is all-zero or a low order point) in RFC9810 §7.1.4, which this also adds as the check needs to occur before Expander is initialized, so this switches X25519Kem to use the fallible TryDecapsulate.

Closes #262, #268, #327

Also adds a common `Error` type for the `TryDecapsulate` implementations
to use.

The `HpkeKemId` trait makes it possible to associate one of the KEM IDs
from RFC9180 §7.1 with a given type. The trait is now impl'd for all
KEMs in that table we support (the only one we currently don't is X448).

The generic `EncapsulationKey::encapsulate(_with_rng)_and_expand` as
well as `DecapsulationKey::decapsulate_and_expand` methods provide a
convenient way to initialize an `Expander` from the shared key output by
the KEM.

HPKE mandates an all-zero check for the X25519 output (occurs if the
input is all-zero or a low order point) in RFC9810 §7.1.4, which this
also adds as the check needs to occur before `Expander` is initialized,
so this switches `X25519Kem` to use the fallible `TryDecapsulate`.

Closes #262, #268, #327
@tarcieri tarcieri merged commit cd5d875 into master Jul 9, 2026
59 of 60 checks passed
@tarcieri tarcieri deleted the dhkem/suite-id-support branch July 9, 2026 16:31
@tarcieri tarcieri mentioned this pull request Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant