Replies: 10 comments 8 replies
|
Sorry, I posted #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... |
|
@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. |
|
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. |
|
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) |
|
@jasnell In that case I'll open a tracking issue 👍 |
@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? |
|
Is there an update on this? |
|
Great to see raw key format support ( While exploring the crypto internals around this area, I noticed a related (but separate) issue worth flagging — the This means if new algorithms become available after an engine/provider is loaded (which could be relevant for custom EdDSA providers), the cached lists won't reflect them. I've opened a separate discussion about this here: https://github.com/orgs/nodejs/discussions/5148 Curious if anyone who worked on raw key support ran into the same caching behavior during development? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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
All reactions