Why can't you derive a HKDF key with with WebCrypto?

Viewed 267

I want to take a password and run it through PBKDF2 to create a master key. I then want to take that and run it through HKDF to create multiple keys. It seems as though crypto.subtle.deriveKey will not accept HKDF as a derivedKeyAlgorithm.

In other words I can't get something like this to work

const kd_algo = { name: "PBKDF2", hash: "SHA-256", salt: pbkdf2_salt, iterations: 100000 }
const master_key = await crypto.subtle.deriveKey(kd_algo, password, { name: "HKDF" }, false, ["deriveKey"])

but this will

const kd_algo = { name: "PBKDF2", hash: "SHA-256", salt: pbkdf2_salt, iterations: 1000000 }
const master_key_material = await crypto.subtle.deriveBits(kd_algo, password, 256)
const master_key = await crypto.subtle.importKey("raw", master_key_material, "HKDF", false, ["deriveKey"])

This makes no sense.

0 Answers
Related