Skip to content
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

feat(ext/node): add support for named curves in crypto.generateKeyPair[Sync]() #22882

Merged
merged 2 commits into from Mar 13, 2024

Conversation

iuioiua
Copy link
Collaborator

@iuioiua iuioiua commented Mar 13, 2024

Towards fixing #21761

@iuioiua iuioiua changed the title fix(ext/node): add support for prime256v1 named curve in crypto.generateKeyPairSync() feat(ext/node): add support for prime256v1 named curve in crypto.generateKeyPairSync() Mar 13, 2024
@iuioiua iuioiua changed the title feat(ext/node): add support for prime256v1 named curve in crypto.generateKeyPairSync() feat(ext/node): add support for prime256v1 named curve in crypto.generateKeyPair[Sync]() Mar 13, 2024
@jareddr
Copy link

jareddr commented Mar 13, 2024

Hi, I'm not affiliated with the project at all, but I just posted a related issue: #22879

I still don't fully understand my issue as I'm way out of my depth the the cryptography here, but I'm hoping your PR will fix my issue as well.

What I'm seeing is that the eno_node/internal/crypto/keys.ts code is using the p256 algorithm as seen in the return of the op_node_create_private_key function in this block

export function createPrivateKey(key) {
  const { data, format, type } = prepareAsymmetricKey(key);
  const details = op_node_create_private_key(data, format, type);
  const handle = setOwnedKey(copyBuffer(data));
  return new PrivateKeyObject(handle, details);
}

Hoping your changes will allow this function to create a private key object that uses prime256v1, fingers crossed. Thanks!

Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Please also add secp256r1. (prime256v1, secp256r1 and NIST p-256 are the same)

@iuioiua iuioiua changed the title feat(ext/node): add support for prime256v1 named curve in crypto.generateKeyPair[Sync]() feat(ext/node): add support for named curves in crypto.generateKeyPair[Sync]() Mar 13, 2024
@iuioiua
Copy link
Collaborator Author

iuioiua commented Mar 13, 2024

Ah, good point. I've added that, prime384v1 and secp384r1 too.

@iuioiua iuioiua requested a review from littledivy March 13, 2024 06:03
@littledivy littledivy merged commit 6e6c316 into denoland:main Mar 13, 2024
17 checks passed
@iuioiua iuioiua deleted the generateKeyPairSync-prime256v1 branch March 13, 2024 06:48
magurotuna pushed a commit to magurotuna/deno that referenced this pull request Mar 13, 2024
nathanwhit pushed a commit that referenced this pull request Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants