Implement SubtleCrypto.deriveBits with PBDKF2 (#34164)

* Start implementing SubtleCrypto.deriveBits

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Move shared crypto operations into their own functions

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update some doclinks

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Remove note about potential no-op

It is, indeed, a no-op.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Move normalized algorithm digest operation into its own function

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Implement mvp for pbkdf2 derivation

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Add missing division to derive bytes instead of bits

The length argument specifies the number of bits that
we need to derive, so we should divide it by 8 to
get the number of bytes.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Allow using PBKDF2 with usage "importKey"

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update WPT expectations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix test-tidy errors

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Fix clippy warnings

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2024-11-06 16:52:15 +01:00 committed by GitHub
parent c0a4eee1fe
commit 2f6ca9407b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 369 additions and 4447 deletions

View file

@ -30,12 +30,6 @@
[X25519 non-multiple of 8 bits]
expected: FAIL
[X25519 missing public property]
expected: FAIL
[X25519 public property of algorithm is not a CryptoKey]
expected: FAIL
[X25519 mismatched algorithms]
expected: FAIL
@ -86,12 +80,6 @@
[X25519 non-multiple of 8 bits]
expected: FAIL
[X25519 missing public property]
expected: FAIL
[X25519 public property of algorithm is not a CryptoKey]
expected: FAIL
[X25519 mismatched algorithms]
expected: FAIL

View file

@ -26,12 +26,6 @@
[X448 non-multiple of 8 bits]
expected: FAIL
[X448 missing public property]
expected: FAIL
[X448 public property of algorithm is not a CryptoKey]
expected: FAIL
[X448 mismatched algorithms]
expected: FAIL
@ -80,12 +74,6 @@
[X448 non-multiple of 8 bits]
expected: FAIL
[X448 missing public property]
expected: FAIL
[X448 public property of algorithm is not a CryptoKey]
expected: FAIL
[X448 mismatched algorithms]
expected: FAIL

View file

@ -14,21 +14,6 @@
[HKDF derivation with omitted as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with 256 as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with 0 as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with null as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with undefined as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with omitted as 'length' parameter]
expected: FAIL
[ECDH derivation with 256 as 'length' parameter]
expected: FAIL
@ -65,12 +50,6 @@
[HKDF derivation with 230 as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with 384 as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with 230 as 'length' parameter]
expected: FAIL
[ECDH derivation with 384 as 'length' parameter]
expected: FAIL
@ -100,21 +79,6 @@
[HKDF derivation with omitted as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with 256 as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with 0 as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with null as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with undefined as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with omitted as 'length' parameter]
expected: FAIL
[ECDH derivation with 256 as 'length' parameter]
expected: FAIL
@ -151,12 +115,6 @@
[HKDF derivation with 230 as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with 384 as 'length' parameter]
expected: FAIL
[PBKDF2 derivation with 230 as 'length' parameter]
expected: FAIL
[ECDH derivation with 384 as 'length' parameter]
expected: FAIL

View file

@ -11,12 +11,6 @@
[P-521 non-multiple of 8 bits]
expected: FAIL
[P-521 missing public curve]
expected: FAIL
[P-521 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-521 mismatched curves]
expected: FAIL
@ -50,12 +44,6 @@
[P-256 non-multiple of 8 bits]
expected: FAIL
[P-256 missing public curve]
expected: FAIL
[P-256 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-256 mismatched curves]
expected: FAIL
@ -89,12 +77,6 @@
[P-384 non-multiple of 8 bits]
expected: FAIL
[P-384 missing public curve]
expected: FAIL
[P-384 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-384 mismatched curves]
expected: FAIL
@ -130,12 +112,6 @@
[P-521 non-multiple of 8 bits]
expected: FAIL
[P-521 missing public curve]
expected: FAIL
[P-521 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-521 mismatched curves]
expected: FAIL
@ -169,12 +145,6 @@
[P-256 non-multiple of 8 bits]
expected: FAIL
[P-256 missing public curve]
expected: FAIL
[P-256 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-256 mismatched curves]
expected: FAIL
@ -208,12 +178,6 @@
[P-384 non-multiple of 8 bits]
expected: FAIL
[P-384 missing public curve]
expected: FAIL
[P-384 public property of algorithm is not a CryptoKey]
expected: FAIL
[P-384 mismatched curves]
expected: FAIL

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff