Skip to content

Conversation

@kkoyung
Copy link
Member

@kkoyung kkoyung commented Nov 15, 2025

We currently use the crate aws-lc-rs for HKDF in the WebCrypto API. When generating output bytes from the output of HKDF-Expand operation (OKM, Output Key Material), it enforces the requested output length must match the length of key type (see error condition of Okm::fill at https://docs.rs/aws-lc-rs/1.14.1/aws_lc_rs/hkdf/struct.Okm.html#method.fill). However, according to the WebCrypto API specification, user should be allowed to choose the output length (https://w3c.github.io/webcrypto/#hkdf-operations-derive-bits). The restriction from aws-lc-rs causes several HKDF-related WPT tests to fail.

This patch switches to use a more flexible crate hkdf (https://crates.io/crates/hkdf) for implementing HKDF in our WebCrypto API, and allowing variable length output. This helps to make those HKDF-related WPT tests pass.

Testing: Pass some WPT tests that were expected to fail.

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
@kkoyung kkoyung requested a review from gterzian as a code owner November 15, 2025 08:53
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 15, 2025
Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

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

Another big chunk of passing chunks 🎉

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Nov 15, 2025
@TimvdLippe TimvdLippe added this pull request to the merge queue Nov 15, 2025
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 15, 2025
Merged via the queue into servo:main with commit 33443d2 Nov 15, 2025
35 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 15, 2025
@kkoyung kkoyung deleted the hkdf-rustcrypto branch November 15, 2025 10:10
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.

3 participants