w3c / w3c/webcrypto

Allow `derivedKeyAlgorithm == 'HKDF'` for `deriveKey()`

Open
#314 4 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
294
Forks
78
PR merge metrics
No merged PRs in 30d

Description

I would like to use deriveKey with PBKDF2 to derive a primary key from a primary password. I would then like to use HKDF to derive multiple independent operational keys (using different info parameters) from this primary key.

This feels like a fairly basic setup. However, I cannot find a "proper" way to realize it after perusing the WebCrypto documentation on MDN.

Here are two possible approaches I want to avoid:

  • Derive the operational keys from the primary password, possibly using different salts
    This is highly inefficient, and not an acceptable solution. PBKDF2 is, by design, costly. Needing to run PBKDF2 ten times as often will require me to reduce the iteration count by the same factor to remain within responsiveness targets.
  • Derive some number of bits from the primary password, then use importKey (with algorithm == 'HKDF')
    This is a feasible workaround. However, the point of deriveKey seems exactly to avoid needing to juggle raw key data in memory.

To me, the easiest medium-term solution to this issue would be to permit 'HKDF' as a value for deriveKey's derivedKeyAlgorithm - or potentially some object that specifies the number of bits required, where necessary?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository files or tests. Start with the linked MDN deriveKey documentation and the WebCrypto deriveKey specification entry, then determine how HKDF should be represented as derivedKeyAlgorithm and how required key length is specified. Done means the standards behavior is agreed and documented with suitable conformance coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, cryptography, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.