[Bug 28578] New: No "raw" export/import for ECDSA

https://www.w3.org/Bugs/Public/show_bug.cgi?id=28578

            Bug ID: 28578
           Summary: No "raw" export/import for ECDSA
           Product: Web Cryptography
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Web Cryptography API Document
          Assignee: sleevi@google.com
          Reporter: martin.thomson@gmail.com
                CC: public-webcrypto@w3.org

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]));
  };

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Tuesday, 28 April 2015 17:01:23 UTC