w3c / webcrypto

The W3C Web Cryptography API
https://w3c.github.io/webcrypto/
Other
266 stars 55 forks source link

HKDF&PBKDF2: Dead write to "extractable" bit during importKey operation #377

Closed BenWiederhake closed 3 weeks ago

BenWiederhake commented 3 weeks ago

SubtleCrypto.importKey invokes the algorithm's importKey operation in step 3, and overwrites the [[extractable]] internal slot in step 10, regardless what the algorithm wrote into that slot: Bildschirmfoto_2024-10-25_11-24-49

So why does HKDF's importKey operation write false into that slot? Bildschirmfoto_2024-10-25_11-23-41

I'm not sure what happened here, and therefore not sure how to resolve this issue:

EDIT: Also affects PBKDF2's importKey.

Found while combing through the docs for #376, which I in turn found while implementing this from scratch. Shameless plug: Ladybird :)

twiss commented 3 weeks ago

Both algorithms say:

  1. If extractable is not false, then throw a SyntaxError.

So both options are essentially true: extractable must be false, but also the write is dead and can be removed in favor of the one in importKey() as you noted.