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

wrapKey permission is not sufficient in iOS Safari to wrap a key #52

Open
borisreitman opened this issue Feb 9, 2018 · 6 comments
Open
Assignees
Labels

Comments

@borisreitman
Copy link

borisreitman commented Feb 9, 2018

The wrapping_key in this code has a "wrapKey" permission. However, this gave an error when I tired to used it. But, when the wrapping key also has an "encrypt" permission, there is no error.

The "wrapKey" permission should be sufficient, and it works in other browsers.

crypto.subtle.wrapKey(
  "jwk",
  key,
  wrapping_key, //the AES-GCM key with "wrapKey" usage flag
  {  
    name: "AES-GCM",
    iv: nonce,
    tagLength: 128
  }
)
@microshine
Copy link
Contributor

This is because wrapKey = exportKey + encrypt
https://github.com/PeculiarVentures/webcrypto-liner/blob/master/src/rsa/crypto.ts#L246

I'm not sure there is another way to resolve it. I think the best way is to use wrapKey usage with encrypt, and unwrapKey usage with decrypt

@borisreitman
Copy link
Author

So, how come it works in Chrome with just wrapKey without decrypt ? Is this non-standard ?

@FalconIA
Copy link

FalconIA commented Apr 2, 2018

Same question.

When I user RSA-OAEP, got a error of "CryptoKey has wrong key usage. Must be 'encrypt'".

@microshine
Copy link
Contributor

@borisreitman webcrypto-liner uses native Crypto if it's possible. This is why it doesn't throw error on wrapKey without encrypt key usage

@microshine
Copy link
Contributor

@FalconIA this is source code for RSA wrapKey https://github.com/PeculiarVentures/webcrypto-liner/blob/master/src/rsa/crypto.ts#L230-L248

As I told before wrapKey = exportKey + encrypt. This is main problem for encrypt key usage error. I've got some ideas how to fix it. I'll do it soon

@microshine microshine added the bug label Apr 2, 2018
microshine added a commit that referenced this issue Apr 2, 2018
@microshine
Copy link
Contributor

@FalconIA @borisreitman I published new version of webcrypto-liner. Can you check it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants