Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

fix: deriveKey in webkit linux (workaround) #313

Merged
merged 12 commits into from Apr 4, 2023

Conversation

MarcoPolo
Copy link
Contributor

After some painful debugging (see: libp2p/js-libp2p#1627 (comment)) I've found out why js-libp2p fails on webkit in Linux. The subtlecrypto implementation doesn't like to derive a key from an empty imported key. This works on all other browsers, so it seems like the webkit implementation is doing the wrong thing. Maybe worth opening a bug and writing a test for them. In the mean time here's a workaround.

This unblocks webkit testing in the interop tester (which runs on linux). This also lets folks use js-libp2p from webkit based linux browsers, although it doesn't seem like anyone else ran into this issue.

@MarcoPolo
Copy link
Contributor Author

Nice. This surfaced a proper error in macos webkit. Surprisingly, that test passes in linux webkit.

@MarcoPolo
Copy link
Contributor Author

Per sync discussion:

A better fix will be to use a static key that is generated from a working implementation when the password is "". When the password is "" we know what the derived password is, so we can fill it in with a constant. This works around the issue in webkit linux by not having it try to generate that constant which fill fail.

Copy link
Member

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple of nits for the types.

src/ciphers/aes-gcm.browser.ts Outdated Show resolved Hide resolved
src/ciphers/aes-gcm.browser.ts Outdated Show resolved Hide resolved
@achingbrain achingbrain merged commit 4905944 into master Apr 4, 2023
18 checks passed
@achingbrain achingbrain deleted the marco/fix-webkit-linux branch April 4, 2023 13:26
github-actions bot pushed a commit that referenced this pull request Apr 4, 2023
## [1.0.15](v1.0.14...v1.0.15) (2023-04-04)

### Bug Fixes

* deriveKey in webkit linux (workaround) ([#313](#313)) ([4905944](4905944))
@github-actions
Copy link

github-actions bot commented Apr 4, 2023

🎉 This PR is included in version 1.0.15 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

2 participants