Skip to content

crypto: make generatePrime/checkPrime interruptible - #56460

Closed
jasnell wants to merge 1 commit into
nodejs:mainfrom
jasnell:jasnell/crypto-prime-interrupt
Closed

jasnell wants to merge 1 commit into
nodejs:mainfrom
jasnell:jasnell/crypto-prime-interrupt

Conversation

@jasnell

@jasnell jasnell commented Jan 3, 2025

Copy link
Copy Markdown
Member

The generatePrime and checkPrime functions in the crypto module are only somewhat interruptible. This change makes it possible to interrupt these more reliably. Note that generating overly large primes can still take a long time and may not be interruptible as this mechanism relies on a callback to check for stopping conditions but OpenSSL may perform a long running operation without calling the callback right away.

Fixes: #56449

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run. labels Jan 3, 2025
@jasnell
jasnell requested a review from anonrig January 3, 2025 23:26
@nodejs-github-bot

This comment was marked as outdated.

@aduh95

aduh95 commented Jan 4, 2025

Copy link
Copy Markdown
Contributor

Shouldn't we add a test? I think the snippet in the linked issue seems to be ideal to validate whether the issue is actually fixed and detect regressions.

@codecov

This comment was marked as outdated.

@jasnell
jasnell force-pushed the jasnell/crypto-prime-interrupt branch 2 times, most recently from 5373306 to 0e78bfb Compare January 4, 2025 02:08
@nodejs-github-bot

This comment was marked as outdated.

@jasnell

jasnell commented Jan 4, 2025

Copy link
Copy Markdown
Member Author

@aduh95 ... test added

@jasnell jasnell added author ready PRs with CI started, the required approvals, and no outstanding review comments. and removed needs-ci PRs that need a full CI run. labels Jan 4, 2025
Comment thread test/parallel/test-crypto-prime.js Outdated
@jasnell
jasnell force-pushed the jasnell/crypto-prime-interrupt branch from 0e78bfb to c06d35e Compare January 4, 2025 15:32
@nodejs-github-bot

This comment was marked as outdated.

@aduh95 aduh95 added the needs-ci PRs that need a full CI run. label Jan 4, 2025
@jasnell jasnell removed the needs-ci PRs that need a full CI run. label Jan 4, 2025
The `generatePrime` and `checkPrime` functions in the `crypto`
module are only somewhat interruptible. This change makes it
possible to interrupt these more reliably. Note that generating
overly large primes can still take a long time and may not be
interruptible as this mechanism relies on a callback to check
for stopping conditions but OpenSSL may perform a long running
operation without calling the callback right away.

Fixes: nodejs#56449
@jasnell
jasnell force-pushed the jasnell/crypto-prime-interrupt branch from c06d35e to 785f016 Compare January 5, 2025 20:03
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

ghost commented Jan 7, 2025

Copy link
Copy Markdown
Collaborator

@jasnell

ghost commented Jan 7, 2025

Copy link
Copy Markdown
Member Author

Landed in ea493c1

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

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crypto.generatePrime seems have much higher priority over than process.exit which results in stuck

5 participants