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

doc: add note about timingSafeEqual for TypedArray #36323

Closed

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-bot nodejs-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
Member Author

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
Member Author

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

@Trott Trott 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

@mhdawson mhdawson 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!
@tniessen tniessen added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 17, 2020
@github-actions github-actions bot 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 <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
@tniessen
Copy link
Member Author

Landed in 6255973, thank you for reviewing!

@tniessen tniessen closed this Dec 17, 2020
targos pushed a commit that referenced this pull request Dec 21, 2020
PR-URL: #36323
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
@tniessen tniessen 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 <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
@danielleadams danielleadams mentioned this pull request May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem. doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants