--- a/spec/Overview-WebCryptoAPI.xml Wed Feb 26 12:55:49 2014 -0800
+++ b/spec/Overview-WebCryptoAPI.xml Wed Feb 26 13:01:24 2014 -0800
@@ -8892,6 +8892,7 @@
<h3>Diffie-Hellman</h3>
<div id="dh-description" class="section">
<h4>Description</h4>
+ <p class="norm">This section is non-normative.</p>
<p>
This describes using Diffie-Hellman for key generation and key agreement, as specified
by <a href="#PKCS3">PKCS #3</a>.
@@ -8929,7 +8930,7 @@
</tr>
<tr>
<td>importKey</td>
- <td>None</td>
+ <td><a href="#dfn-DhImportKeyParams">DhImportKeyParams</a></td>
<td><a href="#dfn-Key">Key</a></td>
</tr>
<tr>
@@ -8945,9 +8946,9 @@
<x:codeblock language="idl">
dictionary <dfn id="dfn-DhKeyGenParams">DhKeyGenParams</dfn> : <a href="#dfn-Algorithm">Algorithm</a> {
<span class="comment">// The prime p.</span>
- BigInteger prime;
+ BigInteger <dfn id="dfn-DhKeyGenParams-prime">prime</dfn>;
<span class="comment">// The base g.</span>
- BigInteger generator;
+ BigInteger <dfn id="dfn-DhKeyGenParams-generator">generator</dfn>;
};
</x:codeblock>
</div>
@@ -8957,9 +8958,9 @@
[NoInterfaceObject]
interface <dfn id="dfn-DhKeyAlgorithm">DhKeyAlgorithm</dfn> : <a href="#dfn-KeyAlgorithm">KeyAlgorithm</a> {
<span class="comment">// The prime p.</span>
- readonly attribute BigInteger prime;
+ readonly attribute BigInteger <dfn id="dfn-DhKeyAlgorithm-prime">prime</dfn>;
<span class="comment">// The base g.</span>
- readonly attribute BigInteger generator;
+ readonly attribute BigInteger <dfn id="dfn-DhKeyAlgorithm-generator">generator</dfn>;
};
</x:codeblock>
</div>
@@ -8968,26 +8969,773 @@
<x:codeblock language="idl">
dictionary <dfn id="dfn-DhKeyDeriveParams">DhKeyDeriveParams</dfn> : <a href="#dfn-Algorithm">Algorithm</a> {
<span class="comment">// The peer's public value.</span>
- BigInteger public;
+ BigInteger <dfn id="dfn-DhKeyDeriveParams-public">public</dfn>;
+};
+ </x:codeblock>
+ </div>
+ <div id="dh-DhImportKeyParams" class="section">
+ <h4>DhImportKeyParams dictionary</h4>
+ <x:codeblock language="idl">
+dictionary <dfn id="dfn-DhImportKeyParams">DhImportKeyParams</dfn> : <a href="#dfn-Algorithm">Algorithm</a> {
+ <span class="comment">// The prime p.</span>
+ BigInteger <dfn id="dfn-DhImportKeyParams-prime">prime</dfn>;
+ <span class="comment">// The base g.</span>
+ BigInteger <dfn id="dfn-DhImportKeyParams-generator">generator</dfn>;
};
</x:codeblock>
</div>
<div id="dh-operations" class="section">
<h4>Operations</h4>
- <ul>
- <li>Generate Key</li>
- <li>Derive Key</li>
- <li>Derive Bits</li>
- <li>Import Key</li>
- <li>Export Key</li>
- </ul>
+ <dl>
+ <dt>Generate Key</dt>
+ <dd>
+ <ol>
+ <li>
+ <p>
+ If any of the members of <a href="#dfn-DhKeyGenParams">DhKeyGenParams</a> are
+ not present in <var>normalizedAlgorithm</var>,
+ terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ If <var>usages</var> contains a value which is not a case-sensitive string match
+ for one of <code>"deriveKey"</code> or <code>"deriveBits"</code>,
+ terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Generate a Diffie-Hellman key pair, as defined in Section 7 of
+ [<a href="#PKCS3">PKCS #3</a>], with prime, <var>p</var>, and base,
+ <var>g</var>, as specified in the
+ <a href="#dfn-DhKeyGenParams-prime">prime</a> and
+ <a href="#dfn-DhKeyGenParams-generator">generator</a> properties of
+ <var>normalizedAlgorithm</var>, respectively.
+ <dl class="switch">
+ <dt>If performing the operation results in an error:</dt>
+ <dd>Terminate this algorithm with an error.</dd>
+ <dt>Otherwise:</dt>
+ <dd>
+ <ol>
+ <li>
+ <p>
+ Let <var>algorithm</var> be a new
+ <a href="#dfn-DhKeyAlgorithm">DhKeyAlgorithm</a>
+ object.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Algorithm-name">name</a> property of
+ <var>algorithm</var> to <code>"DH"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-prime">prime</a>
+ property of <var>algorithm</var> to equal the
+ <a href="#dfn-DhKeyGenParams-prime">prime</a> property of
+ <var>normalizedAlgorithm</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-generator">generator</a>
+ property of <var>algorithm</var> to equal the
+ <a href="#dfn-DhKeyGenParams-generator">generator</a> property of
+ <var>normalizedAlgorithm</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>publicKey</var> be a new <a href="#dfn-Key">Key</a> object
+ representing the public key of the generated key pair.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-type">type</a> property of <var>publicKey</var>
+ to <code>"public"</code>
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-algorithm">algorithm</a> property of
+ <var>publicKey</var> to be <var>algorithm</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-extractable">extractable</a> property of
+ <var>publicKey</var> to true.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-usages">usages</a> property of
+ <var>publicKey</var> to be the empty list.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>privateKey</var> be a new <a href="#dfn-Key">Key</a> object
+ representing the private key of the generated key pair.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-Type">type</a> property of <var>privateKey</var>
+ to <code>"private"</code>
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-algorithm">algorithm</a> property of
+ <var>privateKey</var> to be <var>algorithm</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-extractable">extractable</a> property of
+ <var>privateKey</var> to <var>extractable</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-usages">usages</a> property of
+ <var>privateKey</var> to be <var>usages</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>result</var> be a new <a href="#dfn-KeyPair">KeyPair</a>
+ object.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#def-KeyPair-publicKey">publicKey</a> property
+ of <var>result</var> to be <var>publicKey</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#def-KeyPair-privateKey">privateKey</a> property
+ of <var>result</var> to be <var>privateKey</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Return <var>result</var>.
+ </p>
+ </li>
+ </ol>
+ </dd>
+ </dl>
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>Derive Key</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>"private"</code>, terminate this
+ algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ If any of the members of <a
+ href="#dfn-DhKeyDeriveParams">DhKeyDeriveParams</a> are not present in
+ <var>normalizedAlgorithm</var>, terminate this
+ algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Perform the Diffie Hellman Phase II algorithm as specified in
+ Section 8 of [<a href="#PKCS3">PKCS #3</a>]
+ with <var>key</var> as the DH private value <var>x</var> and the
+ <a href="#dfn-DhKeyDeriveParams-public">public</a> property of
+ <var>normalizedAlgorithm</var> as the other's public value <var>PV'</var>.
+ <dl class="switch">
+ <dt>If performing the operation results in an error:</dt>
+ <dd>Terminate this algorithm with an error.</dd>
+ <dt>Otherwise:</dt>
+ <dd>
+ Let <var>result</var> be the output of the DH Phase II, <var>SK</var>
+ </dd>
+ </dl>
+ </p>
+ </li>
+ </ol>
+ <div class="ednote">
+ <p>
+ TODO: Define how a key for algorithm <var>normalizedDerivedKeyAlgorithm</var> is
+ derived from a the secret value <var>SK</var>.
+ </p>
+ </div>
+ </dd>
+ <dt>Derive Bits</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>"private"</code>, terminate this
+ algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ If any of the members of <a
+ href="#dfn-DhKeyDeriveParams">DhKeyDeriveParams</a> are not present in
+ <var>normalizedAlgorithm</var>, terminate this
+ algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Perform the Diffie Hellman Phase II algorithm as specified in
+ Section 8 of [<a href="#PKCS3">PKCS #3</a>]
+ with <var>key</var> as the DH private value <var>x</var> and the
+ <a href="#dfn-DhKeyDeriveParams-public">public</a> property of
+ <var>normalizedAlgorithm</var> as the other's public value <var>PV'</var>.
+ <dl class="switch">
+ <dt>If performing the operation results in an error:</dt>
+ <dd>Terminate this algorithm with an error.</dd>
+ <dt>Otherwise:</dt>
+ <dd>
+ Let <var>result</var> be the output of the DH Phase II, <var>SK</var>.
+ </dd>
+ </dl>
+ </p>
+ </li>
+ <li>
+ <p>
+ Return a new ArrayBuffer containing <var>result</var>
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>Import Key</dt>
+ <dd>
+ <dl class="switch">
+ <dt>
+ If <var>format</var> is a case-sensistive string match for <code>"raw"</code>:
+ </dt>
+ <dd>
+ <div class="ednote">
+ <p>
+ It has been suggested that "raw" import for asymmetric keys such as DH
+ should not be supported.
+ </p>
+ </div>
+ <ol>
+ <li>
+ <p>
+ If any of the members of
+ <a href="#dfn-DhImportKeyParams">DhImportKeyParams</a> are
+ not present in <var>normalizedAlgorithm</var>,
+ terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ If <var>usages</var> contains a value which is not a case-sensitive string
+ match for one of <code>"deriveKey"</code> or <code>"deriveBits"</code>,
+ terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>x</var> be the integer which results from interpreting the octets
+ of <var>keyData</var> as an unsigned big integer with most significant
+ octet first.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>key</var> be a new <a href="#dfn-Key">Key</a> object representing
+ a Diffie-Hellman private key with private value <var>x</var> and with
+ prime, <var>p</var> and base, <var>g</var> equal to the
+ <a href="#dfn-DhImportKeyParams-prime">prime</a> and
+ <a href="#dfn-DhImportKeyParams-generator">generator</a> properties
+ of <var>normalizedAlgorithm</var> respectively.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-type">type</a> propety of <var>key</var> to
+ <code>"private"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>algorithm</var> be a new
+ <a href="#dfn-DhKeyAlgorithm">DhKeyAlgorithm</a>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Algorithm-name">name</a> property of
+ <var>algorithm</var> to <code>"DH"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-prime">prime</a> property of
+ <var>algorithm</var> to equal the
+ <a href="#dfn-DhKeyImportParams-prime">prime</a> property of
+ <var>normalizedAlgorithm</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-generator">generator</a> property of
+ <var>algorithm</var> to equal the
+ <a href="#dfn-DhKeyImportParams-generator">generator</a> property of
+ <var>normalizedAlgorithm</var>.
+ </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-extractable">extractable</a> property of
+ <var>key</var> to <var>extractable</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>
+ Return <var>key</var>.
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>
+ If <var>format</var> is a case-sensistive string match for <code>"spki"</code>:
+ </dt>
+ <dd>
+ <ol>
+ <li>
+ <p>
+ If <var>usages</var> is non-empty, terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>spki</var> be the result of running the
+ <a href="#concept-parse-a-spki">parse a subjectPublicKeyInfo</a> algorithm
+ over <var>keyData</var>.
+ <ul>
+ <li>
+ <p>
+ If an error occured while parsing, terminate this algorithm with an error.
+ </p>
+ </li>
+ </ul>
+ </p>
+ </li>
+ <li>
+ <p>
+ If the <code>algorithm</code> object identifier field of the
+ <code>algorithm</code> AlgorithmIdentifier field of <var>spki</var> is not
+ equivalent to the <code>dhKeyAgreement</code> OID defined in Section 9
+ of [<a href="#PKCS3">PKCS #3</a>], terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>parameters</var> be the result of performing the
+ <a href="#concept-parse-an-asn1-structure">parse an ASN.1 structure</a>
+ algorithm, with the <code>parameters</code> field of the
+ <code>algorithm</code> AlgorithmIdentifier field of <var>spki</var> as
+ <var>data</var> and the <code>DHParameter</code> structure defined in
+ Section 9 of [<a href="#PKCS3">PKCS #3</a>] as <var>structure</var> and
+ with <var>extactData</var> set to true.
+ <ul>
+ <li>
+ <p>
+ If an error occured while parsing, terminate this algorithm with an error.
+ </p>
+ </li>
+ </ul>
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>publicValue</var> be the integer obtained by interpreting the
+ <code>subjectPublicKey</code> field of <var>spki</var> as an unsigned
+ integer, most significant bit first.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>key</var> be a new <a href="#dfn-Key">Key</a> object representing
+ a Diffie Hellman public key with prime, <var>p</var> and base,
+ <var>g</var> as specified by the <code>prime</code> and <code>base</code>
+ fields of <var>parameters</var> respectively and with public value,
+ <var>y</var> equal to <var>publicValue</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-type">type</a> propety of <var>key</var> to
+ <code>"public"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>algorithm</var> be a new
+ <a href="#dfn-DhKeyAlgorithm">DhKeyAlgorithm</a>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Algorithm-name">name</a> property of
+ <var>algorithm</var> to <code>"DH"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-prime">prime</a> property of
+ <var>algorithm</var> to equal the
+ <code>prime</code> field of <var>parameters</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-generator">generator</a> property of
+ <var>algorithm</var> to equal the
+ <code>base</code> field of
+ <var>parameters</var>.
+ </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-extractable">extractable</a> property of
+ <var>key</var> to <var>extractable</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>
+ Return <var>key</var>.
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>
+ If <var>format</var> is a case-sensistive string match for <code>"pkcs8"</code>:
+ </dt>
+ <dd>
+ <ol>
+ <li>
+ <p>
+ If <var>usages</var> contains a value which is not a case-sensitive string
+ match for one of <code>"deriveKey"</code> or <code>"deriveBits"</code>,
+ terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>privateKeyInfo</var> be the result of running the
+ <a href="#concept-parse-a-privateKeyInfo">parse a privateKeyInfo</a>
+ algorithm over <var>keyData</var>.
+ <ul>
+ <li>
+ <p>
+ If an error occured while parsing, terminate this algorithm with an error.
+ </p>
+ </li>
+ </ul>
+ </p>
+ </li>
+ <li>
+ <p>
+ If the <code>algorithm</code> object identifier field of the
+ <code>algorithm</code> AlgorithmIdentifier field of
+ <var>privateKeyInfo</var> is not
+ equivalent to the <code>dhKeyAgreement</code> OID defined in Section 9
+ of [<a href="#PKCS3">PKCS #3</a>], terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>parameters</var> be the result of performing the
+ <a href="#concept-parse-an-asn1-structure">parse an ASN.1 structure</a>
+ algorithm, with the <code>parameters</code> field of the
+ <code>algorithm</code> AlgorithmIdentifier field of
+ <var>privateKeyInfo</var> as
+ <var>data</var> and the <code>DHParameter</code> structure defined in
+ Section 9 of [<a href="#PKCS3">PKCS #3</a>] as <var>structure</var> and
+ with <var>extactData</var> set to true.
+ <ul>
+ <li>
+ <p>
+ If an error occured while parsing, terminate this algorithm with an error.
+ </p>
+ </li>
+ </ul>
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>privateValue</var> be the integer obtained by interpreting the
+ <code>privateKey</code> field of <var>privateKeyInfo</var> as an unsigned
+ integer, most significant octet first.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>key</var> be a new <a href="#dfn-Key">Key</a> object representing
+ a Diffie Hellman private key with prime, <var>p</var> and base,
+ <var>g</var> as specified by the <code>prime</code> and <code>base</code>
+ fields of <var>parameters</var> respectively and with private value,
+ <var>x</var> equal to <var>privateValue</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-type">type</a> propety of <var>key</var> to
+ <code>"private"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>algorithm</var> be a new
+ <a href="#dfn-DhKeyAlgorithm">DhKeyAlgorithm</a>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Algorithm-name">name</a> property of
+ <var>algorithm</var> to <code>"DH"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-prime">prime</a> property of
+ <var>algorithm</var> to equal the
+ <code>prime</code> field of <var>parameters</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-generator">generator</a> property of
+ <var>algorithm</var> to equal the
+ <code>base</code> field of
+ <var>parameters</var>.
+ </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-extractable">extractable</a> property of
+ <var>key</var> to <var>extractable</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>
+ 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>
+ <dl class="switch">
+ <dt>
+ If the <a href="#dfn-Key-type">type</a> property of <var>key</var> is a
+ case-sensitive string match for <code>"public"</code>:
+ </dt>
+ <dd>
+ Let <var>result</var> be the Public Value , <var>PV</var>, associated
+ with <var>key</var> as
+ specified in Section 7 of [<a href="#PKCS3">PKCS #3</a>].
+ </dd>
+ <dt>
+ If the <a href="#dfn-Key-type">type</a> property of <var>key</var> is a
+ case-sensitive string match for <code>"private"</code>:
+ </dt>
+ <dd>
+ Let <var>result</var> be the octet string that represents the private
+ value <var>x</var> associated with <var>key</var> as a big integer,
+ most significant octet first.
+ </dd>
+ </dl>
+ </li>
+ <li>
+ <p>
+ Return a new ArrayBuffer containing <var>result</var>.
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>
+ If <var>format</var> is a case-sensitive string match for <code>"spki"</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> then terminate this
+ algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>parameters</var> be a new internal object.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let the <code>prime</code> property of <var>parameters</var> equal the
+ <a href="#dfn-DhKeyAlgorithm-prime">prime</a> property of the
+ <a href="#dfn-Key-algorithm">algorithm</a> property of <var>key</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let the <code>base</code> property of <var>parameters</var> equal the
+ <a href="#dfn-DhKeyAlgorithm-generator">generator</a> property of the
+ <a href="#dfn-Key-algorithm">algorithm</a> property of <var>key</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>result</var> be the result of performing the
+ <a href="#concept-encode-a-subjectPublicKeyInfo">encode a
+ subjectPublicKeyInfo</a> algorithm with the Public Value , <var>PV</var>,
+ associated
+ with <var>key</var> as
+ specified in Section 7 of [<a href="#PKCS3">PKCS #3</a>] as
+ <var>publicKey</var>, <var>parameters</var> as
+ <var>parameters</var>, the <code>DHParameter</code> structure defined in
+ Section 9 of [<a href="#PKCS3">PKCS #3</a>] as <var>parametersType</var>
+ and the <code>dhKeyAgreement</code> OID defined in Section 9
+ of [<a href="#PKCS3">PKCS #3</a>] as <var>oid</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Return <var>result</var>.
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>
+ If <var>format</var> is a case-sensitive string match for <code>"pkcs8"</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>"private"</code> then terminate this
+ algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>parameters</var> be a new internal object.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let the <code>prime</code> property of <var>parameters</var> equal the
+ <a href="#dfn-DhKeyAlgorithm-prime">prime</a> property of the
+ <a href="#dfn-Key-algorithm">algorithm</a> property of <var>key</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let the <code>base</code> property of <var>parameters</var> equal the
+ <a href="#dfn-DhKeyAlgorithm-generator">generator</a> property of the
+ <a href="#dfn-Key-algorithm">algorithm</a> property of <var>key</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>result</var> be the result of performing the
+ <a href="#concept-encode-a-privateKeyInfo">encode a
+ privateKeyInfo</a> algorithm with the octet string that represents the
+ private value, <var>x</var> associated with <var>key</var> as a big
+ integer, most significant octet first as <var>privateKey</var>,
+ <var>parameters</var> as
+ <var>parameters</var>, the <code>DHParameter</code> structure defined in
+ Section 9 of [<a href="#PKCS3">PKCS #3</a>] as <var>parametersType</var>
+ and the <code>dhKeyAgreement</code> OID defined in Section 9
+ of [<a href="#PKCS3">PKCS #3</a>] as <var>oid</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Return <var>result</var>.
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>Otherwise:</dt>
+ <dd>Terminate this algorithm with an error.</dd>
+ </dl>
+ </dd>
+ </dl>
</div>
<div class="ednote">
<p>
- TODO: This interface is broken for import/export. Generate is defined in terms of
- PKCS#3 - meaning it takes base/g and prime/p - whereas the dhpublicnumber used by
- X.509/RFC 3279 uses the X9.42 form - meaning it takes base/g, prime/p, and subprime/q.
- The inconsistency here needs to be resolved before this can be reliably implemented.
+ Since this algorithm is based on PKCS#3, import/export in X9.42 form, as
+ specified in X.509/RFC 3279 is not supported [PKCS#3 uses only prime/p and base/g
+ as parameters, wheras X9.42 adds a further value q].
</p>
</div>
</div>
--- a/spec/Overview.html Wed Feb 26 12:55:49 2014 -0800
+++ b/spec/Overview.html Wed Feb 26 13:01:24 2014 -0800
@@ -44,7 +44,7 @@
communications.
</p>
- <div class="ednote"><div class="ednoteHeader">Editorial note</div><p>There are 37 further editorial notes in the document.</p></div>
+ <div class="ednote"><div class="ednoteHeader">Editorial note</div><p>There are 39 further editorial notes in the document.</p></div>
</div>
<div class="section">
@@ -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-ctr-operations">18.10.6. 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-cmac-operations">18.12.3. 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. HmacKeyParams dictionary</a></li><li><a href="#hmac-operations">18.16.6. 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-operations">18.17.6. 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="#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-ctr-operations">18.10.6. 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-cmac-operations">18.12.3. 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. HmacKeyParams dictionary</a></li><li><a href="#hmac-operations">18.16.6. 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">
@@ -8884,6 +8884,7 @@
<h3>18.17. Diffie-Hellman</h3>
<div id="dh-description" class="section">
<h4>18.17.1. Description</h4>
+ <p class="norm">This section is non-normative.</p>
<p>
This describes using Diffie-Hellman for key generation and key agreement, as specified
by <a href="#PKCS3">PKCS #3</a>.
@@ -8921,7 +8922,7 @@
</tr>
<tr>
<td>importKey</td>
- <td>None</td>
+ <td><a href="#dfn-DhImportKeyParams">DhImportKeyParams</a></td>
<td><a href="#dfn-Key">Key</a></td>
</tr>
<tr>
@@ -8937,9 +8938,9 @@
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">
dictionary <dfn id="dfn-DhKeyGenParams">DhKeyGenParams</dfn> : <a href="#dfn-Algorithm">Algorithm</a> {
<span class="comment">// The prime p.</span>
- BigInteger prime;
+ BigInteger <dfn id="dfn-DhKeyGenParams-prime">prime</dfn>;
<span class="comment">// The base g.</span>
- BigInteger generator;
+ BigInteger <dfn id="dfn-DhKeyGenParams-generator">generator</dfn>;
};
</code></pre></div></div>
</div>
@@ -8949,9 +8950,9 @@
[NoInterfaceObject]
interface <dfn id="dfn-DhKeyAlgorithm">DhKeyAlgorithm</dfn> : <a href="#dfn-KeyAlgorithm">KeyAlgorithm</a> {
<span class="comment">// The prime p.</span>
- readonly attribute BigInteger prime;
+ readonly attribute BigInteger <dfn id="dfn-DhKeyAlgorithm-prime">prime</dfn>;
<span class="comment">// The base g.</span>
- readonly attribute BigInteger generator;
+ readonly attribute BigInteger <dfn id="dfn-DhKeyAlgorithm-generator">generator</dfn>;
};
</code></pre></div></div>
</div>
@@ -8960,26 +8961,771 @@
<div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">
dictionary <dfn id="dfn-DhKeyDeriveParams">DhKeyDeriveParams</dfn> : <a href="#dfn-Algorithm">Algorithm</a> {
<span class="comment">// The peer's public value.</span>
- BigInteger public;
+ BigInteger <dfn id="dfn-DhKeyDeriveParams-public">public</dfn>;
+};
+ </code></pre></div></div>
+ </div>
+ <div id="dh-DhImportKeyParams" class="section">
+ <h4>18.17.6. DhImportKeyParams dictionary</h4>
+ <div class="block"><div class="blockTitleDiv"><span class="blockTitle">IDL</span></div><div class="blockContent"><pre class="code"><code class="idl-code">
+dictionary <dfn id="dfn-DhImportKeyParams">DhImportKeyParams</dfn> : <a href="#dfn-Algorithm">Algorithm</a> {
+ <span class="comment">// The prime p.</span>
+ BigInteger <dfn id="dfn-DhImportKeyParams-prime">prime</dfn>;
+ <span class="comment">// The base g.</span>
+ BigInteger <dfn id="dfn-DhImportKeyParams-generator">generator</dfn>;
};
</code></pre></div></div>
</div>
<div id="dh-operations" class="section">
- <h4>18.17.6. Operations</h4>
- <ul>
- <li>Generate Key</li>
- <li>Derive Key</li>
- <li>Derive Bits</li>
- <li>Import Key</li>
- <li>Export Key</li>
- </ul>
+ <h4>18.17.7. Operations</h4>
+ <dl>
+ <dt>Generate Key</dt>
+ <dd>
+ <ol>
+ <li>
+ <p>
+ If any of the members of <a href="#dfn-DhKeyGenParams">DhKeyGenParams</a> are
+ not present in <var>normalizedAlgorithm</var>,
+ terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ If <var>usages</var> contains a value which is not a case-sensitive string match
+ for one of <code>"deriveKey"</code> or <code>"deriveBits"</code>,
+ terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Generate a Diffie-Hellman key pair, as defined in Section 7 of
+ [<a href="#PKCS3">PKCS #3</a>], with prime, <var>p</var>, and base,
+ <var>g</var>, as specified in the
+ <a href="#dfn-DhKeyGenParams-prime">prime</a> and
+ <a href="#dfn-DhKeyGenParams-generator">generator</a> properties of
+ <var>normalizedAlgorithm</var>, respectively.
+ <dl class="switch">
+ <dt>If performing the operation results in an error:</dt>
+ <dd>Terminate this algorithm with an error.</dd>
+ <dt>Otherwise:</dt>
+ <dd>
+ <ol>
+ <li>
+ <p>
+ Let <var>algorithm</var> be a new
+ <a href="#dfn-DhKeyAlgorithm">DhKeyAlgorithm</a>
+ object.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Algorithm-name">name</a> property of
+ <var>algorithm</var> to <code>"DH"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-prime">prime</a>
+ property of <var>algorithm</var> to equal the
+ <a href="#dfn-DhKeyGenParams-prime">prime</a> property of
+ <var>normalizedAlgorithm</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-generator">generator</a>
+ property of <var>algorithm</var> to equal the
+ <a href="#dfn-DhKeyGenParams-generator">generator</a> property of
+ <var>normalizedAlgorithm</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>publicKey</var> be a new <a href="#dfn-Key">Key</a> object
+ representing the public key of the generated key pair.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-type">type</a> property of <var>publicKey</var>
+ to <code>"public"</code>
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-algorithm">algorithm</a> property of
+ <var>publicKey</var> to be <var>algorithm</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-extractable">extractable</a> property of
+ <var>publicKey</var> to true.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-usages">usages</a> property of
+ <var>publicKey</var> to be the empty list.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>privateKey</var> be a new <a href="#dfn-Key">Key</a> object
+ representing the private key of the generated key pair.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-Type">type</a> property of <var>privateKey</var>
+ to <code>"private"</code>
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-algorithm">algorithm</a> property of
+ <var>privateKey</var> to be <var>algorithm</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-extractable">extractable</a> property of
+ <var>privateKey</var> to <var>extractable</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-usages">usages</a> property of
+ <var>privateKey</var> to be <var>usages</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>result</var> be a new <a href="#dfn-KeyPair">KeyPair</a>
+ object.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#def-KeyPair-publicKey">publicKey</a> property
+ of <var>result</var> to be <var>publicKey</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#def-KeyPair-privateKey">privateKey</a> property
+ of <var>result</var> to be <var>privateKey</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Return <var>result</var>.
+ </p>
+ </li>
+ </ol>
+ </dd>
+ </dl>
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>Derive Key</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>"private"</code>, terminate this
+ algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ If any of the members of <a href="#dfn-DhKeyDeriveParams">DhKeyDeriveParams</a> are not present in
+ <var>normalizedAlgorithm</var>, terminate this
+ algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Perform the Diffie Hellman Phase II algorithm as specified in
+ Section 8 of [<a href="#PKCS3">PKCS #3</a>]
+ with <var>key</var> as the DH private value <var>x</var> and the
+ <a href="#dfn-DhKeyDeriveParams-public">public</a> property of
+ <var>normalizedAlgorithm</var> as the other's public value <var>PV'</var>.
+ <dl class="switch">
+ <dt>If performing the operation results in an error:</dt>
+ <dd>Terminate this algorithm with an error.</dd>
+ <dt>Otherwise:</dt>
+ <dd>
+ Let <var>result</var> be the output of the DH Phase II, <var>SK</var>
+ </dd>
+ </dl>
+ </p>
+ </li>
+ </ol>
+ <div class="ednote"><div class="ednoteHeader">Editorial note</div>
+ <p>
+ TODO: Define how a key for algorithm <var>normalizedDerivedKeyAlgorithm</var> is
+ derived from a the secret value <var>SK</var>.
+ </p>
+ </div>
+ </dd>
+ <dt>Derive Bits</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>"private"</code>, terminate this
+ algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ If any of the members of <a href="#dfn-DhKeyDeriveParams">DhKeyDeriveParams</a> are not present in
+ <var>normalizedAlgorithm</var>, terminate this
+ algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Perform the Diffie Hellman Phase II algorithm as specified in
+ Section 8 of [<a href="#PKCS3">PKCS #3</a>]
+ with <var>key</var> as the DH private value <var>x</var> and the
+ <a href="#dfn-DhKeyDeriveParams-public">public</a> property of
+ <var>normalizedAlgorithm</var> as the other's public value <var>PV'</var>.
+ <dl class="switch">
+ <dt>If performing the operation results in an error:</dt>
+ <dd>Terminate this algorithm with an error.</dd>
+ <dt>Otherwise:</dt>
+ <dd>
+ Let <var>result</var> be the output of the DH Phase II, <var>SK</var>.
+ </dd>
+ </dl>
+ </p>
+ </li>
+ <li>
+ <p>
+ Return a new ArrayBuffer containing <var>result</var>
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>Import Key</dt>
+ <dd>
+ <dl class="switch">
+ <dt>
+ If <var>format</var> is a case-sensistive string match for <code>"raw"</code>:
+ </dt>
+ <dd>
+ <div class="ednote"><div class="ednoteHeader">Editorial note</div>
+ <p>
+ It has been suggested that "raw" import for asymmetric keys such as DH
+ should not be supported.
+ </p>
+ </div>
+ <ol>
+ <li>
+ <p>
+ If any of the members of
+ <a href="#dfn-DhImportKeyParams">DhImportKeyParams</a> are
+ not present in <var>normalizedAlgorithm</var>,
+ terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ If <var>usages</var> contains a value which is not a case-sensitive string
+ match for one of <code>"deriveKey"</code> or <code>"deriveBits"</code>,
+ terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>x</var> be the integer which results from interpreting the octets
+ of <var>keyData</var> as an unsigned big integer with most significant
+ octet first.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>key</var> be a new <a href="#dfn-Key">Key</a> object representing
+ a Diffie-Hellman private key with private value <var>x</var> and with
+ prime, <var>p</var> and base, <var>g</var> equal to the
+ <a href="#dfn-DhImportKeyParams-prime">prime</a> and
+ <a href="#dfn-DhImportKeyParams-generator">generator</a> properties
+ of <var>normalizedAlgorithm</var> respectively.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-type">type</a> propety of <var>key</var> to
+ <code>"private"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>algorithm</var> be a new
+ <a href="#dfn-DhKeyAlgorithm">DhKeyAlgorithm</a>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Algorithm-name">name</a> property of
+ <var>algorithm</var> to <code>"DH"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-prime">prime</a> property of
+ <var>algorithm</var> to equal the
+ <a href="#dfn-DhKeyImportParams-prime">prime</a> property of
+ <var>normalizedAlgorithm</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-generator">generator</a> property of
+ <var>algorithm</var> to equal the
+ <a href="#dfn-DhKeyImportParams-generator">generator</a> property of
+ <var>normalizedAlgorithm</var>.
+ </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-extractable">extractable</a> property of
+ <var>key</var> to <var>extractable</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>
+ Return <var>key</var>.
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>
+ If <var>format</var> is a case-sensistive string match for <code>"spki"</code>:
+ </dt>
+ <dd>
+ <ol>
+ <li>
+ <p>
+ If <var>usages</var> is non-empty, terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>spki</var> be the result of running the
+ <a href="#concept-parse-a-spki">parse a subjectPublicKeyInfo</a> algorithm
+ over <var>keyData</var>.
+ <ul>
+ <li>
+ <p>
+ If an error occured while parsing, terminate this algorithm with an error.
+ </p>
+ </li>
+ </ul>
+ </p>
+ </li>
+ <li>
+ <p>
+ If the <code>algorithm</code> object identifier field of the
+ <code>algorithm</code> AlgorithmIdentifier field of <var>spki</var> is not
+ equivalent to the <code>dhKeyAgreement</code> OID defined in Section 9
+ of [<a href="#PKCS3">PKCS #3</a>], terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>parameters</var> be the result of performing the
+ <a href="#concept-parse-an-asn1-structure">parse an ASN.1 structure</a>
+ algorithm, with the <code>parameters</code> field of the
+ <code>algorithm</code> AlgorithmIdentifier field of <var>spki</var> as
+ <var>data</var> and the <code>DHParameter</code> structure defined in
+ Section 9 of [<a href="#PKCS3">PKCS #3</a>] as <var>structure</var> and
+ with <var>extactData</var> set to true.
+ <ul>
+ <li>
+ <p>
+ If an error occured while parsing, terminate this algorithm with an error.
+ </p>
+ </li>
+ </ul>
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>publicValue</var> be the integer obtained by interpreting the
+ <code>subjectPublicKey</code> field of <var>spki</var> as an unsigned
+ integer, most significant bit first.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>key</var> be a new <a href="#dfn-Key">Key</a> object representing
+ a Diffie Hellman public key with prime, <var>p</var> and base,
+ <var>g</var> as specified by the <code>prime</code> and <code>base</code>
+ fields of <var>parameters</var> respectively and with public value,
+ <var>y</var> equal to <var>publicValue</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-type">type</a> propety of <var>key</var> to
+ <code>"public"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>algorithm</var> be a new
+ <a href="#dfn-DhKeyAlgorithm">DhKeyAlgorithm</a>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Algorithm-name">name</a> property of
+ <var>algorithm</var> to <code>"DH"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-prime">prime</a> property of
+ <var>algorithm</var> to equal the
+ <code>prime</code> field of <var>parameters</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-generator">generator</a> property of
+ <var>algorithm</var> to equal the
+ <code>base</code> field of
+ <var>parameters</var>.
+ </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-extractable">extractable</a> property of
+ <var>key</var> to <var>extractable</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>
+ Return <var>key</var>.
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>
+ If <var>format</var> is a case-sensistive string match for <code>"pkcs8"</code>:
+ </dt>
+ <dd>
+ <ol>
+ <li>
+ <p>
+ If <var>usages</var> contains a value which is not a case-sensitive string
+ match for one of <code>"deriveKey"</code> or <code>"deriveBits"</code>,
+ terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>privateKeyInfo</var> be the result of running the
+ <a href="#concept-parse-a-privateKeyInfo">parse a privateKeyInfo</a>
+ algorithm over <var>keyData</var>.
+ <ul>
+ <li>
+ <p>
+ If an error occured while parsing, terminate this algorithm with an error.
+ </p>
+ </li>
+ </ul>
+ </p>
+ </li>
+ <li>
+ <p>
+ If the <code>algorithm</code> object identifier field of the
+ <code>algorithm</code> AlgorithmIdentifier field of
+ <var>privateKeyInfo</var> is not
+ equivalent to the <code>dhKeyAgreement</code> OID defined in Section 9
+ of [<a href="#PKCS3">PKCS #3</a>], terminate this algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>parameters</var> be the result of performing the
+ <a href="#concept-parse-an-asn1-structure">parse an ASN.1 structure</a>
+ algorithm, with the <code>parameters</code> field of the
+ <code>algorithm</code> AlgorithmIdentifier field of
+ <var>privateKeyInfo</var> as
+ <var>data</var> and the <code>DHParameter</code> structure defined in
+ Section 9 of [<a href="#PKCS3">PKCS #3</a>] as <var>structure</var> and
+ with <var>extactData</var> set to true.
+ <ul>
+ <li>
+ <p>
+ If an error occured while parsing, terminate this algorithm with an error.
+ </p>
+ </li>
+ </ul>
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>privateValue</var> be the integer obtained by interpreting the
+ <code>privateKey</code> field of <var>privateKeyInfo</var> as an unsigned
+ integer, most significant octet first.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>key</var> be a new <a href="#dfn-Key">Key</a> object representing
+ a Diffie Hellman private key with prime, <var>p</var> and base,
+ <var>g</var> as specified by the <code>prime</code> and <code>base</code>
+ fields of <var>parameters</var> respectively and with private value,
+ <var>x</var> equal to <var>privateValue</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Key-type">type</a> propety of <var>key</var> to
+ <code>"private"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>algorithm</var> be a new
+ <a href="#dfn-DhKeyAlgorithm">DhKeyAlgorithm</a>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-Algorithm-name">name</a> property of
+ <var>algorithm</var> to <code>"DH"</code>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-prime">prime</a> property of
+ <var>algorithm</var> to equal the
+ <code>prime</code> field of <var>parameters</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Set the <a href="#dfn-DhKeyAlgorithm-generator">generator</a> property of
+ <var>algorithm</var> to equal the
+ <code>base</code> field of
+ <var>parameters</var>.
+ </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-extractable">extractable</a> property of
+ <var>key</var> to <var>extractable</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>
+ 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>
+ <dl class="switch">
+ <dt>
+ If the <a href="#dfn-Key-type">type</a> property of <var>key</var> is a
+ case-sensitive string match for <code>"public"</code>:
+ </dt>
+ <dd>
+ Let <var>result</var> be the Public Value , <var>PV</var>, associated
+ with <var>key</var> as
+ specified in Section 7 of [<a href="#PKCS3">PKCS #3</a>].
+ </dd>
+ <dt>
+ If the <a href="#dfn-Key-type">type</a> property of <var>key</var> is a
+ case-sensitive string match for <code>"private"</code>:
+ </dt>
+ <dd>
+ Let <var>result</var> be the octet string that represents the private
+ value <var>x</var> associated with <var>key</var> as a big integer,
+ most significant octet first.
+ </dd>
+ </dl>
+ </li>
+ <li>
+ <p>
+ Return a new ArrayBuffer containing <var>result</var>.
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>
+ If <var>format</var> is a case-sensitive string match for <code>"spki"</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> then terminate this
+ algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>parameters</var> be a new internal object.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let the <code>prime</code> property of <var>parameters</var> equal the
+ <a href="#dfn-DhKeyAlgorithm-prime">prime</a> property of the
+ <a href="#dfn-Key-algorithm">algorithm</a> property of <var>key</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let the <code>base</code> property of <var>parameters</var> equal the
+ <a href="#dfn-DhKeyAlgorithm-generator">generator</a> property of the
+ <a href="#dfn-Key-algorithm">algorithm</a> property of <var>key</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>result</var> be the result of performing the
+ <a href="#concept-encode-a-subjectPublicKeyInfo">encode a
+ subjectPublicKeyInfo</a> algorithm with the Public Value , <var>PV</var>,
+ associated
+ with <var>key</var> as
+ specified in Section 7 of [<a href="#PKCS3">PKCS #3</a>] as
+ <var>publicKey</var>, <var>parameters</var> as
+ <var>parameters</var>, the <code>DHParameter</code> structure defined in
+ Section 9 of [<a href="#PKCS3">PKCS #3</a>] as <var>parametersType</var>
+ and the <code>dhKeyAgreement</code> OID defined in Section 9
+ of [<a href="#PKCS3">PKCS #3</a>] as <var>oid</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Return <var>result</var>.
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>
+ If <var>format</var> is a case-sensitive string match for <code>"pkcs8"</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>"private"</code> then terminate this
+ algorithm with an error.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>parameters</var> be a new internal object.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let the <code>prime</code> property of <var>parameters</var> equal the
+ <a href="#dfn-DhKeyAlgorithm-prime">prime</a> property of the
+ <a href="#dfn-Key-algorithm">algorithm</a> property of <var>key</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let the <code>base</code> property of <var>parameters</var> equal the
+ <a href="#dfn-DhKeyAlgorithm-generator">generator</a> property of the
+ <a href="#dfn-Key-algorithm">algorithm</a> property of <var>key</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Let <var>result</var> be the result of performing the
+ <a href="#concept-encode-a-privateKeyInfo">encode a
+ privateKeyInfo</a> algorithm with the octet string that represents the
+ private value, <var>x</var> associated with <var>key</var> as a big
+ integer, most significant octet first as <var>privateKey</var>,
+ <var>parameters</var> as
+ <var>parameters</var>, the <code>DHParameter</code> structure defined in
+ Section 9 of [<a href="#PKCS3">PKCS #3</a>] as <var>parametersType</var>
+ and the <code>dhKeyAgreement</code> OID defined in Section 9
+ of [<a href="#PKCS3">PKCS #3</a>] as <var>oid</var>.
+ </p>
+ </li>
+ <li>
+ <p>
+ Return <var>result</var>.
+ </p>
+ </li>
+ </ol>
+ </dd>
+ <dt>Otherwise:</dt>
+ <dd>Terminate this algorithm with an error.</dd>
+ </dl>
+ </dd>
+ </dl>
</div>
<div class="ednote"><div class="ednoteHeader">Editorial note</div>
<p>
- TODO: This interface is broken for import/export. Generate is defined in terms of
- PKCS#3 - meaning it takes base/g and prime/p - whereas the dhpublicnumber used by
- X.509/RFC 3279 uses the X9.42 form - meaning it takes base/g, prime/p, and subprime/q.
- The inconsistency here needs to be resolved before this can be reliably implemented.
+ Since this algorithm is based on PKCS#3, import/export in X9.42 form, as
+ specified in X.509/RFC 3279 is not supported [PKCS#3 uses only prime/p and base/g
+ as parameters, wheras X9.42 adds a further value q].
</p>
</div>
</div>