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.generateKeyPair results in an abort #38358

Closed
zyscoder opened this issue Apr 22, 2021 · 1 comment
Closed

crypto.generateKeyPair results in an abort #38358

zyscoder opened this issue Apr 22, 2021 · 1 comment
Labels
confirmed-bug Issues with confirmed bugs. crypto Issues and PRs related to the crypto subsystem.

Comments

@zyscoder
Copy link

What steps will reproduce the bug?

Setup a node instance,

» node

and run the following javascript code.

crypto = require('crypto');crypto.generateKeyPair('dsa',{modulusLength:0,divisorLength: 2147485780},(err,publicKey,privateKey)=>{});

Then the node instance occurs an abort.

How often does it reproduce? Is there a required condition?

This abort can always be triggered following the steps above.

What is the expected behavior?

If any error occurs, an exception or other similar error-reporting stuff should be thrown. There is no reason to abort the whole node process.

What do you see instead?

» node
Welcome to Node.js v16.0.0-pre.
Type ".help" for more information.
> crypto = require('crypto');crypto.generateKeyPair('dsa',{modulusLength:0,divisorLength: 2147485780},(err,publicKey,privateKey)=>{});
/home/zys/Toolchains/node/node[53567]: ../src/crypto/crypto_dsa.cc:82:static v8::Maybe<bool> node::crypto::DsaKeyGenTraits::AdditionalConfig(node::crypto::CryptoJobMode, const v8::FunctionCallbackInfo<v8::Value>&, unsigned int*, node::crypto::DsaKeyPairGenConfig*): Assertion `args[*offset + 1]->IsInt32()' failed.
 1: 0x557dae7c5af4 node::Abort() [/home/zys/Toolchains/node/node]
 2: 0x557dae7c5b88  [/home/zys/Toolchains/node/node]
 3: 0x557dae919f2c node::crypto::DsaKeyGenTraits::AdditionalConfig(node::crypto::CryptoJobMode, v8::FunctionCallbackInfo<v8::Value> const&, unsigned int*, node::crypto::KeyPairGenConfig<node::crypto::DsaKeyPairParams>*) [/home/zys/Toolchains/node/node]
 4: 0x557dae91eba5 node::crypto::KeyGenJob<node::crypto::KeyPairGenTraits<node::crypto::DsaKeyGenTraits> >::New(v8::FunctionCallbackInfo<v8::Value> const&) [/home/zys/Toolchains/node/node]
 5: 0x557daea44167 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [/home/zys/Toolchains/node/node]
 6: 0x557daea44be2  [/home/zys/Toolchains/node/node]
 7: 0x557daea454ad  [/home/zys/Toolchains/node/node]
 8: 0x557daea4579a v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/zys/Toolchains/node/node]
 9: 0x557daf3e3259  [/home/zys/Toolchains/node/node]
[1]    53567 abort (core dumped)  /home/zys/Toolchains/node/node                                                                                                                                                                          

Additional information

@Ayase-252 Ayase-252 added crypto Issues and PRs related to the crypto subsystem. confirmed-bug Issues with confirmed bugs. labels Apr 22, 2021
@Linkgoron
Copy link
Member

I'll take a look

Linkgoron added a commit to Linkgoron/node that referenced this issue Apr 22, 2021
Change saltLength, divisorLength, primeLength and generator
checks in generateKeyPair to int32 from uint32, to align
with c++ code.

fixes: nodejs#38358
targos pushed a commit that referenced this issue Apr 29, 2021
Change saltLength, divisorLength, primeLength and generator
checks in generateKeyPair to int32 from uint32, to align
with c++ code.

fixes: #38358

PR-URL: #38364
Fixes: #38358
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. crypto Issues and PRs related to the crypto subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants