Skip to content

doc: add note about timingSafeEqual for TypedArray - #36323

Closed
tniessen wants to merge 2 commits into
nodejs:masterfrom
tniessen:doc-note-about-timingsafeequal
Closed

doc: add note about timingSafeEqual for TypedArray#36323
tniessen wants to merge 2 commits into
nodejs:masterfrom
tniessen:doc-note-about-timingsafeequal

Conversation

@tniessen

Copy link
Copy Markdown
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
Comment threaddoc/api/crypto.md Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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!

@TrottTrott left a comment

Copy link
Copy Markdown
Member

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.

@mhdawsonmhdawson left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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 <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>
@targostargos mentioned this pull request Dec 22, 2020
@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>
@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