-
Notifications
You must be signed in to change notification settings - Fork 70
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
Pure JS Crypto Implementation #122
Comments
What is wrong with the current system that uses standard js crypto packages?
|
@turon : If I understand well lauckhart proposal:
An alternative would be to have the pure js implementation part of matter.js directly. This might add a bunch of extra dependencies that won't be needed for everyone. Probably splitting it into its own package is the best approach. @lauckhart : |
@turon -- @mfucci is correct, there's a brief discussion in Discord. I think your suggestion is actually pretty close to my preferred path -- shim for node's "crypto" module when necessary and otherwise leave our implementation as is for now. @mfucci -- I couldn't find anything more recent, no. Forge is somewhat less stale but doesn't support AES-CCM. I think Node adding their OpenSSL wrapper and development of WebCrypto may have killed interest in these slow JS libraries. For option 3 we could use e.g. WebCrypto for key generation (I haven't confirmed browser support is mature enough) and elliptic.js for EC signatures but unfortunately at least AES-CCM would still be a gap. Right now the immediate use case is getting Karma testing and for that I figure the easy path of shimming is OK. We could swap out as other use cases become clearer (to me, at least). Frankly I'd be hesitant to trust any of these libraries for real security, especially loaded from NPM. I figure prominent warnings in documentation and a WARN-level log message are warranted anytime matter.js falls back to crypto that isn't OpenSSL or WebCrypto. elliptic.js may be OK but I find it hard to trust crypto until there's at least one prominent CERT advisory. 🤔 |
Because I was kind ofg the initiator of the idea having a "Pure JS" implementation here also my POV: I also came more from the "it would be cool to have a pure JS implementation of crypto" in first place for testing to allow to have testing in matter.js really "complete" also in the matter.js package and not outside - andhave the same code tested in web and "node" tests for matter.js and not different. The side effect would be basic crypto support for limited platforms like low.js, but that was not my main goal here - but then the pure JS ones would be needed to be "good" security wise. but as said, not my main goal. I basically like the idea of an own package for that to keep the dependencies low, but I would leave the current deps and Crypto.ts in matter.js as "abstract core definition" and the other package is just providing the CryptoJs.ts as compatible interface. And matter.js just uses this then as "dev dep" for testing only :-) An alternative would be to directly implement a webcrypto based impleemntation that falls back to nodejs ones if existing - that would already solve the testing topic hopefully anddirectly bring the webcrypto one with it. Then we would have the main goals for matter.js fullfilled, but then special frameworks like low.js would still need own solutions (but in fact as said above that is a complete "out of scope side topic" and just beneficial. |
OK I researched best-available implementations for each feature. Google thinks I'm a bot now and regularly makes me select pictures of motorcycles. The following is a list by feature. I'd appreciate a sanity check from anyone with crypto expertise. The list below -- in theory -- supports Node, Karma, all modern browsers and react native (via plugins and shims, par for the course). low.js is an interesting case but ECs in V8 on an esp32 will be even more interesting. 😁 I'll try for a new package based on below and leave open the question of a.) additional shimming and b.) whether the current Node implementation is necessary.
|
Maybe we could poke the PR again to see if someone can take up. SOme other browserify packages were updated not too long ago, so basically there is activity From my first short look (yes, I'm far away from crypo expert) that looks ok. Thank you very much for your efforts here! |
Replace key handling with a JS implementation that converts keys to standard JWK Key format. Streamlines the Crypto.ts API and removes the various formats and hacks we previously used to pass keys to Node's OpenSSL wrapper. fixes project-chip#212 could be considered phase 1 of project-chip#122
Feedback appreciated!
Goals:
Proposal:
Option 1: Implement Crypto interface using SJCL
Pros
Cons
Option 2: Shim node's OpenSSL style wrappers
Pros
Cons
Option 3: Implement crypto using mix of 3rd party implementations
Pros
Cons
Option 4: New implementation of crypto primitives in matter-crypto.ts
Ha ha, j/k
The text was updated successfully, but these errors were encountered: