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
{{ message }}
Repository navigation
Feature request: Support create public key from components method? #24471
I cannot use ursa anymore at node v10. So I'm trying to move to native crypto.
But the problem is, native crypto seems not support create public key from components.
So, why don't you support create public key from components method?
constursa=require('ursa');// modulus should be a base64/base64Url stringconstmodulus=newBuffer(modulusStr,'base64');// exponent should be base64/base64urlconstexponent=newBuffer('AQAB','base64');constpubKey=ursa.createPublicKeyFromComponents(modulus,exponent);console.info(pubKey.toPublicPem('utf8'));// ------BEGIN PUBLIC KEY------// ...
This came up in a discussion around the key object API recently. Currently, the only way to do this is to manually create an SPKI structure. That might change in the future, though.
@tniessen Can you clarify? I assume you're not talking about openssl's NETSCAPE_SPKI.
There's DSA_set0_key() and RSA_set0_key(). I'd be okay with adding bindings for those. We already use/expose DH_set0_key().
It might get a bit awkward if we also want to support EC keys through the same API because they're quite different from RSA and DSA keys, and because there's some overlap with the ECDH class.
(ECDH can generate keys from an arbitrary private key. 'Arbitrary' in the sense that the private key is just a bignum encoded as a buffer.)
On the other hand, DSA and RSA keys have well-defined formats. It's not hard to write a npm module that takes some BigInts and spits out PEM. There's no real reason it should live in core except convenience.
Can you clarify? I assume you're not talking about openssl's NETSCAPE_SPKI.
I meant this, where PEM would encode a SubjectPublicKeyInfo (SPKI) structure:
On the other hand, DSA and RSA keys have well-defined formats. It's not hard to write a npm module that takes some BigInts and spits out PEM. There's no real reason it should live in core except convenience.
I think this discussion should be aligned with the more recent comments in #15113 regarding JWK support. JWK recommends support for EC, by the way.
I am considering extending #30045 with a .fields property to retrieve components, and adding a KeyObject.from({ type, asymmetricKeyType, params: { ... }, fields: { ... } }) function, but I am open to other ideas, too. (cc @panva)
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.
Activity
Trott commentedon Nov 19, 2018
@nodejs/crypto
tniessen commentedon Nov 19, 2018
This came up in a discussion around the key object API recently. Currently, the only way to do this is to manually create an SPKI structure. That might change in the future, though.
bnoordhuis commentedon Nov 22, 2018
@tniessen Can you clarify? I assume you're not talking about openssl's
NETSCAPE_SPKI.There's
DSA_set0_key()andRSA_set0_key(). I'd be okay with adding bindings for those. We already use/exposeDH_set0_key().It might get a bit awkward if we also want to support EC keys through the same API because they're quite different from RSA and DSA keys, and because there's some overlap with the
ECDHclass.(
ECDHcan generate keys from an arbitrary private key. 'Arbitrary' in the sense that the private key is just a bignum encoded as a buffer.)On the other hand, DSA and RSA keys have well-defined formats. It's not hard to write a npm module that takes some BigInts and spits out PEM. There's no real reason it should live in core except convenience.
tniessen commentedon Jan 15, 2019
Sorry, Ben, I must have missed the notitfication.
I meant this, where PEM would encode a SubjectPublicKeyInfo (SPKI) structure:
I think this discussion should be aligned with the more recent comments in #15113 regarding JWK support. JWK recommends support for EC, by the way.
jainendra commentedon Jan 4, 2020
@belldoor Is there anyway to do this now ?
bnoordhuis commentedon Jan 4, 2020
@jainendra You can use https://www.npmjs.com/package/bursar (I wrote it a while ago in response to this issue but I forgot to publish it... Done just now.)
Some examples here: https://github.com/bnoordhuis/node-bursar/blob/9447b188b9f424a72dac5a318a1ffe6596057822/test.js#L30-L85
tniessen commentedon Jan 4, 2020
I am considering extending #30045 with a
.fieldsproperty to retrieve components, and adding aKeyObject.from({ type, asymmetricKeyType, params: { ... }, fields: { ... } })function, but I am open to other ideas, too. (cc @panva)panva commentedon Jan 4, 2020
@tniessen sounds great!
crypto: add KeyObject.from and keyObject.export JWK format support
github-actions commentedon May 15, 2022
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
github-actions commentedon Jun 15, 2022
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.
For more information on how the project manages feature requests, please consult the feature request management document.