This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
This is trivial to shim, but inexplicably absent from the spec. const SPKI_PREFIX = { "P-256": new Uint8Array([ 48, 86, 48, 16, 6, 4, 43, 129, 4, 112, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0]) // add more }; function importRawPublicKey(pub, alg, usages) { var prefix = SPKI_PREFIX[alg.namedCurve]; var spki = new Uint8Array(prefix.byteLength + pub.byteLength); spki.set(prefix, 0); spki.set(pub, prefix.byteLength); return crypto.subtle.importKey('spki', spki, alg, true, usages); }; function exportRawPublicKey(key, alg) { return crypto.subtle.exportKey('spki', key) .then(spki => new Uint8Array(spki, SPKI_PREFIX[alg.namedCurve])); };
I missed this first time around. *** This bug has been marked as a duplicate of bug 27447 ***