From 2b3bca893c325eb4bbea8e1503582d79875f12f9 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Mon, 1 May 2023 20:14:58 +0200 Subject: [PATCH] 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. --- spec/Overview.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/Overview.html b/spec/Overview.html index 5a8000b..d47e9e3 100644 --- a/spec/Overview.html +++ b/spec/Overview.html @@ -1257,7 +1257,7 @@

SubtleCrypto interface

sequence<KeyUsage> keyUsages ); Promise<ArrayBuffer> deriveBits(AlgorithmIdentifier algorithm, CryptoKey baseKey, - unsigned long length); + optional unsigned long? length = null); Promise<CryptoKey> importKey(KeyFormat format, (BufferSource or JsonWebKey) keyData,