You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Platform: macOS Mojave (10.14.2) Darwin C02TT3JQHTD6 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64
From crypto.generateKeyPair documentation
If a publicKeyEncoding or privateKeyEncoding was specified, this function behaves as if keyObject.export() had been called on its result. Otherwise, the respective part of the key is returned as a KeyObject.
This 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 expected KeyObject.
changed the title [-]generateKeyPair (+sync) doesn't return KeyObject as documented[/-][+]generateKeyPair (+sync) doesn't return KeyObject as documented when promisified[/+]on Jan 3, 2019
changed the title [-]generateKeyPair (+sync) doesn't return KeyObject as documented when promisified[/-][+]generateKeyPairSync doesn't return KeyObject[/+]on Jan 3, 2019
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.
@cqupt-yifanwu Your code creates a key pair and returns them as a pair of Buffers, because you specified the publicKeyEncoding and privateKeyEncoding options. Buffer does not have properties such as getAsymmetricKeyType and getSymmetricKeySize. You can either remove the encoding options and use KeyObjects, or create KeyObjects from the returned Buffers.
@cqupt-yifanwu Your code creates a key pair and returns them as a pair of Buffers, because you specified the publicKeyEncoding and privateKeyEncoding options. Buffer does not have properties such as getAsymmetricKeyType and getSymmetricKeySize. You can either remove the encoding options and use KeyObjects, or create KeyObjects from the returned Buffers.
i want to Communication with java Server in ECDH encryption way ,but the generateKeyPairSync retruns privateKey has different length with java server
Activity
[-]generateKeyPair (+sync) doesn't return KeyObject as documented[/-][+]generateKeyPair (+sync) doesn't return KeyObject as documented when promisified[/+][-]generateKeyPair (+sync) doesn't return KeyObject as documented when promisified[/-][+]generateKeyPairSync doesn't return KeyObject[/+]tniessen commentedon Jan 3, 2019
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.
crypto: fix key object wrapping in sync keygen
crypto: fix key object wrapping in sync keygen
crypto: fix key object wrapping in sync keygen
crypto: fix key object wrapping in sync keygen
tniessen commentedon Dec 19, 2019
@cqupt-yifanwu Your code creates a key pair and returns them as a pair of
Buffers, because you specified thepublicKeyEncodingandprivateKeyEncodingoptions.Bufferdoes not have properties such asgetAsymmetricKeyTypeandgetSymmetricKeySize. You can either remove the encoding options and useKeyObjects, or createKeyObjectsfrom the returnedBuffers.cqupt-yifanwu commentedon Dec 19, 2019
i want to Communication with java Server in ECDH encryption way ,but the generateKeyPairSync retruns privateKey has different length with java server
tniessen commentedon Dec 19, 2019
@cqupt-yifanwu Please open a new issue for that (preferably in nodejs/help), and please include code to reproduce your problem!
crypto: fix key object wrapping in sync keygen