Skip to content

crypto.generateKeyPair results in an abort #38358

Closed
@zyscoder

Description

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

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.cryptoIssues and PRs related to the crypto subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions