Skip to content

Conversation

@panva
Copy link
Member

This makes CryptoKey and KeyObject instances testable using assert.deepStrictEqual and assert.deepEqual.

The state before was that

  • deepEqual did not check extractable, algorithm, usages
  • neither deepEqual or deepStrict equal compared the key material, so two different keys with the other properties matching evaluated as equal

@panvapanva added crypto Issues and PRs related to the crypto subsystem. assert Issues and PRs related to the assert subsystem. webcrypto labels Nov 24, 2023
@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Nov 24, 2023
@panvapanva added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Nov 24, 2023
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 24, 2023
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@panvapanva added the commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. label Nov 25, 2023
@panvapanvaforce-pushed the crypto-objects-equal branch from 0965ede to 5327861CompareNovember 25, 2023 13:20
@panvapanva added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 25, 2023
@panvapanvaforce-pushed the crypto-objects-equal branch from 5327861 to ca444dbCompareNovember 25, 2023 13:27
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 25, 2023
@nodejs-github-bot

This comment was marked as outdated.

@panvapanva removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Nov 25, 2023
@panvapanvaforce-pushed the crypto-objects-equal branch from ca444db to b008047CompareNovember 25, 2023 14:33
@panvapanva added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 25, 2023
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 25, 2023
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@panva
Copy link
MemberAuthor

cc @nodejs/crypto

@nodejs-github-bot
Copy link
Collaborator

@panvapanva added the review wanted PRs that need reviews. label Nov 30, 2023
@panvapanva requested a review from aduh95December 6, 2023 09:55
@panva
Copy link
MemberAuthor

cc @nodejs/crypto

Copy link
Contributor

@aduh95aduh95 left a comment

Choose a reason for hiding this comment

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

I think the use case makes sense, and I'm not able to able to suggest a better implementation, so let's roll with this.

Comment on lines +1230 to +1231
consta=crypto.createSecretKey(Buffer.alloc(1,0));
constb=crypto.createSecretKey(Buffer.alloc(1,1));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I find Buffer.from easier to understand (I had to go read the docs to get what the second argument of Buffer.alloc was for)

Suggested change
consta=crypto.createSecretKey(Buffer.alloc(1,0));
constb=crypto.createSecretKey(Buffer.alloc(1,1));
consta=crypto.createSecretKey(Buffer.from([0]));
constb=crypto.createSecretKey(Buffer.from([1]));

@panvapanva added the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 17, 2023
@nodejs-github-botnodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Dec 17, 2023
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/50897 ✔ Done loading data for nodejs/node/pull/50897 ----------------------------------- PR info ------------------------------------ Title assert,crypto: make KeyObject and CryptoKey testable for equality (#50897) Author Filip Skokan (@panva) Branch panva:crypto-objects-equal -> nodejs:main Labels crypto, assert, util, needs-ci, review wanted, webcrypto, commit-queue-rebase Commits 2 - crypto: update CryptoKey symbol properties - assert,crypto: make KeyObject and CryptoKey testable for equality Committers 1 - Filip Skokan PR-URL: https://github.com/nodejs/node/pull/50897 Reviewed-By: Antoine du Hamel ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/50897 Reviewed-By: Antoine du Hamel -------------------------------------------------------------------------------- ℹ This PR was created on Fri, 24 Nov 2023 16:50:43 GMT ✔ Approvals: 1 ✔ - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/50897#pullrequestreview-1785408839 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2023-11-25T19:19:00Z: https://ci.nodejs.org/job/node-test-pull-request/55920/ ⚠ Commits were pushed after the last Full PR CI run: ⚠ - crypto: update CryptoKey symbol properties ⚠ - assert,crypto: make KeyObject and CryptoKey testable for equality - Querying data for job/node-test-pull-request/55920/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/7237974363

@panvapanva added request-ci Add this label to start a Jenkins CI on a PR. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Dec 17, 2023
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 17, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@panvapanva added the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 17, 2023
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 17, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in 154afbe...0afe731

nodejs-github-bot pushed a commit that referenced this pull request Dec 17, 2023
nodejs-github-bot pushed a commit that referenced this pull request Dec 17, 2023
@panvapanva deleted the crypto-objects-equal branch December 17, 2023 13:16
RafaelGSS pushed a commit that referenced this pull request Jan 2, 2024
RafaelGSS pushed a commit that referenced this pull request Jan 2, 2024
@RafaelGSSRafaelGSS mentioned this pull request Jan 2, 2024
richardlau pushed a commit that referenced this pull request Mar 25, 2024
richardlau pushed a commit that referenced this pull request Mar 25, 2024
@richardlaurichardlau mentioned this pull request Mar 25, 2024
@chharvey
Copy link
Contributor

chharvey commented Jun 9, 2024

Not sure if this is the right place to comment but I noticed a regression from v18 to v20, and this PR seems vaguely related.

consta=['a'];assert.deepStrictEqual(newSet([a,['b']]),newSet([a,['b']]));
  • v18.20.2: pass — no error as expected
  • v20.0.0: fail — unexpected error:

AssertionError [ERR_ASSERTION]: Values have same structure but are not reference-equal:

Set(2){[ 'a' ], [ 'b' ] } 

The bug seems to occur only when comparing Set objects, with a mix of elements where some elements are compared by reference (===) and other elements are compared by deep equality.

@aduh95
Copy link
Contributor

@chharvey can you open a new issue to track this please? (FWIW I'm able to reproduce)

@chharvey
Copy link
Contributor

@aduh95 thanks for your reply. I think I found the culprit and left a comment: #46593 (comment)

@panva
Copy link
MemberAuthor

@chharvey can you open a new issue to track this please?

@chharvey
Copy link
Contributor

@aduh95@panva I opened this issue: #53423

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

assertIssues and PRs related to the assert subsystem.commit-queue-rebaseAdd this label to allow the Commit Queue to land a PR in several commits.cryptoIssues and PRs related to the crypto subsystem.needs-ciPRs that need a full CI run.review wantedPRs that need reviews.utilIssues and PRs related to the built-in util module.webcrypto

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@panva@nodejs-github-bot@BridgeAR@chharvey@aduh95