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/crypto): support importing RSA JWKs #13071

Merged
merged 2 commits into from
Dec 14, 2021

Conversation

lucacasonato
Copy link
Member

@lucacasonato lucacasonato commented Dec 13, 2021

This commit adds support for importing RSA JWKs in the Web Crypto API.

Extracted out of #12022, with modifications.

Towards #11690

This commit adds support for importing RSA JWKs in the Web Crypto API.

Co-authored-by: Sean Michael Wykes <sean.wykes@nascent.com.br>
@@ -3948,240 +3948,120 @@
"Good parameters: 1024 bits (jwk, object(kty, n, e, d, p, q, dp, dq, qi), {hash: SHA-1, name: RSA-OAEP}, true, [decrypt])",
"Good parameters: 1024 bits (jwk, object(kty, n, e, d, p, q, dp, dq, qi), {hash: SHA-1, name: RSA-OAEP}, true, [unwrapKey, decrypt])",
"Good parameters: 1024 bits (jwk, object(kty, n, e, d, p, q, dp, dq, qi), {hash: SHA-1, name: RSA-OAEP}, true, [unwrapKey])",
Copy link
Member Author

Choose a reason for hiding this comment

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

These tests were extractable = true do not yet pass, because they rely on support for exporting RSA private keys (which is not implemented in this PR).

ext/crypto/import_key.rs Outdated Show resolved Hide resolved
ext/crypto/import_key.rs Outdated Show resolved Hide resolved
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM too

let hash;

// 8.
switch (jwk.alg) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@lucacasonato I believe you need a different set of JWK.alg for each algorithm. For example, RSA-OAEP-256 for RSA-OAEP, PS256 for RSA-PSS.

See
[https://www.w3.org/TR/WebCryptoAPI/#rsa-pss-operations] .. jwk step 7, and
[https://www.w3.org/TR/WebCryptoAPI/#rsa-oaep-operations] .. jwk step 8

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.

4 participants