Skip to content

Commit

Permalink
Allow length=0 in HKDF and PBKDF2 derive bits operations (#380)
Browse files Browse the repository at this point in the history
* Revert "Throw an OperationError in the PBKDF2 and HKDF derive bits operations if length is zero (#275)"

This reverts commit 6438d87.

* Properly handle length=0 in the PBKDF2 derive bits operation

RFC 8018 does not allow passing dkLen=0. Therefore, we explicitly
return an empty ArrayBuffer in that case.

* Explicitly return `ArrayBuffer`s in HKDF and PBKDF2

The algorithm registrations state that they return `ArrayBuffer`s,
but the operations did not.
  • Loading branch information
twiss authored Nov 6, 2024
1 parent 85a4826 commit d4ffcad
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions spec/Overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -13105,7 +13105,7 @@ <h4>Operations</h4>
<ol>
<li>
<p>
If |length| is null or zero, or is not a multiple of 8, then [= exception/throw =] an {{OperationError}}.
If |length| is null or is not a multiple of 8, then [= exception/throw =] an {{OperationError}}.
</p>
</li>
<li>
Expand Down Expand Up @@ -13160,7 +13160,8 @@ <h4>Operations</h4>
</li>
<li>
<p>
Return |result|.
Return the result of [= ArrayBuffer/create | creating =]
an {{ArrayBuffer}} containing |result|.
</p>
</li>
</ol>
Expand Down Expand Up @@ -13324,7 +13325,7 @@ <h4>Operations</h4>
<ol>
<li>
<p>
If |length| is null or zero, or is not a multiple of 8, then [= exception/throw =] an {{OperationError}}.
If |length| is null or is not a multiple of 8, then [= exception/throw =] an {{OperationError}}.
</p>
</li>
<li>
Expand All @@ -13333,6 +13334,13 @@ <h4>Operations</h4>
then [= exception/throw =] an {{OperationError}}.
</p>
</li>
<li>
<p>
If |length| is zero, return the result of
[= ArrayBuffer/create | creating =] an {{ArrayBuffer}}
containing an empty [= byte sequence =].
</p>
</li>
<li>
<p>
Let |prf| be the MAC Generation function described in Section 4 of
Expand Down Expand Up @@ -13362,7 +13370,8 @@ <h4>Operations</h4>
</li>
<li>
<p>
Return |result|
Return the result of [= ArrayBuffer/create | creating =]
an {{ArrayBuffer}} containing |result|.
</p>
</li>
</ol>
Expand Down

0 comments on commit d4ffcad

Please sign in to comment.