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): import JWK key for HMAC #11716

Merged
merged 22 commits into from
Aug 27, 2021

Conversation

littledivy
Copy link
Member

Towards #11690

@littledivy littledivy marked this pull request as ready for review August 15, 2021 15:48
@bartlomieju bartlomieju added this to the 1.14.0 milestone Aug 17, 2021
@lucacasonato lucacasonato self-requested a review August 24, 2021 12:41
@bartlomieju bartlomieju requested a review from bnoordhuis August 24, 2021 17:44
ext/crypto/00_crypto.js Outdated Show resolved Hide resolved
ext/crypto/00_crypto.js Outdated Show resolved Hide resolved
ext/crypto/00_crypto.js Outdated Show resolved Hide resolved
ext/crypto/00_crypto.js Outdated Show resolved Hide resolved
ext/crypto/00_crypto.js Outdated Show resolved Hide resolved
ext/crypto/00_crypto.js Outdated Show resolved Hide resolved
ext/crypto/00_crypto.js Outdated Show resolved Hide resolved
ext/crypto/00_crypto.js Outdated Show resolved Hide resolved
Comment on lines +668 to +670
if (keyUsages.length == 0) {
throw new DOMException("Key usage is empty", "SyntaxError");
}
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 the spec say to do this?

Copy link
Member Author

Choose a reason for hiding this comment

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

ext/crypto/01_webidl.js Show resolved Hide resolved
Copy link
Contributor

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

LGTM but caveat emptor, I'm not a JWK expert.

Comment on lines 109 to 112
StringPrototypeSplit(
atob(
StringPrototypeReplace(
StringPrototypeReplace(key, /\-/g, "+"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Using split() and replace() has the (global, user visible) side effect of clobbering RegExp.$_, etc.

(Aside: I also feel this code is really hard to read.)

Copy link
Member

Choose a reason for hiding this comment

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

@littledivy Can you split this across multiple lines rather than nesting these calls?

Copy link
Member Author

@littledivy littledivy Aug 27, 2021

Choose a reason for hiding this comment

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

Done (also made it a bit more readable)

ext/crypto/00_crypto.js Outdated Show resolved Hide resolved
// 7.
if (
normalizedAlgorithm.length > length ||
normalizedAlgorithm.length <= (length - 8)
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks kind of weird to me. length === data.byteLength * 8 so is this trying to say if (length !== normalizedAlgoritm.length) in a roundabout way?

Copy link
Member

Choose a reason for hiding this comment

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

It expresses the following:
image

ext/crypto/00_crypto.js Outdated 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.

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.

4 participants