Skip to content

Commit 467780a

Browse files
committed
Fix false positive in supports
Fix the case when e.g. `supports('deriveKey', 'PBKDF2', 'HKDF')` returns true because the length parameter from the "get key length" operation of HKDF (which returns null, which causes the "deriveKey" operation of PBKDF2 to throw) is not available. (The same is true for other combinations of PBKDF2 and HKDF.)
1 parent e5909dd commit 467780a

File tree

1 file changed

+45
-30
lines changed

1 file changed

+45
-30
lines changed

index.html

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -746,16 +746,12 @@ <h4>The supports method</h4>
746746
</li>
747747
<li>
748748
<dl class="switch">
749-
<dt>If |operation| is "`deriveKey`":</dt>
749+
<dt>If |operation| is "`deriveKey`", "`unwrapKey`", "`encapsulateKey`" or "`decapsulateKey`":</dt>
750750
<dd>
751751
<p>
752752
If the result of [= check support for an algorithm | checking support for an algorithm =]
753753
with `op` set to "`importKey`"
754754
and `alg` set to |additionalAlgorithm|
755-
is false, or
756-
the result of [= check support for an algorithm | checking support for an algorithm =]
757-
with `op` set to "`get key length`"
758-
and `alg` set to |additionalAlgorithm|
759755
is false,
760756
return false.
761757
</p>
@@ -770,32 +766,56 @@ <h4>The supports method</h4>
770766
return false.
771767
</p>
772768
</dd>
773-
<dt>If |operation| is "`unwrapKey`":</dt>
774-
<dd>
775-
<p>
776-
If the result of [= check support for an algorithm | checking support for an algorithm =]
777-
with `op` set to "`importKey`"
778-
and `alg` set to |additionalAlgorithm|
779-
is false,
780-
return false.
781-
</p>
782-
</dd>
783-
<dt>If |operation| is "`encapsulateKey`" or "`decapsulateKey`":</dt>
769+
</dl>
770+
</li>
771+
<li>
772+
<p>
773+
Let |length| be null.
774+
</p>
775+
</li>
776+
<li>
777+
<dl class="switch">
778+
<dt>If |operation| is "`deriveKey`":</dt>
784779
<dd>
785-
<p>
786-
If the result of [= check support for an algorithm | checking support for an algorithm =]
787-
with `op` set to "`importKey`"
788-
and `alg` set to |additionalAlgorithm|
789-
is false,
790-
return false.
791-
</p>
780+
<ol>
781+
<li>
782+
<p>
783+
If the result of [= check support for an algorithm | checking support for an algorithm =]
784+
with `op` set to "`get key length`"
785+
and `alg` set to |additionalAlgorithm|
786+
is false,
787+
return false.
788+
</p>
789+
</li>
790+
<li>
791+
<p>
792+
Let |normalizedDerivedKeyAlgorithmLength| be the result of
793+
<a data-cite="webcrypto#dfn-normalize-an-algorithm">normalizing an algorithm</a>, with
794+
`alg` set to |derivedKeyType| and `op` set to
795+
"`get key length`".
796+
</p>
797+
</li>
798+
<li>
799+
<p>
800+
Let |length| be the result of performing the get key length
801+
algorithm specified by |additionalAlgorithm| using
802+
|derivedKeyType|.
803+
</p>
804+
</li>
805+
<li>
806+
<p>
807+
Set |operation| to "`deriveBits`".
808+
</p>
809+
</li>
810+
</ol>
792811
</dd>
793812
</dl>
794813
</li>
795814
<li>
796815
<p>
797816
Return the result of [= check support for an algorithm | checking support for an algorithm =],
798-
with `op` set to |operation| and `alg` set to |algorithm|.
817+
with `op` set to |operation|, `alg` set to |algorithm|,
818+
and `length` set to |length|.
799819
</p>
800820
</li>
801821
</ol>
@@ -808,15 +828,10 @@ <h3>Checking support for an algorithm</h3>
808828
The <dfn id="dfn-check-support-for-algorithm">check support for an algorithm</dfn> algorithm
809829
defines a process for checking whether the given algorithm is supported for the given operation.
810830
Its input is an operation name |op|, an {{AlgorithmIdentifier}} |alg|,
811-
and an optional |length| parameter. Its output is a boolean.
831+
and a |length| parameter. Its output is a boolean.
812832
It behaves as follows:
813833
</p>
814834
<ol>
815-
<li>
816-
<p>
817-
If |op| is "`deriveKey`", set |op| to "`deriveBits`".
818-
</p>
819-
</li>
820835
<li>
821836
<p>
822837
If |op| is "`encapsulateKey`" or "`encapsulateBits`", set |op| is "`encapsulate`".

0 commit comments

Comments
 (0)