Bug 24825 - Add procedures for encoding ASN.1 structures
authorMark Watson <watsonm@netflix.com>
Wed, 26 Feb 2014 12:55:49 -0800
changeset 125 19be0e9a2f81
parent 124 59edf569342c
child 126 5f1f7c04c1de
Bug 24825 - Add procedures for encoding ASN.1 structures
spec/Overview-WebCryptoAPI.xml
spec/Overview.html
--- a/spec/Overview-WebCryptoAPI.xml	Thu Feb 20 18:11:06 2014 -0800
+++ b/spec/Overview-WebCryptoAPI.xml	Wed Feb 26 12:55:49 2014 -0800
@@ -655,6 +655,327 @@
             </p>
           </li>
         </ol>
+        <p>
+          When this specification says to <dfn id="concept-encode-an-asn1-structure">encode an ASN.1
+          structure</dfn>, the user agent must perform the following steps:
+          <ol>
+            <li>
+              <p>
+                Let <var>structure</var> be the ASN.1 structure to be encoded.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>data</var> be an object containing the data to be encoded into the
+                <var>structure</var>.
+              </p>
+            </li>
+            <li>
+              <dl class="switch">
+                <dt>If <var>structure</var> is an ASN.1 SEQUENCE:</dt>
+                <dd>
+                  <ol>
+                    <li>
+                      <p>
+                        If <var>data</var> is not an object, terminate this algorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        If <var>structure</var> includes any non-optional field for which there is
+                        no property of <var>data</var> with the same name, terminate this
+                        algorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>result</var> be the result of encoding <var>data</var> according to
+                        <var>structure</var> using the Distinguished Encoding Rules of
+                        <a href="#X690">X.690 (11/08)</a>, where the value for a field of
+                        <var>structure</var> with name <var>fieldName</var> is obtained by performing
+                        the steps to
+                        <a href="#concept-encode-an-asn1-structure">encode an ASN.1 structure</a> with
+                        the property of <var>data</var> with the name <var>fieldName</var> as the data
+                        to be encoded and the syntax
+                        specified for <var>fieldName</var> in <var>structure</var> as the
+                        ASN.1 structure to be
+                        encoded.
+                      </p>
+                    </li>
+                  </ol>
+                </dd>
+                <dt>If <var>structure</var> is an ASN.1 CHOICE:</dt>
+                <dd>
+                  <ol>
+                    <li>
+                      <p>
+                        If <var>data</var> is not an object, terminate this algorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        If no property of <var>data</var> has a name which matches one of the fields
+                        of <var>structure</var>, terminate this alorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        If more than one property of <var>data</var> has a name which matches one of
+                        the fields of <var>struture</var>, terminate this alorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>result</var> be the result of encoding <var>data</var> according to
+                        <var>structure</var> using the Distinguished Encoding Rules of
+                        <a href="#X690">X.690 (11/08)</a>, where the value for the unique field of
+                        <var>structure</var> with a name that is also the name of a property of
+                        <var>data</var> is obtained by performing
+                        the steps to
+                        <a href="#concept-encode-an-asn1-structure">encode an ASN.1 structure</a> with
+                        this property of <var>data</var> as the data
+                        to be encoded and the syntax
+                        specified for this field in <var>structure</var> as the ASN.1 structure to be
+                        encoded.
+                      </p>
+                    </li>
+                  </ol>
+                </dd>
+                <dt>If <var>structure</var> is an ASN.1 SEQUENCE OF or SET OF:</dt>
+                <dd>
+                  <ol>
+                    <li>
+                      <p>
+                        If <var>data</var> is not an array, terminate this algorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>result</var> be the result of encoding the elements of
+                        <var>data</var> according to
+                        <var>structure</var> using the Distinguished Encoding Rules of
+                        <a href="#X690">X.690 (11/08)</a>, where the value for each element of
+                        <var>data</var> is obtained by performing
+                        the steps to
+                        <a href="#concept-encode-an-asn1-structure">encode an ASN.1 structure</a> with
+                        the element of <var>data</var> as the data
+                        to be encoded and the syntax
+                        specified for set or sequence elements by <var>structure</var> as the ASN.1
+                        structure to be
+                        encoded.
+                      </p>
+                    </li>
+                  </ol>
+                </dd>
+                <dt>If <var>structure</var> is defined as having type ANY:</dt>
+                <dd>
+                  Let <var>result</var> be equal to <var>data</var>.
+                </dd>
+                <dt>Otherwise:</dt>
+                <dd>
+                  <ol>
+                    <li>
+                      <p>
+                        If <var>data</var> is an object or array, terminate this algorithm with an
+                        error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>result</var> be the result of encoding <var>data</var>
+                        according to the Distinguished Encoding Rules of
+                        <a href="#X690">X.690 (11/08)</a> using the format for type
+                        <var>structure</var>.
+                      </p>
+                    </li>
+                  </ol>
+                </dd>
+              </dl>
+            </li>
+            <li>
+              <p>
+                Return <var>result</var>
+              </p>
+            </li>
+          </ol>
+          <div class="ednote">
+            <p>
+              The above algorithm is not complete, in the sense that it cannot encode all possible
+              ASN.1 structures. However, it is sufficient for the ASN.1 structures presently used
+              in this document.
+            </p>
+          </div>
+        </p>
+        <p>
+          When this specification says to <dfn id="concept-encode-a-subjectPublicKeyInfo">encode
+          a subjectPublicKeyInfo</dfn> the user agent must run the following steps:
+          <ol>
+            <li>
+              <p>
+                Let <var>oid</var> be an Object Identifier identifying the public key algorithm.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>parameters</var> be the algorithm parameters and <var>parametersType</var>
+                be the ASN.1 type of the parameters.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>publicKey</var> be an octet string containing the public key.
+              </p>
+            </li>
+            <li>
+              <dl class="switch">
+                <dt>If <var>parameters</var> is not null:</dt>
+                <dd>
+                  <p>
+                    Let <var>encodedParameters</var> be the result of
+                    <a href="#concept-encode-an-asn1-structure">encoding an ASN.1 structure</a>
+                    using <var>parametersType</var> as <var>structure</var> and <var>parameters</var>
+                    as <var>data</var>.
+                  </p>
+                </dd>
+                <dt>Otherwise:</dt>
+                <dd>Let <var>encodedParameters</var> be null</dd>.
+              </dl>
+            </li>
+            <li>
+              <p>
+                Let <var>algorithmIdentifier</var> be a new internal object.
+              </p>
+            </li>
+            <li>
+              <p>
+                Set the <code>algorithm</code> property of <var>algorithmIdentifier</var> to be
+                <var>oid</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                If <var>encodedParameters</var> is not null, set the <code>parameters</code>
+                property of <var>algorithmIdentifier</var> to be <var>encodedParameters</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>subjectPublicKeyInfo</var> be a new internal object.
+              </p>
+            </li>
+            <li>
+              <p>
+                Set the <code>algorithm</code> property of <var>subjectPublicKeyInfo</var> to be
+                <var>algorithmIdentifier</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Set the <code>subjectPublicKey</code> property of <var>subjectPublicKeyInfo</var>
+                to be <var>publicKey</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>result</var> be the result of
+                <a href="#concept-encode-an-asn1-structure">encoding an ASN.1 structure</a> using
+                the ASN.1 structure of subjectPublicKeyInfo, as specified in
+                <a href="#RFC5280">RFC 5280</a> as <var>structure</var> and
+                <var>subjectPublicKeyInfo</var> as <var>data</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Return <var>result</var>.
+              </p>
+            </li>
+          </ol>
+        </p>
+        <p>
+          When this specification says to <dfn id="concept-encode-a-privateKeyInfo">encode a
+          privateKeyInfo</dfn> the user agent must run the following steps:
+          <ol>
+            <li>
+              <p>
+                Let <var>oid</var> be an Object Identifier identifying the private key algorithm.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>parameters</var> be the algorithm parameters and <var>parametersType</var>
+                be the ASN.1 type of the parameters.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>privateKey</var> be an octet string containing the private key.
+              </p>
+            </li>
+            <li>
+              <dl class="switch">
+                <dt>If <var>parameters</var> is not null:</dt>
+                <dd>
+                  <p>
+                    Let <var>encodedParameters</var> be the result of
+                    <a href="#concept-encode-an-asn1-structure">encoding an ASN.1 structure</a>
+                    using <var>parametersType</var> as <var>structure</var> and <var>parameters</var>
+                    as <var>data</var>.
+                  </p>
+                </dd>
+                <dt>Otherwise:</dt>
+                <dd>Let <var>encodedParameters</var> be null</dd>.
+              </dl>
+            </li>
+            <li>
+              <p>
+                Let <var>algorithmIdentifier</var> be a new internal object.
+              </p>
+            </li>
+            <li>
+              <p>
+                Set the <code>algorithm</code> property of <var>algorithmIdentifier</var> to be
+                <var>oid</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                If <var>encodedParameters</var> is not null, set the <code>parameters</code>
+                property of <var>algorithmIdentifier</var> to be <var>encodedParameters</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>privateKeyInfo</var> be a new internal object.
+              </p>
+            </li>
+            <li>
+              <p>
+                Set the <code>privateKeyAlgorithm</code> property of <var>privateKeyInfo</var> to be
+                <var>algorithmIdentifier</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Set the <code>privateKey</code> property of <var>privateKeyInfo</var>
+                to be <var>privateKey</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>result</var> be the result of
+                <a href="#concept-encode-an-asn1-structure">encoding an ASN.1 structure</a> using
+                the ASN.1 structure of PrivateKeyInfo, as specified in
+                <a href="#RFC5208">RFC 5208</a> as <var>structure</var> and
+                <var>privateKeyInfo</var> as <var>data</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Return <var>result</var>.
+              </p>
+            </li>
+          </ol>
+        </p>
       </div>
 
       <div id="RandomSource-interface" class="section">
@@ -8616,7 +8937,6 @@
                   <td>None</td>
                   <td>ArrayBuffer</td>
                 </tr>
-
               </tbody>
             </table>
           </div>
--- a/spec/Overview.html	Thu Feb 20 18:11:06 2014 -0800
+++ b/spec/Overview.html	Wed Feb 26 12:55:49 2014 -0800
@@ -28,7 +28,7 @@
   <link rel="stylesheet" href="//www.w3.org/StyleSheets/TR/W3C-ED" type="text/css" /></head>
 
   <body>
-    <div class="head"><div><a href="http://www.w3.org/"><img src="//www.w3.org/Icons/w3c_home" width="72" height="48" alt="W3C" /></a></div><h1>Web Cryptography API</h1><h2>W3C Editor’s Draft <em>20 February 2014</em></h2><dl><dt>Latest Editor’s Draft:</dt><dd><a href="http://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html">http://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html</a></dd><dt>Latest Published Version:</dt><dd><a href="http://www.w3.org/TR/WebCryptoAPI/">http://www.w3.org/TR/WebCryptoAPI/</a></dd><dt>Previous Version(s):</dt><dd><a href="https://dvcs.w3.org/hg/webcrypto-api/raw-file/0fe9b34c13fb/spec/Overview.html">https://dvcs.w3.org/hg/webcrypto-api/raw-file/0fe9b34c13fb/spec/Overview.html</a></dd><dt>Editors:</dt><dd><a href="http://www.google.com/">Ryan Sleevi</a>, Google, Inc. &lt;[email protected]&gt;</dd><dd><a href="http://www.netflix.com/">Mark Watson</a>, Netflix &lt;[email protected]&gt;</dd><dt>Participate:</dt><dd><p>Send feedback to <a href="mailto:[email protected]?subject=%5BWebCryptoAPI%5D">[email protected]</a> (<a href="http://lists.w3.org/Archives/Public/public-webcrypto/">archives</a>), or <a href="https://www.w3.org/Bugs/Public/enter_bug.cgi?product=Web%20Cryptography&amp;component=Web%20Cryptography%20API%20Document">file a bug</a> 
+    <div class="head"><div><a href="http://www.w3.org/"><img src="//www.w3.org/Icons/w3c_home" width="72" height="48" alt="W3C" /></a></div><h1>Web Cryptography API</h1><h2>W3C Editor’s Draft <em>26 February 2014</em></h2><dl><dt>Latest Editor’s Draft:</dt><dd><a href="http://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html">http://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html</a></dd><dt>Latest Published Version:</dt><dd><a href="http://www.w3.org/TR/WebCryptoAPI/">http://www.w3.org/TR/WebCryptoAPI/</a></dd><dt>Previous Version(s):</dt><dd><a href="https://dvcs.w3.org/hg/webcrypto-api/raw-file/0fe9b34c13fb/spec/Overview.html">https://dvcs.w3.org/hg/webcrypto-api/raw-file/0fe9b34c13fb/spec/Overview.html</a></dd><dt>Editors:</dt><dd><a href="http://www.google.com/">Ryan Sleevi</a>, Google, Inc. &lt;[email protected]&gt;</dd><dd><a href="http://www.netflix.com/">Mark Watson</a>, Netflix &lt;[email protected]&gt;</dd><dt>Participate:</dt><dd><p>Send feedback to <a href="mailto:[email protected]?subject=%5BWebCryptoAPI%5D">[email protected]</a> (<a href="http://lists.w3.org/Archives/Public/public-webcrypto/">archives</a>), or <a href="https://www.w3.org/Bugs/Public/enter_bug.cgi?product=Web%20Cryptography&amp;component=Web%20Cryptography%20API%20Document">file a bug</a> 
     (see <a href="https://www.w3.org/Bugs/Public/buglist.cgi?product=Web%20Cryptography&amp;component=Web%20Cryptography%20API%20Document&amp;resolution=---">existing bugs</a>).</p></dd></dl><p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> &copy; view <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>&reg;</sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.org/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p></div><hr />
 
     <div class="section">
@@ -44,7 +44,7 @@
         communications.
       </p>
   
-      <div class="ednote"><div class="ednoteHeader">Editorial note</div><p>There are 36 further editorial notes in the document.</p></div>
+      <div class="ednote"><div class="ednoteHeader">Editorial note</div><p>There are 37 further editorial notes in the document.</p></div>
     </div>
 
     <div class="section">
@@ -56,7 +56,7 @@
         report can be found in the <a href="http://www.w3.org/TR/">W3C technical
           reports index</a> at http://www.w3.org/TR/.
       </em></p><p>
-        This document is the 20 February 2014 <b>Editor’s Draft</b> of the
+        This document is the 26 February 2014 <b>Editor’s Draft</b> of the
         <cite>Web Cryptography API</cite> specification.
       
       Please send comments about this document to
@@ -663,6 +663,327 @@
             </p>
           </li>
         </ol>
+        <p>
+          When this specification says to <dfn id="concept-encode-an-asn1-structure">encode an ASN.1
+          structure</dfn>, the user agent must perform the following steps:
+          <ol>
+            <li>
+              <p>
+                Let <var>structure</var> be the ASN.1 structure to be encoded.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>data</var> be an object containing the data to be encoded into the
+                <var>structure</var>.
+              </p>
+            </li>
+            <li>
+              <dl class="switch">
+                <dt>If <var>structure</var> is an ASN.1 SEQUENCE:</dt>
+                <dd>
+                  <ol>
+                    <li>
+                      <p>
+                        If <var>data</var> is not an object, terminate this algorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        If <var>structure</var> includes any non-optional field for which there is
+                        no property of <var>data</var> with the same name, terminate this
+                        algorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>result</var> be the result of encoding <var>data</var> according to
+                        <var>structure</var> using the Distinguished Encoding Rules of
+                        <a href="#X690">X.690 (11/08)</a>, where the value for a field of
+                        <var>structure</var> with name <var>fieldName</var> is obtained by performing
+                        the steps to
+                        <a href="#concept-encode-an-asn1-structure">encode an ASN.1 structure</a> with
+                        the property of <var>data</var> with the name <var>fieldName</var> as the data
+                        to be encoded and the syntax
+                        specified for <var>fieldName</var> in <var>structure</var> as the
+                        ASN.1 structure to be
+                        encoded.
+                      </p>
+                    </li>
+                  </ol>
+                </dd>
+                <dt>If <var>structure</var> is an ASN.1 CHOICE:</dt>
+                <dd>
+                  <ol>
+                    <li>
+                      <p>
+                        If <var>data</var> is not an object, terminate this algorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        If no property of <var>data</var> has a name which matches one of the fields
+                        of <var>structure</var>, terminate this alorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        If more than one property of <var>data</var> has a name which matches one of
+                        the fields of <var>struture</var>, terminate this alorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>result</var> be the result of encoding <var>data</var> according to
+                        <var>structure</var> using the Distinguished Encoding Rules of
+                        <a href="#X690">X.690 (11/08)</a>, where the value for the unique field of
+                        <var>structure</var> with a name that is also the name of a property of
+                        <var>data</var> is obtained by performing
+                        the steps to
+                        <a href="#concept-encode-an-asn1-structure">encode an ASN.1 structure</a> with
+                        this property of <var>data</var> as the data
+                        to be encoded and the syntax
+                        specified for this field in <var>structure</var> as the ASN.1 structure to be
+                        encoded.
+                      </p>
+                    </li>
+                  </ol>
+                </dd>
+                <dt>If <var>structure</var> is an ASN.1 SEQUENCE OF or SET OF:</dt>
+                <dd>
+                  <ol>
+                    <li>
+                      <p>
+                        If <var>data</var> is not an array, terminate this algorithm with an error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>result</var> be the result of encoding the elements of
+                        <var>data</var> according to
+                        <var>structure</var> using the Distinguished Encoding Rules of
+                        <a href="#X690">X.690 (11/08)</a>, where the value for each element of
+                        <var>data</var> is obtained by performing
+                        the steps to
+                        <a href="#concept-encode-an-asn1-structure">encode an ASN.1 structure</a> with
+                        the element of <var>data</var> as the data
+                        to be encoded and the syntax
+                        specified for set or sequence elements by <var>structure</var> as the ASN.1
+                        structure to be
+                        encoded.
+                      </p>
+                    </li>
+                  </ol>
+                </dd>
+                <dt>If <var>structure</var> is defined as having type ANY:</dt>
+                <dd>
+                  Let <var>result</var> be equal to <var>data</var>.
+                </dd>
+                <dt>Otherwise:</dt>
+                <dd>
+                  <ol>
+                    <li>
+                      <p>
+                        If <var>data</var> is an object or array, terminate this algorithm with an
+                        error.
+                      </p>
+                    </li>
+                    <li>
+                      <p>
+                        Let <var>result</var> be the result of encoding <var>data</var>
+                        according to the Distinguished Encoding Rules of
+                        <a href="#X690">X.690 (11/08)</a> using the format for type
+                        <var>structure</var>.
+                      </p>
+                    </li>
+                  </ol>
+                </dd>
+              </dl>
+            </li>
+            <li>
+              <p>
+                Return <var>result</var>
+              </p>
+            </li>
+          </ol>
+          <div class="ednote"><div class="ednoteHeader">Editorial note</div>
+            <p>
+              The above algorithm is not complete, in the sense that it cannot encode all possible
+              ASN.1 structures. However, it is sufficient for the ASN.1 structures presently used
+              in this document.
+            </p>
+          </div>
+        </p>
+        <p>
+          When this specification says to <dfn id="concept-encode-a-subjectPublicKeyInfo">encode
+          a subjectPublicKeyInfo</dfn> the user agent must run the following steps:
+          <ol>
+            <li>
+              <p>
+                Let <var>oid</var> be an Object Identifier identifying the public key algorithm.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>parameters</var> be the algorithm parameters and <var>parametersType</var>
+                be the ASN.1 type of the parameters.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>publicKey</var> be an octet string containing the public key.
+              </p>
+            </li>
+            <li>
+              <dl class="switch">
+                <dt>If <var>parameters</var> is not null:</dt>
+                <dd>
+                  <p>
+                    Let <var>encodedParameters</var> be the result of
+                    <a href="#concept-encode-an-asn1-structure">encoding an ASN.1 structure</a>
+                    using <var>parametersType</var> as <var>structure</var> and <var>parameters</var>
+                    as <var>data</var>.
+                  </p>
+                </dd>
+                <dt>Otherwise:</dt>
+                <dd>Let <var>encodedParameters</var> be null</dd>.
+              </dl>
+            </li>
+            <li>
+              <p>
+                Let <var>algorithmIdentifier</var> be a new internal object.
+              </p>
+            </li>
+            <li>
+              <p>
+                Set the <code>algorithm</code> property of <var>algorithmIdentifier</var> to be
+                <var>oid</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                If <var>encodedParameters</var> is not null, set the <code>parameters</code>
+                property of <var>algorithmIdentifier</var> to be <var>encodedParameters</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>subjectPublicKeyInfo</var> be a new internal object.
+              </p>
+            </li>
+            <li>
+              <p>
+                Set the <code>algorithm</code> property of <var>subjectPublicKeyInfo</var> to be
+                <var>algorithmIdentifier</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Set the <code>subjectPublicKey</code> property of <var>subjectPublicKeyInfo</var>
+                to be <var>publicKey</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>result</var> be the result of
+                <a href="#concept-encode-an-asn1-structure">encoding an ASN.1 structure</a> using
+                the ASN.1 structure of subjectPublicKeyInfo, as specified in
+                <a href="#RFC5280">RFC 5280</a> as <var>structure</var> and
+                <var>subjectPublicKeyInfo</var> as <var>data</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Return <var>result</var>.
+              </p>
+            </li>
+          </ol>
+        </p>
+        <p>
+          When this specification says to <dfn id="concept-encode-a-privateKeyInfo">encode a
+          privateKeyInfo</dfn> the user agent must run the following steps:
+          <ol>
+            <li>
+              <p>
+                Let <var>oid</var> be an Object Identifier identifying the private key algorithm.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>parameters</var> be the algorithm parameters and <var>parametersType</var>
+                be the ASN.1 type of the parameters.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>privateKey</var> be an octet string containing the private key.
+              </p>
+            </li>
+            <li>
+              <dl class="switch">
+                <dt>If <var>parameters</var> is not null:</dt>
+                <dd>
+                  <p>
+                    Let <var>encodedParameters</var> be the result of
+                    <a href="#concept-encode-an-asn1-structure">encoding an ASN.1 structure</a>
+                    using <var>parametersType</var> as <var>structure</var> and <var>parameters</var>
+                    as <var>data</var>.
+                  </p>
+                </dd>
+                <dt>Otherwise:</dt>
+                <dd>Let <var>encodedParameters</var> be null</dd>.
+              </dl>
+            </li>
+            <li>
+              <p>
+                Let <var>algorithmIdentifier</var> be a new internal object.
+              </p>
+            </li>
+            <li>
+              <p>
+                Set the <code>algorithm</code> property of <var>algorithmIdentifier</var> to be
+                <var>oid</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                If <var>encodedParameters</var> is not null, set the <code>parameters</code>
+                property of <var>algorithmIdentifier</var> to be <var>encodedParameters</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>privateKeyInfo</var> be a new internal object.
+              </p>
+            </li>
+            <li>
+              <p>
+                Set the <code>privateKeyAlgorithm</code> property of <var>privateKeyInfo</var> to be
+                <var>algorithmIdentifier</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Set the <code>privateKey</code> property of <var>privateKeyInfo</var>
+                to be <var>privateKey</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Let <var>result</var> be the result of
+                <a href="#concept-encode-an-asn1-structure">encoding an ASN.1 structure</a> using
+                the ASN.1 structure of PrivateKeyInfo, as specified in
+                <a href="#RFC5208">RFC 5208</a> as <var>structure</var> and
+                <var>privateKeyInfo</var> as <var>data</var>.
+              </p>
+            </li>
+            <li>
+              <p>
+                Return <var>result</var>.
+              </p>
+            </li>
+          </ol>
+        </p>
       </div>
 
       <div id="RandomSource-interface" class="section">
@@ -8608,7 +8929,6 @@
                   <td>None</td>
                   <td>ArrayBuffer</td>
                 </tr>
-
               </tbody>
             </table>
           </div>