Skip to content

Conversation

@tniessen
Copy link
Member

Since #29657, timingSafeEqual uses byteLength instead of length. When comparing different types (e.g., Uint8Array and Uint16Array), the result can depend on the byte order of the system architecture.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-botnodejs-github-bot added crypto Issues and PRs related to the crypto subsystem. doc Issues and PRs related to the documentations. labels Nov 30, 2020
must have the same byte length.

If at least one of `a` and `b` is a `TypedArray`, the result may depend on
the platform byte order.
Copy link
Member

Choose a reason for hiding this comment

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

may depend sounds like this isn’t deterministic, but I assume it is? It’s always going to depend on the platform byte order, right?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Good point! My thinking was that the result of some inputs (e.g., timingSafeEqual(new Uint8Array([1, 1]), new Uint16Array([0x0101]))) does not depend on the platform byte order, but that's probably not what others would take away from the way I worded it.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I see … maybe I would say something like If at least one of `a` and `b` is a `TypedArray` with more than one byte per entry, like `Uint16Array`, the result will be computed using platform byte order?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Sorry about the delay, fixed!

Copy link
Member

@TrottTrott left a comment

Choose a reason for hiding this comment

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

LGTM with the elimination of may from the text.

Copy link
Member

@mhdawsonmhdawson left a comment

Choose a reason for hiding this comment

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

LGTM with @addaleax's suggestion

Thanks Anna!
@tniessentniessen added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 17, 2020
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 17, 2020
@nodejs-github-bot
Copy link
Collaborator

tniessen added a commit that referenced this pull request Dec 17, 2020
PR-URL: #36323 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
@tniessen
Copy link
MemberAuthor

Landed in 6255973, thank you for reviewing!

targos pushed a commit that referenced this pull request Dec 21, 2020
PR-URL: #36323 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
@targostargos mentioned this pull request Dec 22, 2020
@tniessentniessen deleted the doc-note-about-timingsafeequal branch January 15, 2021 17:14
targos pushed a commit that referenced this pull request May 1, 2021
PR-URL: #36323 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
@danielleadamsdanielleadams mentioned this pull request May 3, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cryptoIssues and PRs related to the crypto subsystem.docIssues and PRs related to the documentations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@tniessen@nodejs-github-bot@jasnell@Trott@addaleax@lpinca@cjihrig@mhdawson