Skip to content

fix(webauthn): allow PRF inputs of any length (fix #209)#211

Open
AlfioEmanueleFresta wants to merge 2 commits into
masterfrom
issue-209
Open

fix(webauthn): allow PRF inputs of any length (fix #209)#211
AlfioEmanueleFresta wants to merge 2 commits into
masterfrom
issue-209

Conversation

@AlfioEmanueleFresta
Copy link
Copy Markdown
Member

@AlfioEmanueleFresta AlfioEmanueleFresta commented May 12, 2026

Closes #209.

Split PRFValue into PrfInputValue (Vec<u8>, variable-length salt inputs) and PrfOutputValue ([u8; 32], fixed-length hmac-secret outputs).

Spec: W3C WebAuthn L3 §10.1.4 — PRF salt inputs are BufferSources of any length; the client hashes them via SHA-256("WebAuthn PRF" || 0x00 || input) before CTAP2 hmac-secret. The hashing was already in place; only the input type was over-constrained.

Tests

  • Unit: variable-length (1/16/31/33/64/256 bytes), empty input, eval_by_credential variable-length, plus un-#[ignore]'d test_request_from_json_prf_extension.
  • Virtual device: test_webauthn_prf_variable_length_input exercises 0/7/100-byte salts end-to-end and asserts PRF determinism.

Split PRFValue into PrfInputValue (Vec<u8>) for variable-length salt
inputs and PrfOutputValue ([u8; 32]) for the fixed-size hmac-secret
output. Per W3C WebAuthn L3 §10.1.4, PRF salt inputs are BufferSources
of any length; the existing SHA-256 prefix-hashing already produces a
32-byte salt for CTAP2 hmac-secret regardless of input length.

Adds unit tests for variable-length and empty inputs, and a virtual-
device test exercising 0-byte, 7-byte, and 100-byte salts.
@AlfioEmanueleFresta AlfioEmanueleFresta requested review from iinuwa and msirringhaus and removed request for iinuwa May 12, 2026 18:36
@AlfioEmanueleFresta AlfioEmanueleFresta marked this pull request as ready for review May 12, 2026 18:36
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.

PRF Inputs incorrectly required to be 32 bytes

1 participant