Replies: 7 comments 4 replies
-
Sorry, I posted nodejs/help#3000 (comment) before noticing this. What does "raw key" mean in a generic context? For EdDSA specifically it does make sense (since the private key is just a bit string), but other algorithms have multiple parameters so not sure what "raw key" would mean there... |
Beta Was this translation helpful? Give feedback.
-
@mildsunrise Yeah I just mean in the context of EdDSA. If you use something like libsodium's crypto_sign_verify_detached you can just pass in the raw bytes of the key, so I'm curious if node's crypto (openssl?) supports that. |
Beta Was this translation helpful? Give feedback.
-
But libsodium's API works specifically with ed25519, right? Our API is generic, so I'm not sure how we'd do that... We could add an ed25519-specific const k = privateKey.export({ format: 'ed25519_raw' }) // returns 32-byte buffer
createPrivateKey({ key: k, format: 'ed25519_raw' }) But that looks hacky... and we'd need to do that for every EdDSA algorithm. |
Beta Was this translation helpful? Give feedback.
-
Currently no, in fact there's a TODO comment in the native code that asks if we should support raw curves. I think it's a good idea but we'd certainly need someone to do the implementation (I can add it to my list but it would be a while) |
Beta Was this translation helpful? Give feedback.
-
@jasnell In that case I'll open a tracking issue 👍 |
Beta Was this translation helpful? Give feedback.
-
@devsnek I'm not sure I understand what you mean. This works: const { generateKeyPairSync, createPublicKey } = require('crypto');
const { publicKey, privateKey } = generateKeyPairSync('rsa', {
modulusLength: 4096,
publicKeyEncoding: {
type: 'spki',
format: 'pem'
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem',
cipher: 'aes-256-cbc',
passphrase: 'top secret'
}
});
const publicKeyObject = createPublicKey(publicKey); right? |
Beta Was this translation helpful? Give feedback.
-
Is there an update on this? |
Beta Was this translation helpful? Give feedback.
-
do we have a way to do crypto with raw keys, like how libsodium works? for example, createPublicKey won't accept the raw key as far as I can tell.
cc @nodejs/crypto
Beta Was this translation helpful? Give feedback.
All reactions