-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
generateKeyPairSync doesn't return KeyObject #25322
Comments
Thanks for reporting this! The problem is that the native (C++) key object is being returned, not the JavaScript key object, that's why the object appears to be empty. > const { publicKey, privateKey } = crypto.generateKeyPairSync('rsa', { modulusLength: 2048 })
undefined
> publicKey.getAsymmetricKeyType()
'rsa'
> publicKey.getSymmetricKeySize()
C:\WINDOWS\system32\cmd.exe - node[6416]: src\node_crypto.cc:3350: Assertion `(key_type_) == (kKeyTypeSecret)' failed.
1: 00007FF7F0EC3FDA v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4714
2: 00007FF7F0E68AD6 uv_loop_fork+80918
3: 00007FF7F0E68B8F uv_loop_fork+81103
4: 00007FF7F0D8682F std::vector<v8::CpuProfileDeoptFrame,std::allocator<v8::CpuProfileDeoptFrame> >::vector<v8::CpuProfileDeoptFrame,std::allocator<v8::CpuProfileDeoptFrame> >+102815
5: 00007FF7F12D20BE v8::internal::ZoneVector<v8::internal::compiler::MoveOperands * __ptr64>::ZoneVector<v8::internal::compiler::MoveOperands * __ptr64>+59870
6: 00007FF7F12D3620 v8::internal::ZoneVector<v8::internal::compiler::MoveOperands * __ptr64>::ZoneVector<v8::internal::compiler::MoveOperands * __ptr64>+65344
7: 00007FF7F12D25B9 v8::internal::ZoneVector<v8::internal::compiler::MoveOperands * __ptr64>::ZoneVector<v8::internal::compiler::MoveOperands * __ptr64>+61145
8: 00007FF7F12D249B v8::internal::ZoneVector<v8::internal::compiler::MoveOperands * __ptr64>::ZoneVector<v8::internal::compiler::MoveOperands * __ptr64>+60859
9: 00000038CF650361 |
PR-URL: nodejs#25326 Fixes: nodejs#25322 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#25326 Fixes: nodejs#25322 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
@cqupt-yifanwu Your code creates a key pair and returns them as a pair of |
i want to Communication with java Server in ECDH encryption way ,but the generateKeyPairSync retruns privateKey has different length with java server |
@cqupt-yifanwu Please open a new issue for that (preferably in nodejs/help), and please include code to reproduce your problem! |
From
crypto.generateKeyPair
documentationThis documentation part is missing from
crypto.generateKeyPairSync
but you can still omit the encoding objects, then a simple empty object{}
is returned instead of an expectedKeyObject
./cc @tniessen
Examples:
The text was updated successfully, but these errors were encountered: