Skip to content

fix: check provider support in KeyPackageIn::validate - #2206

Merged
kkohbrok merged 3 commits into
openmls:mainfrom
SchwarzDigits:keypackage-validate-supports
Oct 5, 2026
Merged

kkohbrok merged 3 commits into
openmls:mainfrom
SchwarzDigits:keypackage-validate-supports

Conversation

@mtrossbach

Copy link
Copy Markdown
Contributor

KeyPackageIn::validate doesn't check whether the crypto provider supports the key package's ciphersuite before it verifies the signatures. If the provider doesn't support it, signature verification fails and the caller gets InvalidLeafNodeSignature, even though the signature is valid. I ran into this with the libcrux provider, which only does Ed25519: validating a P-256 key package returns InvalidLeafNodeSignature. For something like a delivery service that validates key packages on its own this is misleading, because it looks like a bad signature and not like an unsupported ciphersuite.

#2109 added a supports() check and UnsupportedCiphersuite errors to group creation, StagedWelcome and the external commit builder. KeyPackageIn::validate is another public entry point that takes a ciphersuite from the wire, and it didn't get the check. This PR adds it as the first step of validate, plus a KeyPackageVerifyError::UnsupportedCiphersuite(Ciphersuite) variant. The test uses the RestrictedProvider from test-utils and fails without the change.

Two smaller things in the same area:

  • AddProposalIn::validate did the full key package validation (both signature checks) before comparing the key package's ciphersuite with the group's. Now the comparison comes first. The test corrupts the key package signature and checks that the ciphersuite mismatch is reported, not the signature.
  • A test that a GREASE value in the ciphersuite field of a KeyPackage is rejected when deserializing. This already works, GREASE values aren't in the Ciphersuite table, but there was no test for it.

Context: I've been looking into how crypto providers could bring their own ciphersuites (#1915) and what that would touch in the code base, and I'll probably have something to propose on that at some point. This came up while going through the ciphersuite checks. It's independent of that though.

KeyPackageIn::validate verified the leaf node and key package signatures
with the signature scheme of the key package's ciphersuite, without first
asking the crypto provider whether it supports that ciphersuite. When it
does not, signature verification fails for the wrong reason and the caller
gets InvalidLeafNodeSignature for a key package whose signature is valid.
With the libcrux provider, which only handles Ed25519, that is every P-256
key package.

Group creation, StagedWelcome and the external commit builder got a
supports() check and an UnsupportedCiphersuite error in openmls#2109. validate is
another public entry point that takes a ciphersuite from the wire and did
not. This adds the check as the first step, with a matching
KeyPackageVerifyError::UnsupportedCiphersuite variant, and a test with the
RestrictedProvider that fails without it.

Two smaller things in the same area: AddProposalIn::validate now compares
the key package's ciphersuite with the group's before running the full key
package validation instead of after, and a test pins down that a GREASE
value in a KeyPackage's own ciphersuite field fails to deserialize.
@mtrossbach
mtrossbach force-pushed the keypackage-validate-supports branch from ba409d6 to 26c9566 Compare September 2, 2026 11:39

@kkohbrok kkohbrok left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your continued contributions! This generally looks good to merge.

@kkohbrok
kkohbrok enabled auto-merge (squash) October 5, 2026 06:45
@kkohbrok
kkohbrok merged commit fe0567e into openmls:main Oct 5, 2026
48 checks passed
MicroDroid pushed a commit to MicroDroid/openmls that referenced this pull request Nov 17, 2026
KeyPackageIn::validate verified the leaf node and key package signatures
with the signature scheme of the key package's ciphersuite, without first
asking the crypto provider whether it supports that ciphersuite. When it
does not, signature verification fails for the wrong reason and the caller
gets InvalidLeafNodeSignature for a key package whose signature is valid.
With the libcrux provider, which only handles Ed25519, that is every P-256
key package.

Group creation, StagedWelcome and the external commit builder got a
supports() check and an UnsupportedCiphersuite error in openmls#2109. validate is
another public entry point that takes a ciphersuite from the wire and did
not. This adds the check as the first step, with a matching
KeyPackageVerifyError::UnsupportedCiphersuite variant, and a test with the
RestrictedProvider that fails without it.

Two smaller things in the same area: AddProposalIn::validate now compares
the key package's ciphersuite with the group's before running the full key
package validation instead of after, and a test pins down that a GREASE
value in a KeyPackage's own ciphersuite field fails to deserialize.

Co-authored-by: Konrad Kohbrok <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants