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

feat(ext/crypto): implement importKey and deriveBits for Pbkdf2 #11642

Merged
merged 22 commits into from
Aug 26, 2021

Conversation

littledivy
Copy link
Member

@littledivy littledivy commented Aug 11, 2021

Introduces deriveBits in SubtleCrypto

Towards #11690

@littledivy littledivy marked this pull request as ready for review August 11, 2021 08:33
@bartlomieju bartlomieju added this to the 1.14.0 milestone Aug 11, 2021
@littledivy littledivy changed the title feat(extensions/crypto): implement importKey and deriveBits for Pbkdf2 feat(ext/crypto): implement importKey and deriveBits for Pbkdf2 Aug 11, 2021
@panva

This comment has been minimized.

@lucacasonato lucacasonato self-assigned this Aug 24, 2021
@lucacasonato lucacasonato self-requested a review August 24, 2021 12:36
@bartlomieju bartlomieju requested a review from bnoordhuis August 24, 2021 17:45
switch (normalizedAlgorithm.name) {
case "PBKDF2": {
// 1.
if (length == null || length == 0 || length % 8 !== 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Where does it say that length may not be 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Can you open a spec issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

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

Looks great from my side, other than the minor issues. @bnoordhuis please review the Rust side code too.

ext/crypto/00_crypto.js Outdated Show resolved Hide resolved
switch (normalizedAlgorithm.name) {
case "PBKDF2": {
// 1.
if (length == null || length == 0 || length % 8 !== 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check if there's e.g. a WPT test that tests non-numeric inputs?

The logic is correct because e.g. "bad" % 8 evaluates to NaN and NaN !== 0 but I suspect that if it somehow managed to slip through to Rust land, it'd get coerced to zero.

Copy link
Member

Choose a reason for hiding this comment

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

@bnoordhuis All the input types are always valid. They are validated by various webidl converters at the top of this function.

Copy link
Member Author

@littledivy littledivy Aug 25, 2021

Choose a reason for hiding this comment

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

Only null as non-numeric length is tested in WPT.

Wouldn't the WebIDL converter (unsigned long) also complain? Edit: Whoops Github doesn't update in realtime

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it will. Strings will already fail parsing there, so will never reach this statement.

ext/crypto/lib.rs Show resolved Hide resolved
Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@lucacasonato lucacasonato merged commit 23a9bc0 into denoland:main Aug 26, 2021
@littledivy littledivy deleted the pbkdf2 branch August 26, 2021 11:02
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.

5 participants