-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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(crypto): support importKey
in SPKI format
#12921
Conversation
There was a lot of copy/pasting involved. Shall I refactor and introduce a more generic function for key imports, at least for RSA? |
I'm investigating why the Web platform tests are |
Thank you @littledivy. I fixed the code according to you suggestions. I found that the wpt were not passing because the public keys were deserialized as if they were private keys. There was also a couple of unexpected errors in the wpt due to checks on the emptiness of I am only left with fixing some web platform tests related to decryption using RSA-OAEP with a non-empty label. |
I also need to change the implementation of |
This has been implemented by adding a Also, I noticed that we always put the type
It was a simple issue. The label was not passed to the OP. It is fixed. Also, I took this opportunity to factor common code across all methods that copy buffers into new Uint8Arrays. The PR is ready for review @littledivy @bartlomieju. |
Good catch, sgtm. (I think I added that to be used later on but I can't recall) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Rust side of things mostly LGTM. Bartek or Luca are probably more qualified to review the JS part. (The code itself looks okay but I can't really judge whether it's up to spec.)
Minor aside (and cc @littledivy): ext/crypto/lib.rs calls custom_error("Foo", "some string".to_string())
a lot but that's inefficient because it allocates the string on the heap. You can just custom_error("Foo", "some string")
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'll submit another PR that changes this. |
I managed to find a way, but I can't replicate it with ECDSA as ring doesn't really let us generate the public key and private key already separated. It only provides a pkcs8-formatted buffer, which would then need to be parsed again to get the raw keys. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM to me too, cleanly implemented!
Before landing, I will wait for @lucacasonato review.
)); | ||
} | ||
|
||
hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a check missing here:
- If the parameters field of the maskGenAlgorithm field of params is not an instance of the HashAlgorithm ASN.1 type that is identical in content to the hashAlgorithm field of params, throw a NotSupportedError.
This is very close @yacinehmito. Thanks for working on this :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Incredible work, thank you @yacinehmito. At least 700 more passing tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you @yacinehmito!
Work towards #11690.
This is a good milestone. Now, there is a key format that can be both imported and exported for RSA. This wasn't the case before, and it was a real blocker to implement an authorization server in Deno.