mdn / browser-compat-data

This repository contains compatibility data for Web technologies as displayed on MDN
https://developer.mozilla.org
Creative Commons Zero v1.0 Universal
4.99k stars 2k forks source link

api.SubtleCrypto.importKey does not work for 8192 bit key length (RSA-OAEP) #8752

Open thinkagain-debug opened 3 years ago

thinkagain-debug commented 3 years ago

What information was incorrect, unhelpful, or incomplete?

importKey throws an error: [Log] DataError: Data provided to an operation does not meet requirements —

also generateKey does not work for 8192 bit key length

What did you expect to see?

imported key to crypt data

Did you test this? If so, how?

let keyPair = window.crypto.subtle.generateKey(
  {
    name: "RSA-OAEP",
    modulusLength: 8192,
    publicExponent: new Uint8Array([1, 0, 1]),
    hash: "SHA-512"
  },
  true,
  ["encrypt", "decrypt"]
);

same code works on other browsers like firefox, chrome

MDN page report details * Query: `api.SubtleCrypto.importKey` * MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey * Report started: 2021-01-14T08:59:30.192Z
queengooborg commented 3 years ago

Hi there -- to further assist in resolving this issue, may I ask what browser and browser version you are using?

thinkagain-debug commented 3 years ago

Safari 14.0.2 (Mac)

On iPhone (iOS 14.3) it doesn't work too

ddbeck commented 3 years ago

Hi @thinkagain-debug, thanks for noting this (and providing some helpful code to exercise the problem quickly).

To reflect this difference in behavior between browsers, I would suggest adding a note that describes this limitation for Safari and Safari for iOS on the generateKey and importKey features in SubtleCrypto.json. The spec doesn't seem to require support for any particular key length, so I don't think we need to change the support data beyond a note. For the note itself, I'd suggest a wording along the lines of "Throws an <code>OperationError</code> for RSA-OAEP keys greater than 4096 bits long." or similar.

I'd welcome a PR from you (or another contributor) to update the features. Thank you!