Bug 24830 (part 1) Provide public value for ECDH deriveKey as a Key and add raw import/export for public keys
authorMark Watson <watsonm@netflix.com>
Fri, 28 Feb 2014 15:56:46 -0800
changeset 142 11dcc989d87b
parent 141 7f7c2917970d
child 143 652347d84a62
Bug 24830 (part 1) Provide public value for ECDH deriveKey as a Key and add raw import/export for public keys
spec/Overview-WebCryptoAPI.xml
spec/Overview.html
--- a/spec/Overview-WebCryptoAPI.xml	Fri Feb 28 09:00:20 2014 -0800
+++ b/spec/Overview-WebCryptoAPI.xml	Fri Feb 28 15:56:46 2014 -0800
@@ -4852,6 +4852,17 @@
               </dl>
             </p>
           </div>
+          <div id="EcKeyImportParams-dictionary" class="section">
+            <h4>EcKeyImportParams dictionary</h4>
+            <x:codeblock language="idl">
+typedef DOMString <a href="#dfn-NamedCurve">NamedCurve</a>;
+
+dictionary <dfn id="dfn-EcKeyImportParams">EcKeyImportParams</dfn> : <a href="#dfn-Algorithm">Algorithm</a> {
+  <span class="comment">// A named curve</span>
+  <a href="#dfn-NamedCurve">NamedCurve</a> <dfn id="#dfn-EcKeyImportParams-namedCurve">namedCurve</dfn>;
+};
+            </x:codeblock>
+          </div>
 
           <div id="ecdsa-operations" class="section">
             <h4>Operations</h4>
@@ -5072,7 +5083,7 @@
                 </tr>
                 <tr>
                   <td>importKey</td>
-                  <td>None</td>
+                  <td><a href="#dfn-EcKeyImportParams">EcKeyImportParams</a></td>
                   <td><a href="#dfn-Key">Key</a></td>
                 </tr>
                 <tr>
@@ -5090,14 +5101,9 @@
 
 dictionary <dfn id="dfn-EcdhKeyDeriveParams">EcdhKeyDeriveParams</dfn> : <a href="#dfn-Algorithm">Algorithm</a> {
   <span class="comment">// The peer's EC public key.</span>
-  ECPoint public;
+  <a href="#dfn-Key">Key</a> public;
 };
             </x:codeblock>
-            <p>
-              The <a href="#dfn-ECPoint">ECPoint</a> typedef is a <code>Uint8Array</code> holding an
-              elliptic curve point. An elliptic curve point is converted to an array of Uint8
-              elements using the procedure specified in <a href="#X9.62">X9.62</a> Annex A.5.7.
-            </p>
           </div>
           <div id="ecdh-operations" class="section">
             <h4>Operations</h4>
@@ -5263,10 +5269,31 @@
                 </li>
                 <li>
                   <p>
+                    Let <var>publicKey</var> be the
+                    <a href="#dfn-EcdhKeyDeriveParams-public">public</a> property of
+                    <var>normalizedAlgorithm</var>.
+                  </p>
+                </li>
+                <li>
+                  <p>
+                    If the <a href="#dfn-KeyAlgorithm-name">name</a> property of the
+                    <a href="#dfn-Key-algorithm">algorithm</a> property of <var>publicKey</var> is
+                    not a case-sensitive string match for
+                    <code>"ECDH"</code>, terminate this algorithm with an error.
+                  </p>
+                </li>
+                <li>
+                  <p>
+                    If the <a href="#dfn-Key-type">type</a> property of <var>publicKey</var>
+                    is not a case-sensitive string match for
+                    <code>"public"</code>, terminate this algorithm with an error.
+                  </p>
+                </li>
+                <li>
+                  <p>
                     Perform the ECDH primitive specified in <a href="#X9.63">X9.63</a> Section 5.4.1
-                    with <var>key</var> as the EC private key <var>d</var> and the
-                    <a href="#dfn-EcdhKeyDeriveParams-public">public</a> property of
-                    <var>normalizedAlgorithm</var> as the EC public key <var>Q</var>.
+                    with <var>key</var> as the EC private key <var>d</var> and the EC public key
+                    represented by <var>publicKey</var> as the EC public key <var>Q</var>.
                     <dl class="switch">
                       <dt>If performing the operation results in an error:</dt>
                       <dd>Terminate this algorithm with an error.</dd>
@@ -5299,6 +5326,141 @@
                 </li>
               </ol>
             </dd>
+            <dt>Import key</dt>
+            <dd>
+              <dl class="switch">
+                <dt>If <var>format</var> is a case-sensitive string match for <code>"raw"</code>:</dt>
+                <dd>
+                  <ol>
+                    <li>
+                      <p>
+                        If any of the members of
+                        <a href="#dfn-EcKeyImportParams">EcKeyImportParams</a> are not present in
+                        <var>normalizedAlgorithm</var> then terminate this algorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        If the <a href="#dfn-EcKeyImportParams-namedCurve">namedCurve</a> property
+                        of <var>normalizedAlgorithm</var> is not a case-sensitive string match for
+                        a <a href="#dfn-NamedCurve">named curve</a>, terminate this algorithm with
+                        an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        If <var>usages</var> is not the empty list, terminate this algorithm with
+                        an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        If <var>extractable</var> is false, terminate this algorithm with
+                        an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>Q</var> be the elliptic curve point on the curve identified by the
+                        <a href="#dfn-EcKeyImportParams-namedCurve">namedCurve</a> property
+                        of <var>normalizedAlgorithm</var> identified by interpreting
+                        <var>keyData</var> according to <a href="#X9.62">X9.62</a> Annex A.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>algorithm</var> be a new
+                        <a href="#dfn-EcKeyAlgorithm">EcKeyAlgorithm</a> object.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Set the <a href="#dfn-KeyAlgorith-name">name</a> property of
+                        <var>algorithm</var> to <code>"ECDH"</code>.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Set the <a href="#dfn-KeyAlgorith-namedCurve">namedCurve</a> property of
+                        <var>algorithm</var> to equal the
+                        <a href="#dfn-EcKeyImportParams-namedCurve">namedCurve</a> property
+                        of <var>normalizedAlgorithm</var>.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>key</var> be a new <a href="#dfn-Key">Key</a> object.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Set the <a href="#dfn-Key-type">type</a> property of <var>key</var> to
+                        <code>"public"</code>
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Set the <a href="#dfn-Key-algorithm">algorithm</a> property of
+                        <var>key</var> to <var>algorithm</var>.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Set the <a href="#dfn-Key-usages">usages</a> property of
+                        <var>key</var> to <var>usages</var>.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Set the <a href="#dfn-Key-extractable">extractable</a> property of
+                        <var>key</var> to <var>extractable</var>.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Return <var>key</var>
+                      </p>
+                    </li>
+                  </ol>
+                </dd>
+                <dt>Otherwise:</dt>
+                <dd>Terminate this algorithm with an error.</dd>
+              </dl>
+            </dd>
+            <dt>Export key</dt>
+            <dd>
+              <dl class="switch">
+                <dt>
+                  If <var>format</var> is a case-sensitive string match for <code>"raw"</code>:
+                </dt>
+                <dd>
+                  <ol>
+                    <li>
+                      <p>
+                        If the <a href="#dfn-Key-type">type</a> property of <var>key</var> is not
+                        a case-sensitive string match for <code>"public"</code>, terminate this
+                        algorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>data</var> be an octet string representing the Elliptic Curve point
+                        <var>Q</var> represented by <var>key</var> according to
+                        <a href="#X9.62">X9.62</a> Annex A.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Return a new <a href="#dfn-ArrayBuffer">ArrayBuffer</a> containing
+                        <var>data</var>.
+                      </p>
+                    </li>
+                  </ol>
+                </dd>
+                <dt>Otherwise:</dt>
+                <dd>Terminate this algorithm with an error.</dd>
+              </dl>
+            </dd>
           </div>
         </div>
 
--- a/spec/Overview.html	Fri Feb 28 09:00:20 2014 -0800
+++ b/spec/Overview.html	Fri Feb 28 15:56:46 2014 -0800
@@ -134,7 +134,7 @@
 
     <div id="toc">
       <h2>Table of Contents</h2>
-      <div class="toc"><ul><li><a href="#introduction">1. Introduction</a></li><li><a href="#use-cases">2. Use Cases</a><ul><li><a href="#multifactor-authentication">2.1. Multi-factor Authentication</a></li><li><a href="#protected-document">2.2. Protected Document Exchange</a></li><li><a href="#cloud-storage">2.3. Cloud Storage</a></li><li><a href="#document-signing">2.4. Document Signing</a></li><li><a href="#data-integrity-protection">2.5. Data Integrity Protection</a></li><li><a href="#secure-messaging">2.6. Secure Messaging</a></li><li><a href="#jose">2.7. Javascript Object Signing and Encryption (JOSE)</a></li></ul></li><li><a href="#conformance">3. Conformance</a></li><li><a href="#scope">4. Scope</a><ul><li><a href="#scope-abstraction">4.1. Level of abstraction</a></li><li><a href="#scope-algorithms">4.2. Cryptographic algorithms</a></li><li><a href="#scope-operations">4.3. Operations</a></li><li><a href="#scope-out-of-scope">4.4. Out of scope</a></li></ul></li><li><a href="#security">5. Security considerations</a><ul><li><a href="#security-implementers">5.1. Security considerations for implementers</a></li><li><a href="#security-developers">5.2. Security considerations for authors</a></li></ul></li><li><a href="#privacy">6. Privacy considerations</a></li><li><a href="#dependencies">7. Dependencies</a></li><li><a href="#terminology">8. Terminology</a></li><li><a href="#RandomSource-interface">9. RandomSource interface</a><ul><li><a href="#RandomSource-description">9.1. Description</a></li><li><a href="#RandomSource-interface-methods">9.2. Methods and Parameters</a><ul><li><a href="#RandomSource-method-getRandomValues">9.2.1. The getRandomValues method</a></li></ul></li></ul></li><li><a href="#algorithm-dictionary">10. Algorithm dictionary</a><ul><li><a href="#algorithm-dictionary-members">10.1. Algorithm Dictionary Members</a></li></ul></li><li><a href="#key-algorithm-interface">11. KeyAlgorithm interface</a><ul><li><a href="#key-algorithm-interface-description">11.1. Description</a></li><li><a href="#key-algorithm-interface-members">11.2. KeyAlgorithm interface members</a></li></ul></li><li><a href="#key-interface">12. Key interface</a><ul><li><a href="#key-interface-description">12.1. Description</a></li><li><a href="#key-interface-types">12.2. Key interface data types</a></li><li><a href="#key-interface-members">12.3. Key interface members</a></li><li><a href="#key-interface-clone">12.4. Structured clone algorithm</a></li></ul></li><li><a href="#crypto-interface">13. Crypto interface</a></li><li><a href="#subtlecrypto-interface">14. SubtleCrypto interface</a><ul><li><a href="#subtlecrypto-interface-description">14.1. Description</a></li><li><a href="#subtlecrypto-interface-datatypes">14.2. Data Types</a></li><li><a href="#subtlecrypto-interface-methods">14.3. Methods and Parameters</a><ul><li><a href="#SubtleCrypto-method-encrypt">14.3.1. The encrypt method</a></li><li><a href="#SubtleCrypto-method-decrypt">14.3.2. The decrypt method</a></li><li><a href="#SubtleCrypto-method-sign">14.3.3. The sign method</a></li><li><a href="#SubtleCrypto-method-verify">14.3.4. The verify method</a></li><li><a href="#SubtleCrypto-method-digest">14.3.5. The digest method</a></li><li><a href="#SubtleCrypto-method-generateKey">14.3.6. The generateKey method</a></li><li><a href="#SubtleCrypto-method-deriveKey">14.3.7. The deriveKey method</a></li><li><a href="#SubtleCrypto-method-deriveBits">14.3.8. The deriveBits method</a></li><li><a href="#SubtleCrypto-method-importKey">14.3.9. The importKey method</a></li><li><a href="#SubtleCrypto-method-exportKey">14.3.10. The exportKey method</a></li><li><a href="#SubtleCrypto-method-wrapKey">14.3.11. The wrapKey method</a></li><li><a href="#SubtleCrypto-method-unwrapKey">14.3.12. The unwrapKey method</a></li></ul></li></ul></li><li><a href="#WorkerCrypto-interface">15. WorkerCrypto interface</a><ul><li><a href="#WorkerCrypto-description">15.1. Description</a></li></ul></li><li><a href="#big-integer">16. BigInteger</a></li><li><a href="#keypair">17. KeyPair</a></li><li><a href="#algorithms">18. Algorithms</a><ul><li><a href="#algorithms-index">18.1. Registered algorithms</a></li><li><a href="#recommended-algorithms">18.2. Recommended algorithms</a></li><li><a href="#defining-an-algorithm">18.3. Defining an algorithm</a><ul><li><a href="#recognized-algorithm-name">18.3.1. Recognized algorithm name</a></li><li><a href="#supported-operations">18.3.2. Supported operations</a></li><li><a href="#algorithm-specific-params">18.3.3. Algorithm-specific parameters</a></li><li><a href="#algorithm-result">18.3.4. Algorithm results</a></li><li><a href="#algorithm-alias">18.3.5. Algorithm aliases</a></li></ul></li><li><a href="#rsaes-pkcs1">18.4. RSAES-PKCS1-v1_5</a><ul><li><a href="#rsaes-pkcs1-description">18.4.1. Description</a></li><li><a href="#rsaes-pkcs1-registration">18.4.2. Registration</a></li><li><a href="#RsaKeyGenParams-dictionary">18.4.3. RsaKeyGenParams dictionary</a></li><li><a href="#RsaKeyAlgorithm-interface">18.4.4. RsaKeyAlgorithm interface</a></li><li><a href="#rsaes-pkcs1-operations">18.4.5. Operations</a></li></ul></li><li><a href="#rsassa-pkcs1">18.5. RSASSA-PKCS1-v1_5</a><ul><li><a href="#rsassa-pkcs1-description">18.5.1. Description</a></li><li><a href="#rsassa-pkcs1-registration">18.5.2. Registration</a></li><li><a href="#RsaHashedKeyGenParams-dictionary">18.5.3. RsaHashedKeyGenParams dictionary</a></li><li><a href="#RsaHashedKeyAlgorithm-interface">18.5.4. RsaHashedKeyAlgorithm interface</a></li><li><a href="#RsaHashedImportParams-dictionary">18.5.5. RsaHashedImportParams dictionary</a></li><li><a href="#rsassa-pkcs1-operations">18.5.6. Operations</a></li></ul></li><li><a href="#rsa-pss">18.6. RSA-PSS</a><ul><li><a href="#rsa-pss-description">18.6.1. Description</a></li><li><a href="#rsa-pss-registration">18.6.2. Registration</a></li><li><a href="#RsaPssParams-dictionary">18.6.3. RsaPssParams dictionary</a></li><li><a href="#rsa-pss-operations">18.6.4. Operations</a></li></ul></li><li><a href="#rsa-oaep">18.7. RSA-OAEP</a><ul><li><a href="#rsa-oaep-description">18.7.1. Description</a></li><li><a href="#rsa-oaep-registration">18.7.2. Registration</a></li><li><a href="#rsa-oaep-params">18.7.3. RsaOaepParams dictionary</a></li><li><a href="#rsa-oaep-operations">18.7.4. Operations</a></li></ul></li><li><a href="#ecdsa">18.8. ECDSA</a><ul><li><a href="#ecdsa-description">18.8.1. Description</a></li><li><a href="#ecdsa-registration">18.8.2. Registration</a></li><li><a href="#EcdsaParams-dictionary">18.8.3. EcdsaParams dictionary</a></li><li><a href="#EcKeyAlgorithm-interface">18.8.4. </a></li><li><a href="#EcKeyGenParams-dictionary">18.8.5. EcKeyGenParams dictionary</a></li><li><a href="#ecdsa-operations">18.8.6. Operations</a></li></ul></li><li><a href="#ecdh">18.9. ECDH</a><ul><li><a href="#ecdh-description">18.9.1. Description</a></li><li><a href="#ecdh-registration">18.9.2. Registration</a></li><li><a href="#dh-EcdhKeyDeriveParams">18.9.3. EcdhKeyDeriveParams dictionary</a></li><li><a href="#ecdh-operations">18.9.4. Operations</a></li></ul></li><li><a href="#aes-ctr">18.10. AES-CTR</a><ul><li><a href="#aes-ctr-description">18.10.1. Description</a></li><li><a href="#aes-ctr-registration">18.10.2. Registration</a></li><li><a href="#aes-ctr-params">18.10.3. AesCtrParams dictionary</a></li><li><a href="#AesKeyAlgorithm-interface">18.10.4. </a></li><li><a href="#aes-keygen-params">18.10.5. AesKeyGenParams dictionary</a></li><li><a href="#aes-derivedkey-params">18.10.6. AesDerivedKeyParams dictionary</a></li><li><a href="#aes-ctr-operations">18.10.7. Operations</a></li></ul></li><li><a href="#aes-cbc">18.11. AES-CBC</a><ul><li><a href="#aes-cbc-description">18.11.1. Description</a></li><li><a href="#aes-cbc-registration">18.11.2. Registration</a></li><li><a href="#aes-cbc-params">18.11.3. AesCbcParams dictionary</a></li><li><a href="#aes-cbc-operations">18.11.4. Operations</a></li></ul></li><li><a href="#aes-cmac">18.12. AES-CMAC</a><ul><li><a href="#aes-cmac-description">18.12.1. Description</a></li><li><a href="#aes-cmac-registration">18.12.2. Registration</a></li><li><a href="#aes-keygen-params">18.12.3. AesCmacParams dictionary</a></li><li><a href="#aes-cmac-operations">18.12.4. Operations</a></li></ul></li><li><a href="#aes-gcm">18.13. AES-GCM</a><ul><li><a href="#aes-gcm-description">18.13.1. Description</a></li><li><a href="#aes-gcm-registration">18.13.2. Registration</a></li><li><a href="#aes-gcm-params">18.13.3. AesGcmParams dictionary</a></li><li><a href="#aes-gcm-operations">18.13.4. Operations</a></li></ul></li><li><a href="#aes-cfb">18.14. AES-CFB</a><ul><li><a href="#aes-cfb-description">18.14.1. Description</a></li><li><a href="#aes-cfb-registration">18.14.2. Registration</a></li><li><a href="#aes-cfb-params">18.14.3. AesCfbParams dictionary</a></li><li><a href="#aes-cfb-operations">18.14.4. Operations</a></li></ul></li><li><a href="#aes-kw">18.15. AES-KW</a><ul><li><a href="#aes-kw-description">18.15.1. Description</a></li><li><a href="#aes-kw-registration">18.15.2. Registration</a></li><li><a href="#aes-kw-operations">18.15.3. Operations</a></li></ul></li><li><a href="#hmac">18.16. HMAC</a><ul><li><a href="#hmac-description">18.16.1. Description</a></li><li><a href="#hmac-registration">18.16.2. Registration</a></li><li><a href="#hmac-importparams">18.16.3. HmacImportParams dictionary</a></li><li><a href="#hmac-keyalgorithm">18.16.4. HmacKeyAlgorithm interface</a></li><li><a href="#hmac-keygen-params">18.16.5. HmacKeyGenParams dictionary</a></li><li><a href="#hmac-derivedkey-params">18.16.6. HmacDerivedKeyParams dictionary</a></li><li><a href="#hmac-operations">18.16.7. Operations</a></li></ul></li><li><a href="#dh">18.17. Diffie-Hellman</a><ul><li><a href="#dh-description">18.17.1. Description</a></li><li><a href="#dh-registration">18.17.2. Registration</a></li><li><a href="#dh-DhKeyGenParams">18.17.3. DhKeyGenParams dictionary</a></li><li><a href="#dh-DhKeyAlgorithm">18.17.4. DhKeyAlgorithm interface</a></li><li><a href="#dh-DhKeyDeriveParams">18.17.5. DhKeyDeriveParams dictionary</a></li><li><a href="#dh-DhImportKeyParams">18.17.6. DhImportKeyParams dictionary</a></li><li><a href="#dh-operations">18.17.7. Operations</a></li></ul></li><li><a href="#sha">18.18. SHA</a><ul><li><a href="#sha-description">18.18.1. Description</a></li><li><a href="#sha-registration">18.18.2. Registration</a></li><li><a href="#sha-operations">18.18.3. Operations</a></li></ul></li><li><a href="#concatkdf">18.19. Concat KDF</a><ul><li><a href="#concatkdf-description">18.19.1. Description</a></li><li><a href="#concatkdf-registration">18.19.2. Registration</a></li><li><a href="#concat-params">18.19.3. ConcatParams dictionary</a></li><li><a href="#concat-operations">18.19.4. Operations</a></li></ul></li><li><a href="#hkdf-ctr">18.20. HKDF-CTR</a><ul><li><a href="#hkdf-ctr-description">18.20.1. Description</a></li><li><a href="#hkdf-ctr-registration">18.20.2. Registration</a></li><li><a href="#hkdf-ctr-params">18.20.3. HkdfCtrParams dictionary</a></li><li><a href="#hkdf2-ctr-operations">18.20.4. Operations</a></li></ul></li><li><a href="#pbkdf2">18.21. PBKDF2</a><ul><li><a href="#pbkdf2-description">18.21.1. Description</a></li><li><a href="#pbkdf2-registration">18.21.2. Registration</a></li><li><a href="#pbkdf2-params">18.21.3. Pbkdf2Params dictionary</a></li><li><a href="#pbkdf2-operations">18.21.4. Operations</a></li></ul></li></ul></li><li><a href="#algorithm-normalizing-rules">19. Algorithm normalizing rules</a></li><li><a href="#examples-section">20. JavaScript Example Code</a><ul><li><a href="#examples-signing">20.1. Generate a signing key pair, sign some data</a></li><li><a href="#examples-symmetric-encryption">20.2. Symmetric Encryption</a></li></ul></li><li><a href="#iana-section">21. IANA Considerations</a><ul><li><a href="#iana-section-jws-jwa">21.1. JSON Web Signature and Encryption Algorithms Registration</a></li><li><a href="#iana-section-jwk">21.2. JSON Web Key Parameters Registry</a></li></ul></li><li><a href="#acknowledgements-section">22. Acknowledgements</a></li><li><a href="#references">23. References</a><ul><li><a href="#normative-references">23.1. Normative References</a></li><li><a href="#informative-references">23.2. Informative References</a></li></ul></li></ul><ul><li><a href="#jwk-mapping">A. Mapping between JSON Web Key / JSON Web Algorithm</a><ul><li><a href="#jwk-mapping-alg">A.1. Algorithm mappings</a></li><li><a href="#jwk-mapping-usage">A.2. Usage mapping</a></li></ul></li><li><a href="#spki-mapping">B. Mapping between Algorithm and SubjectPublicKeyInfo</a></li><li><a href="#pkcs8-mapping">C. Mapping between Algorithm and PKCS#8 PrivateKeyInfo</a></li></ul></div>
+      <div class="toc"><ul><li><a href="#introduction">1. Introduction</a></li><li><a href="#use-cases">2. Use Cases</a><ul><li><a href="#multifactor-authentication">2.1. Multi-factor Authentication</a></li><li><a href="#protected-document">2.2. Protected Document Exchange</a></li><li><a href="#cloud-storage">2.3. Cloud Storage</a></li><li><a href="#document-signing">2.4. Document Signing</a></li><li><a href="#data-integrity-protection">2.5. Data Integrity Protection</a></li><li><a href="#secure-messaging">2.6. Secure Messaging</a></li><li><a href="#jose">2.7. Javascript Object Signing and Encryption (JOSE)</a></li></ul></li><li><a href="#conformance">3. Conformance</a></li><li><a href="#scope">4. Scope</a><ul><li><a href="#scope-abstraction">4.1. Level of abstraction</a></li><li><a href="#scope-algorithms">4.2. Cryptographic algorithms</a></li><li><a href="#scope-operations">4.3. Operations</a></li><li><a href="#scope-out-of-scope">4.4. Out of scope</a></li></ul></li><li><a href="#security">5. Security considerations</a><ul><li><a href="#security-implementers">5.1. Security considerations for implementers</a></li><li><a href="#security-developers">5.2. Security considerations for authors</a></li></ul></li><li><a href="#privacy">6. Privacy considerations</a></li><li><a href="#dependencies">7. Dependencies</a></li><li><a href="#terminology">8. Terminology</a></li><li><a href="#RandomSource-interface">9. RandomSource interface</a><ul><li><a href="#RandomSource-description">9.1. Description</a></li><li><a href="#RandomSource-interface-methods">9.2. Methods and Parameters</a><ul><li><a href="#RandomSource-method-getRandomValues">9.2.1. The getRandomValues method</a></li></ul></li></ul></li><li><a href="#algorithm-dictionary">10. Algorithm dictionary</a><ul><li><a href="#algorithm-dictionary-members">10.1. Algorithm Dictionary Members</a></li></ul></li><li><a href="#key-algorithm-interface">11. KeyAlgorithm interface</a><ul><li><a href="#key-algorithm-interface-description">11.1. Description</a></li><li><a href="#key-algorithm-interface-members">11.2. KeyAlgorithm interface members</a></li></ul></li><li><a href="#key-interface">12. Key interface</a><ul><li><a href="#key-interface-description">12.1. Description</a></li><li><a href="#key-interface-types">12.2. Key interface data types</a></li><li><a href="#key-interface-members">12.3. Key interface members</a></li><li><a href="#key-interface-clone">12.4. Structured clone algorithm</a></li></ul></li><li><a href="#crypto-interface">13. Crypto interface</a></li><li><a href="#subtlecrypto-interface">14. SubtleCrypto interface</a><ul><li><a href="#subtlecrypto-interface-description">14.1. Description</a></li><li><a href="#subtlecrypto-interface-datatypes">14.2. Data Types</a></li><li><a href="#subtlecrypto-interface-methods">14.3. Methods and Parameters</a><ul><li><a href="#SubtleCrypto-method-encrypt">14.3.1. The encrypt method</a></li><li><a href="#SubtleCrypto-method-decrypt">14.3.2. The decrypt method</a></li><li><a href="#SubtleCrypto-method-sign">14.3.3. The sign method</a></li><li><a href="#SubtleCrypto-method-verify">14.3.4. The verify method</a></li><li><a href="#SubtleCrypto-method-digest">14.3.5. The digest method</a></li><li><a href="#SubtleCrypto-method-generateKey">14.3.6. The generateKey method</a></li><li><a href="#SubtleCrypto-method-deriveKey">14.3.7. The deriveKey method</a></li><li><a href="#SubtleCrypto-method-deriveBits">14.3.8. The deriveBits method</a></li><li><a href="#SubtleCrypto-method-importKey">14.3.9. The importKey method</a></li><li><a href="#SubtleCrypto-method-exportKey">14.3.10. The exportKey method</a></li><li><a href="#SubtleCrypto-method-wrapKey">14.3.11. The wrapKey method</a></li><li><a href="#SubtleCrypto-method-unwrapKey">14.3.12. The unwrapKey method</a></li></ul></li></ul></li><li><a href="#WorkerCrypto-interface">15. WorkerCrypto interface</a><ul><li><a href="#WorkerCrypto-description">15.1. Description</a></li></ul></li><li><a href="#big-integer">16. BigInteger</a></li><li><a href="#keypair">17. KeyPair</a></li><li><a href="#algorithms">18. Algorithms</a><ul><li><a href="#algorithms-index">18.1. Registered algorithms</a></li><li><a href="#recommended-algorithms">18.2. Recommended algorithms</a></li><li><a href="#defining-an-algorithm">18.3. Defining an algorithm</a><ul><li><a href="#recognized-algorithm-name">18.3.1. Recognized algorithm name</a></li><li><a href="#supported-operations">18.3.2. Supported operations</a></li><li><a href="#algorithm-specific-params">18.3.3. Algorithm-specific parameters</a></li><li><a href="#algorithm-result">18.3.4. Algorithm results</a></li><li><a href="#algorithm-alias">18.3.5. Algorithm aliases</a></li></ul></li><li><a href="#rsaes-pkcs1">18.4. RSAES-PKCS1-v1_5</a><ul><li><a href="#rsaes-pkcs1-description">18.4.1. Description</a></li><li><a href="#rsaes-pkcs1-registration">18.4.2. Registration</a></li><li><a href="#RsaKeyGenParams-dictionary">18.4.3. RsaKeyGenParams dictionary</a></li><li><a href="#RsaKeyAlgorithm-interface">18.4.4. RsaKeyAlgorithm interface</a></li><li><a href="#rsaes-pkcs1-operations">18.4.5. Operations</a></li></ul></li><li><a href="#rsassa-pkcs1">18.5. RSASSA-PKCS1-v1_5</a><ul><li><a href="#rsassa-pkcs1-description">18.5.1. Description</a></li><li><a href="#rsassa-pkcs1-registration">18.5.2. Registration</a></li><li><a href="#RsaHashedKeyGenParams-dictionary">18.5.3. RsaHashedKeyGenParams dictionary</a></li><li><a href="#RsaHashedKeyAlgorithm-interface">18.5.4. RsaHashedKeyAlgorithm interface</a></li><li><a href="#RsaHashedImportParams-dictionary">18.5.5. RsaHashedImportParams dictionary</a></li><li><a href="#rsassa-pkcs1-operations">18.5.6. Operations</a></li></ul></li><li><a href="#rsa-pss">18.6. RSA-PSS</a><ul><li><a href="#rsa-pss-description">18.6.1. Description</a></li><li><a href="#rsa-pss-registration">18.6.2. Registration</a></li><li><a href="#RsaPssParams-dictionary">18.6.3. RsaPssParams dictionary</a></li><li><a href="#rsa-pss-operations">18.6.4. Operations</a></li></ul></li><li><a href="#rsa-oaep">18.7. RSA-OAEP</a><ul><li><a href="#rsa-oaep-description">18.7.1. Description</a></li><li><a href="#rsa-oaep-registration">18.7.2. Registration</a></li><li><a href="#rsa-oaep-params">18.7.3. RsaOaepParams dictionary</a></li><li><a href="#rsa-oaep-operations">18.7.4. Operations</a></li></ul></li><li><a href="#ecdsa">18.8. ECDSA</a><ul><li><a href="#ecdsa-description">18.8.1. Description</a></li><li><a href="#ecdsa-registration">18.8.2. Registration</a></li><li><a href="#EcdsaParams-dictionary">18.8.3. EcdsaParams dictionary</a></li><li><a href="#EcKeyAlgorithm-interface">18.8.4. </a></li><li><a href="#EcKeyGenParams-dictionary">18.8.5. EcKeyGenParams dictionary</a></li><li><a href="#EcKeyImportParams-dictionary">18.8.6. EcKeyImportParams dictionary</a></li><li><a href="#ecdsa-operations">18.8.7. Operations</a></li></ul></li><li><a href="#ecdh">18.9. ECDH</a><ul><li><a href="#ecdh-description">18.9.1. Description</a></li><li><a href="#ecdh-registration">18.9.2. Registration</a></li><li><a href="#dh-EcdhKeyDeriveParams">18.9.3. EcdhKeyDeriveParams dictionary</a></li><li><a href="#ecdh-operations">18.9.4. Operations</a></li></ul></li><li><a href="#aes-ctr">18.10. AES-CTR</a><ul><li><a href="#aes-ctr-description">18.10.1. Description</a></li><li><a href="#aes-ctr-registration">18.10.2. Registration</a></li><li><a href="#aes-ctr-params">18.10.3. AesCtrParams dictionary</a></li><li><a href="#AesKeyAlgorithm-interface">18.10.4. </a></li><li><a href="#aes-keygen-params">18.10.5. AesKeyGenParams dictionary</a></li><li><a href="#aes-derivedkey-params">18.10.6. AesDerivedKeyParams dictionary</a></li><li><a href="#aes-ctr-operations">18.10.7. Operations</a></li></ul></li><li><a href="#aes-cbc">18.11. AES-CBC</a><ul><li><a href="#aes-cbc-description">18.11.1. Description</a></li><li><a href="#aes-cbc-registration">18.11.2. Registration</a></li><li><a href="#aes-cbc-params">18.11.3. AesCbcParams dictionary</a></li><li><a href="#aes-cbc-operations">18.11.4. Operations</a></li></ul></li><li><a href="#aes-cmac">18.12. AES-CMAC</a><ul><li><a href="#aes-cmac-description">18.12.1. Description</a></li><li><a href="#aes-cmac-registration">18.12.2. Registration</a></li><li><a href="#aes-keygen-params">18.12.3. AesCmacParams dictionary</a></li><li><a href="#aes-cmac-operations">18.12.4. Operations</a></li></ul></li><li><a href="#aes-gcm">18.13. AES-GCM</a><ul><li><a href="#aes-gcm-description">18.13.1. Description</a></li><li><a href="#aes-gcm-registration">18.13.2. Registration</a></li><li><a href="#aes-gcm-params">18.13.3. AesGcmParams dictionary</a></li><li><a href="#aes-gcm-operations">18.13.4. Operations</a></li></ul></li><li><a href="#aes-cfb">18.14. AES-CFB</a><ul><li><a href="#aes-cfb-description">18.14.1. Description</a></li><li><a href="#aes-cfb-registration">18.14.2. Registration</a></li><li><a href="#aes-cfb-params">18.14.3. AesCfbParams dictionary</a></li><li><a href="#aes-cfb-operations">18.14.4. Operations</a></li></ul></li><li><a href="#aes-kw">18.15. AES-KW</a><ul><li><a href="#aes-kw-description">18.15.1. Description</a></li><li><a href="#aes-kw-registration">18.15.2. Registration</a></li><li><a href="#aes-kw-operations">18.15.3. Operations</a></li></ul></li><li><a href="#hmac">18.16. HMAC</a><ul><li><a href="#hmac-description">18.16.1. Description</a></li><li><a href="#hmac-registration">18.16.2. Registration</a></li><li><a href="#hmac-importparams">18.16.3. HmacImportParams dictionary</a></li><li><a href="#hmac-keyalgorithm">18.16.4. HmacKeyAlgorithm interface</a></li><li><a href="#hmac-keygen-params">18.16.5. HmacKeyGenParams dictionary</a></li><li><a href="#hmac-derivedkey-params">18.16.6. HmacDerivedKeyParams dictionary</a></li><li><a href="#hmac-operations">18.16.7. Operations</a></li></ul></li><li><a href="#dh">18.17. Diffie-Hellman</a><ul><li><a href="#dh-description">18.17.1. Description</a></li><li><a href="#dh-registration">18.17.2. Registration</a></li><li><a href="#dh-DhKeyGenParams">18.17.3. DhKeyGenParams dictionary</a></li><li><a href="#dh-DhKeyAlgorithm">18.17.4. DhKeyAlgorithm interface</a></li><li><a href="#dh-DhKeyDeriveParams">18.17.5. DhKeyDeriveParams dictionary</a></li><li><a href="#dh-DhImportKeyParams">18.17.6. DhImportKeyParams dictionary</a></li><li><a href="#dh-operations">18.17.7. Operations</a></li></ul></li><li><a href="#sha">18.18. SHA</a><ul><li><a href="#sha-description">18.18.1. Description</a></li><li><a href="#sha-registration">18.18.2. Registration</a></li><li><a href="#sha-operations">18.18.3. Operations</a></li></ul></li><li><a href="#concatkdf">18.19. Concat KDF</a><ul><li><a href="#concatkdf-description">18.19.1. Description</a></li><li><a href="#concatkdf-registration">18.19.2. Registration</a></li><li><a href="#concat-params">18.19.3. ConcatParams dictionary</a></li><li><a href="#concat-operations">18.19.4. Operations</a></li></ul></li><li><a href="#hkdf-ctr">18.20. HKDF-CTR</a><ul><li><a href="#hkdf-ctr-description">18.20.1. Description</a></li><li><a href="#hkdf-ctr-registration">18.20.2. Registration</a></li><li><a href="#hkdf-ctr-params">18.20.3. HkdfCtrParams dictionary</a></li><li><a href="#hkdf2-ctr-operations">18.20.4. Operations</a></li></ul></li><li><a href="#pbkdf2">18.21. PBKDF2</a><ul><li><a href="#pbkdf2-description">18.21.1. Description</a></li><li><a href="#pbkdf2-registration">18.21.2. Registration</a></li><li><a href="#pbkdf2-params">18.21.3. Pbkdf2Params dictionary</a></li><li><a href="#pbkdf2-operations">18.21.4. Operations</a></li></ul></li></ul></li><li><a href="#algorithm-normalizing-rules">19. Algorithm normalizing rules</a></li><li><a href="#examples-section">20. JavaScript Example Code</a><ul><li><a href="#examples-signing">20.1. Generate a signing key pair, sign some data</a></li><li><a href="#examples-symmetric-encryption">20.2. Symmetric Encryption</a></li></ul></li><li><a href="#iana-section">21. IANA Considerations</a><ul><li><a href="#iana-section-jws-jwa">21.1. JSON Web Signature and Encryption Algorithms Registration</a></li><li><a href="#iana-section-jwk">21.2. JSON Web Key Parameters Registry</a></li></ul></li><li><a href="#acknowledgements-section">22. Acknowledgements</a></li><li><a href="#references">23. References</a><ul><li><a href="#normative-references">23.1. Normative References</a></li><li><a href="#informative-references">23.2. Informative References</a></li></ul></li></ul><ul><li><a href="#jwk-mapping">A. Mapping between JSON Web Key / JSON Web Algorithm</a><ul><li><a href="#jwk-mapping-alg">A.1. Algorithm mappings</a></li><li><a href="#jwk-mapping-usage">A.2. Usage mapping</a></li></ul></li><li><a href="#spki-mapping">B. Mapping between Algorithm and SubjectPublicKeyInfo</a></li><li><a href="#pkcs8-mapping">C. Mapping between Algorithm and PKCS#8 PrivateKeyInfo</a></li></ul></div>
     </div>
 
     <div id="sections">
@@ -4847,9 +4847,20 @@
               </dl>
             </p>
           </div>
+          <div id="EcKeyImportParams-dictionary" class="section">
+            <h4>18.8.6. EcKeyImportParams dictionary</h4>
+            <div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">
+typedef DOMString <a href="#dfn-NamedCurve">NamedCurve</a>;
+
+dictionary <dfn id="dfn-EcKeyImportParams">EcKeyImportParams</dfn> : <a href="#dfn-Algorithm">Algorithm</a> {
+  <span class="comment">// A named curve</span>
+  <a href="#dfn-NamedCurve">NamedCurve</a> <dfn id="#dfn-EcKeyImportParams-namedCurve">namedCurve</dfn>;
+};
+            </code></pre></div></div>
+          </div>
 
           <div id="ecdsa-operations" class="section">
-            <h4>18.8.6. Operations</h4>
+            <h4>18.8.7. Operations</h4>
             <dl>
               <dt>Sign</dt>
               <dd>
@@ -5066,7 +5077,7 @@
                 </tr>
                 <tr>
                   <td>importKey</td>
-                  <td>None</td>
+                  <td><a href="#dfn-EcKeyImportParams">EcKeyImportParams</a></td>
                   <td><a href="#dfn-Key">Key</a></td>
                 </tr>
                 <tr>
@@ -5084,14 +5095,9 @@
 
 dictionary <dfn id="dfn-EcdhKeyDeriveParams">EcdhKeyDeriveParams</dfn> : <a href="#dfn-Algorithm">Algorithm</a> {
   <span class="comment">// The peer's EC public key.</span>
-  ECPoint public;
+  <a href="#dfn-Key">Key</a> public;
 };
             </code></pre></div></div>
-            <p>
-              The <a href="#dfn-ECPoint">ECPoint</a> typedef is a <code>Uint8Array</code> holding an
-              elliptic curve point. An elliptic curve point is converted to an array of Uint8
-              elements using the procedure specified in <a href="#X9.62">X9.62</a> Annex A.5.7.
-            </p>
           </div>
           <div id="ecdh-operations" class="section">
             <h4>18.9.4. Operations</h4>
@@ -5256,10 +5262,31 @@
                 </li>
                 <li>
                   <p>
+                    Let <var>publicKey</var> be the
+                    <a href="#dfn-EcdhKeyDeriveParams-public">public</a> property of
+                    <var>normalizedAlgorithm</var>.
+                  </p>
+                </li>
+                <li>
+                  <p>
+                    If the <a href="#dfn-KeyAlgorithm-name">name</a> property of the
+                    <a href="#dfn-Key-algorithm">algorithm</a> property of <var>publicKey</var> is
+                    not a case-sensitive string match for
+                    <code>"ECDH"</code>, terminate this algorithm with an error.
+                  </p>
+                </li>
+                <li>
+                  <p>
+                    If the <a href="#dfn-Key-type">type</a> property of <var>publicKey</var>
+                    is not a case-sensitive string match for
+                    <code>"public"</code>, terminate this algorithm with an error.
+                  </p>
+                </li>
+                <li>
+                  <p>
                     Perform the ECDH primitive specified in <a href="#X9.63">X9.63</a> Section 5.4.1
-                    with <var>key</var> as the EC private key <var>d</var> and the
-                    <a href="#dfn-EcdhKeyDeriveParams-public">public</a> property of
-                    <var>normalizedAlgorithm</var> as the EC public key <var>Q</var>.
+                    with <var>key</var> as the EC private key <var>d</var> and the EC public key
+                    represented by <var>publicKey</var> as the EC public key <var>Q</var>.
                     <dl class="switch">
                       <dt>If performing the operation results in an error:</dt>
                       <dd>Terminate this algorithm with an error.</dd>
@@ -5292,6 +5319,141 @@
                 </li>
               </ol>
             </dd>
+            <dt>Import key</dt>
+            <dd>
+              <dl class="switch">
+                <dt>If <var>format</var> is a case-sensitive string match for <code>"raw"</code>:</dt>
+                <dd>
+                  <ol>
+                    <li>
+                      <p>
+                        If any of the members of
+                        <a href="#dfn-EcKeyImportParams">EcKeyImportParams</a> are not present in
+                        <var>normalizedAlgorithm</var> then terminate this algorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        If the <a href="#dfn-EcKeyImportParams-namedCurve">namedCurve</a> property
+                        of <var>normalizedAlgorithm</var> is not a case-sensitive string match for
+                        a <a href="#dfn-NamedCurve">named curve</a>, terminate this algorithm with
+                        an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        If <var>usages</var> is not the empty list, terminate this algorithm with
+                        an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        If <var>extractable</var> is false, terminate this algorithm with
+                        an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>Q</var> be the elliptic curve point on the curve identified by the
+                        <a href="#dfn-EcKeyImportParams-namedCurve">namedCurve</a> property
+                        of <var>normalizedAlgorithm</var> identified by interpreting
+                        <var>keyData</var> according to <a href="#X9.62">X9.62</a> Annex A.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>algorithm</var> be a new
+                        <a href="#dfn-EcKeyAlgorithm">EcKeyAlgorithm</a> object.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Set the <a href="#dfn-KeyAlgorith-name">name</a> property of
+                        <var>algorithm</var> to <code>"ECDH"</code>.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Set the <a href="#dfn-KeyAlgorith-namedCurve">namedCurve</a> property of
+                        <var>algorithm</var> to equal the
+                        <a href="#dfn-EcKeyImportParams-namedCurve">namedCurve</a> property
+                        of <var>normalizedAlgorithm</var>.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>key</var> be a new <a href="#dfn-Key">Key</a> object.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Set the <a href="#dfn-Key-type">type</a> property of <var>key</var> to
+                        <code>"public"</code>
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Set the <a href="#dfn-Key-algorithm">algorithm</a> property of
+                        <var>key</var> to <var>algorithm</var>.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Set the <a href="#dfn-Key-usages">usages</a> property of
+                        <var>key</var> to <var>usages</var>.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Set the <a href="#dfn-Key-extractable">extractable</a> property of
+                        <var>key</var> to <var>extractable</var>.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Return <var>key</var>
+                      </p>
+                    </li>
+                  </ol>
+                </dd>
+                <dt>Otherwise:</dt>
+                <dd>Terminate this algorithm with an error.</dd>
+              </dl>
+            </dd>
+            <dt>Export key</dt>
+            <dd>
+              <dl class="switch">
+                <dt>
+                  If <var>format</var> is a case-sensitive string match for <code>"raw"</code>:
+                </dt>
+                <dd>
+                  <ol>
+                    <li>
+                      <p>
+                        If the <a href="#dfn-Key-type">type</a> property of <var>key</var> is not
+                        a case-sensitive string match for <code>"public"</code>, terminate this
+                        algorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>data</var> be an octet string representing the Elliptic Curve point
+                        <var>Q</var> represented by <var>key</var> according to
+                        <a href="#X9.62">X9.62</a> Annex A.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Return a new <a href="#dfn-ArrayBuffer">ArrayBuffer</a> containing
+                        <var>data</var>.
+                      </p>
+                    </li>
+                  </ol>
+                </dd>
+                <dt>Otherwise:</dt>
+                <dd>Terminate this algorithm with an error.</dd>
+              </dl>
+            </dd>
           </div>
         </div>