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

Firefox cannot store EC private keys in IndexedDB #1

Open
dholms opened this issue Feb 20, 2020 · 2 comments
Open

Firefox cannot store EC private keys in IndexedDB #1

dholms opened this issue Feb 20, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@dholms
Copy link
Contributor

dholms commented Feb 20, 2020

Problem

Google Chrome is able to store any key (that I've tried at least) in IndexedDB with no issues.

Firefox is able to store symmetric AES keys as well as RSA private keys, but throws the following error when attempting to store an ECDH/ECDSA private key:
DataCloneError: The object could not be cloned.
Note: it is specifically the private key that causes this, not the public

This is strange because the Mozilla recommendation for key management with the Web Crypto API is to store them in IndexedDB

This has to do with the way that Firefox has implemented the Structured Clone Algorithm which is an HTML specification used for storage in IndexedDB but also in other cases of data transfer such as communication between Workers via postMessage (you can see my tests of structuralClone using postMessage in src/utils.ts).

The only relevant bug report I could find is Here. Although I've tried this with both an exportable and a non-exportable key and it doesn't work either way. Apparently that issue is reliant on this one which hasn't shown any movement in 2yrs.

Others have run into this issue as well: localForage/localForage#844 (comment) And it seems that the issue is also present on Safari (I'll rely on someone else to give that a shot 😉)

Solution

Unclear right now. Needs more investigation/discussion.

What's the path forward if we can't get ECDSA/ECDH keys in Firefox/Safari? RSA keys? Or use something other than WebCrypto/IndexedDB?

@dholms dholms added the bug Something isn't working label Feb 20, 2020
@dholms dholms self-assigned this Feb 20, 2020
@dholms
Copy link
Contributor Author

dholms commented Feb 21, 2020

Current plan:

  • implement both ECC (P-256) & RSA(2048 bit)
  • default to ECC but fallback to RSA if it's not supported by the browser
  • upgrade users to ECC if/when it becomes available
  • upgrade from NIST curves (P-256) to Ed25519 if/when it becomes available

@dholms dholms added documentation Improvements or additions to documentation and removed bug Something isn't working labels Feb 27, 2020
@dholms dholms added bug Something isn't working and removed documentation Improvements or additions to documentation labels Apr 6, 2020
@autonome
Copy link

autonome commented Oct 8, 2021

I updated the testcase on that Firefox issue to test storing ECDSA and ECDH keys in IndexedDB and it seems to work fine on both Firefox and Safari now.

https://bugzilla.mozilla.org/show_bug.cgi?id=1434898#c13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants