Skip to content

Commit be453c6

Browse files
committed
Make deriveBits length parameter optional and nullable
Allow omitting the `length` parameter from calls to `deriveBits`, defaulting to `null`, and also allow passing `null` explicitly (as the web platform tests already do). The "derive bits" operations already handle `null` as it can also be returned by the "get key length" operations. In the case of ECDH, the operation returns the entire derived key; in the case of HKDF and PBKDF2, the operation returns an error. This is technically speaking a breaking change, since currently passing `null` explicitly should cause it to be converted to `0`, causing an empty `ArrayBuffer` to be returned. However, the only implementation that actually does so (Chromium) is willing to change this. Additionally, returning the entire value (for ECDH) seems more expected and more useful than returning an empty value.
1 parent 0eed687 commit be453c6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

spec/Overview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ <h2>SubtleCrypto interface</h2>
12571257
sequence&lt;KeyUsage> keyUsages );
12581258
Promise&lt;ArrayBuffer> deriveBits(AlgorithmIdentifier algorithm,
12591259
CryptoKey baseKey,
1260-
unsigned long length);
1260+
optional unsigned long length? = null);
12611261

12621262
Promise&lt;CryptoKey> importKey(KeyFormat format,
12631263
(BufferSource or JsonWebKey) keyData,

0 commit comments

Comments
 (0)