Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow length=0 in HKDF and PBKDF2 derive bits operations #380

Merged
merged 3 commits into from
Nov 6, 2024

Conversation

twiss
Copy link
Member

@twiss twiss commented Oct 25, 2024

Fixes #370.

This PR reverts #275, and addresses #274 in an alternative way, namely by explicitly returning an empty ArrayBuffer for PBKDF2 when length=0 (as RFC 8018 does not allow dkLen=0).

Additionally, explicitly return an ArrayBuffer in all cases (the algorithm registrations already stated this, but the operations did not).


Preview | Diff

twiss added 3 commits October 25, 2024 16:11
…erations if length is zero (#275)"

This reverts commit 6438d87.
RFC 8018 does not allow passing dkLen=0. Therefore, we explicitly
return an empty ArrayBuffer in that case.
The algorithm registrations state that they return `ArrayBuffer`s,
but the operations did not.
Copy link
Collaborator

@davidben davidben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Collaborator

@Frosne Frosne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@javifernandez
Copy link
Collaborator

@nmahendru it´d be great if you could review this PR, to get also support from WebKit.
Thanks.

Copy link
Collaborator

@nmahendru nmahendru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
cc: @annevk

@twiss twiss merged commit d4ffcad into main Nov 6, 2024
2 checks passed
@twiss twiss deleted the hkdf-pbkdf2-allow-0-length branch November 6, 2024 11:32
@javifernandez javifernandez mentioned this pull request Nov 7, 2024
8 tasks
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 7, 2024
This CL adapts our implementation to the spec change described in the
PR#380 [1]. Instead of trowing an OperationError exception, we allow now
zero as value for the 'length' parameter.

Given that the deriveBits operation must result in an empty string, this
change early returns to avoid the unnecessary computation of the bits
derivation.

The specific WTP defined for this case are modified in this CL as well,
so no additional test cases are needed.

[1] w3c/webcrypto#380

Bug: 376493194
Change-Id: If685c349a0a9d134a8e8f7c902e8aac342945226
javifernandez added a commit to javifernandez/web-platform-tests that referenced this pull request Nov 8, 2024
The PR#380 [1] changed the PBKDF2 deriveBits operation to allow
zero length and introduced an additional step to return an empty
string in that case. It also reversted the PR#275 [2] so that
HKDF also handles the zero length in the same way.

This PR updates the tests cases affecting this 2 algorithms on
the cases where zero was passed in the length parameter.

[1] w3c/webcrypto#380
[2] w3c/webcrypto#275
javifernandez added a commit to javifernandez/web-platform-tests that referenced this pull request Nov 8, 2024
The PR#380 [1] changed the PBKDF2 deriveBits operation to allow
zero length and introduced an additional step to return an empty
string in that case. It also reversted the PR#275 [2] so that
HKDF also handles the zero length in the same way.

This PR updates the tests cases affecting this 2 algorithms on
the cases where zero was passed in the length parameter.

[1] w3c/webcrypto#380
[2] w3c/webcrypto#275
javifernandez added a commit to javifernandez/web-platform-tests that referenced this pull request Nov 8, 2024
The PR#380 [1] changed the PBKDF2 deriveBits operation to allow
zero length and introduced an additional step to return an empty
string in that case. It also reversted the PR#275 [2] so that
HKDF also handles the zero length in the same way.

This PR updates the tests cases affecting this 2 algorithms on
the cases where zero was passed in the length parameter.

[1] w3c/webcrypto#380
[2] w3c/webcrypto#275
github-actions bot added a commit that referenced this pull request Nov 8, 2024
SHA: d4ffcad
Reason: push, by twiss

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
twiss pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 11, 2024
… zero (#49048)

The HKDF and PBKDF2 derive bits operations were changed in [1] to allow
a zero length to be passed and return an empty ArrayBuffer in that case.

This PR updates the tests cases affecting these 2 algorithms in the
cases where zero was passed as the length parameter.

[1] w3c/webcrypto#380
aarongable pushed a commit to chromium/chromium that referenced this pull request Nov 12, 2024
This CL adapts our implementation to the spec change described in the
PR#380 [1]. Instead of trowing an OperationError exception, we allow now
zero as value for the 'length' parameter.

Given that the deriveBits operation must result in an empty string, this
change early returns to avoid the unnecessary computation of the bits
derivation.

The specific WTP defined for this case are modified in this CL as well,
so no additional test cases are needed.

[1] w3c/webcrypto#380

Bug: 376493194
Change-Id: If685c349a0a9d134a8e8f7c902e8aac342945226
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5979996
Commit-Queue: Javier Fernandez <[email protected]>
Reviewed-by: David Benjamin <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1381490}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Nov 13, 2024
…ty ArrayBuffer when length is zero, a=testonly

Automatic update from web-platform-tests
WebCrypto: HDKF and PBKDF2 return an empty ArrayBuffer when length is zero (#49048)

The HKDF and PBKDF2 derive bits operations were changed in [1] to allow
a zero length to be passed and return an empty ArrayBuffer in that case.

This PR updates the tests cases affecting these 2 algorithms in the
cases where zero was passed as the length parameter.

[1] w3c/webcrypto#380
--

wpt-commits: b81831169b8527a6c569a4ad92cf8a1baf4a7118
wpt-pr: 49048
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Nov 15, 2024
…ty ArrayBuffer when length is zero, a=testonly

Automatic update from web-platform-tests
WebCrypto: HDKF and PBKDF2 return an empty ArrayBuffer when length is zero (#49048)

The HKDF and PBKDF2 derive bits operations were changed in [1] to allow
a zero length to be passed and return an empty ArrayBuffer in that case.

This PR updates the tests cases affecting these 2 algorithms in the
cases where zero was passed as the length parameter.

[1] w3c/webcrypto#380
--

wpt-commits: b81831169b8527a6c569a4ad92cf8a1baf4a7118
wpt-pr: 49048
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Nov 16, 2024
…ty ArrayBuffer when length is zero, a=testonly

Automatic update from web-platform-tests
WebCrypto: HDKF and PBKDF2 return an empty ArrayBuffer when length is zero (#49048)

The HKDF and PBKDF2 derive bits operations were changed in [1] to allow
a zero length to be passed and return an empty ArrayBuffer in that case.

This PR updates the tests cases affecting these 2 algorithms in the
cases where zero was passed as the length parameter.

[1] w3c/webcrypto#380
--

wpt-commits: b81831169b8527a6c569a4ad92cf8a1baf4a7118
wpt-pr: 49048

UltraBlame original commit: b60e10893fce2f9a640fe2999db7e1785f638b61
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Nov 16, 2024
…ty ArrayBuffer when length is zero, a=testonly

Automatic update from web-platform-tests
WebCrypto: HDKF and PBKDF2 return an empty ArrayBuffer when length is zero (#49048)

The HKDF and PBKDF2 derive bits operations were changed in [1] to allow
a zero length to be passed and return an empty ArrayBuffer in that case.

This PR updates the tests cases affecting these 2 algorithms in the
cases where zero was passed as the length parameter.

[1] w3c/webcrypto#380
--

wpt-commits: b81831169b8527a6c569a4ad92cf8a1baf4a7118
wpt-pr: 49048

UltraBlame original commit: b60e10893fce2f9a640fe2999db7e1785f638b61
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Nov 16, 2024
…ty ArrayBuffer when length is zero, a=testonly

Automatic update from web-platform-tests
WebCrypto: HDKF and PBKDF2 return an empty ArrayBuffer when length is zero (#49048)

The HKDF and PBKDF2 derive bits operations were changed in [1] to allow
a zero length to be passed and return an empty ArrayBuffer in that case.

This PR updates the tests cases affecting these 2 algorithms in the
cases where zero was passed as the length parameter.

[1] w3c/webcrypto#380
--

wpt-commits: b81831169b8527a6c569a4ad92cf8a1baf4a7118
wpt-pr: 49048

UltraBlame original commit: b60e10893fce2f9a640fe2999db7e1785f638b61
i3roly pushed a commit to i3roly/firefox-dynasty that referenced this pull request Nov 16, 2024
…ty ArrayBuffer when length is zero, a=testonly

Automatic update from web-platform-tests
WebCrypto: HDKF and PBKDF2 return an empty ArrayBuffer when length is zero (#49048)

The HKDF and PBKDF2 derive bits operations were changed in [1] to allow
a zero length to be passed and return an empty ArrayBuffer in that case.

This PR updates the tests cases affecting these 2 algorithms in the
cases where zero was passed as the length parameter.

[1] w3c/webcrypto#380
--

wpt-commits: b81831169b8527a6c569a4ad92cf8a1baf4a7118
wpt-pr: 49048
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interop issue with HKDF deriveBits operation when length is zero
5 participants