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

crypto: make generatePrime/checkPrime interruptible #56460

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Jan 3, 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: #56449

@nodejs-github-bot
Copy link
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
Copy link
Contributor

aduh95 commented Jan 4, 2025

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.

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
Copy link
Collaborator

@jasnell
Copy link
Member Author

jasnell commented Jan 4, 2025

@aduh95 ... test added

@jasnell jasnell added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed needs-ci PRs that need a full CI run. labels Jan 4, 2025
test/parallel/test-crypto-prime.js Outdated Show resolved Hide resolved
@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
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. 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