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

Improve JWK importing #38

Open
2 tasks
microshine opened this issue Nov 10, 2021 · 0 comments
Open
2 tasks

Improve JWK importing #38

microshine opened this issue Nov 10, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@microshine
Copy link
Collaborator

  • Compare jwk.alg (if presents) with algorithm argument and throw DOMException if they are not equal

Example

var key = await crypto.subtle.generateKey({name: "AES-CBC", length: 256}, true, ["encrypt", "decrypt"]);
var jwk = await crypto.subtle.exportKey("jwk", key);
delete jwk.key_ops
var hmacKey = await crypto.subtle.importKey("jwk", jwk, {name: "AES-KW"}, false, ["wrapKey"]);

DOMException (Chrome)

DOMException: The JWK "alg" member was inconsistent with that specified by the Web Crypto call
  • Compare jwk.key_ops (if presents) with keyUsages argument and throw DOMException if they are not equal

Example

var key = await crypto.subtle.generateKey({name: "AES-CBC", length: 256}, true, ["encrypt", "decrypt"]);
var jwk = await crypto.subtle.exportKey("jwk", key);
var hmacKey = await crypto.subtle.importKey("jwk", jwk, {name: "AES-KW"}, false, ["wrapKey"]);

DOMException (Chrome)

DOMException: The JWK "key_ops" member was inconsistent with that specified by the Web Crypto call. The JWK usage must be a superset of those requested
@microshine microshine added the enhancement New feature or request label Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant