Closed
Bug 1091005
Opened 11 years ago
Closed 11 years ago
[FxOS] Loop/Hello uses SJCL when it could use WebCrypto instead
Categories
(Firefox OS Graveyard :: Gaia::Loop, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: freddy, Assigned: amac)
References
Details
(Keywords: sec-low, wsec-crypto)
Attachments
(1 file)
67 bytes,
patch
|
crdlc
:
review+
freddy
:
feedback+
|
Details | Diff | Splinter Review |
It is safer to use built-in WebAPIs for cryptography than those implemented in JavaScript. One argument would be side-channels for cryptography.
Here's a list of how things can be replaced:
* sjlc.misc.hmac with WebCrypto HMAC
* sjlc.codec.* and sjlc.bitArray* with the Encoding API, i.e. https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API
Feel free to reach out to me if you have questions about the specifics. No need to block release (end of the week?) for this, but surely something to take into account for future versions.
AFAIU the only usage of SJCL is in token.js (e.g.: https://github.com/mozilla-b2g/firefoxos-loop-client/blob/f83a3c5aa90c0f78a8047c7efadace01ad01325b/app/libs/token.js)
Reporter | ||
Comment 1•11 years ago
|
||
It seems the default CCs for Loop are currently not doing triage. Maria, can you take a look at this bug?
Comment 2•11 years ago
|
||
Sure, first setting ni to Antonio (who is the expert one in these issues) and can provide more detail
Flags: needinfo?(amac.bug)
Assignee | ||
Comment 3•11 years ago
|
||
Well, we have two problems with this (or maybe three):
* HKDF [1] doesn't seem to be implemented in Firefox's Webcrypto currently. Once that's implemented, this should be direct.
* My initial implementation of this using HMAC.sign doesn't work, unsurprisingly
* And dom.webcrypto.enabled is falsein B2G32 (and this has to run in 2.0).
The first two problems might be solvable (by more work) but sadly the third one isn't. So at this point I would say this is a wont fix (at least not for this version).
[1] https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#hkdf-ctr
Flags: needinfo?(amac.bug)
Assignee | ||
Comment 4•11 years ago
|
||
Just out of curiosity, I finished my initial version of this. It's available at:
https://github.com/AntonioMA/firefoxos-loop-client/blob/webcrypto-version/app/libs/token_wc.js
in case you want to take a look, Frederik.
I found something that I believe is a bug on webcrypto (an empty array as raw key gives an exception when according to FIPS-198-1, Section 4, step 3 it should expand it to an array of B 0's. In any case, this version gives the same results as the SJCL based one.
But as I said on my previous comments, I don't think we're going to land this on Loop for the time being, since it has to work on 2.0 and there Webcrypto is disabled.
Flags: needinfo?(fbraun)
Reporter | ||
Comment 5•11 years ago
|
||
I wasn't aware of the limitation to make it work on 2.0 - sorry about the overhead I caused.
Code looks good, but I'd give it a more detailed review if this has any chance of landing.
Flags: needinfo?(fbraun)
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → amac.bug
Assignee | ||
Comment 6•11 years ago
|
||
Note that after fixing this we should also fix hawk.js, which has CryptoJS embedded!
Attachment #8537189 -
Flags: review?(josea.olivera)
Attachment #8537189 -
Flags: review?(fbraun)
Reporter | ||
Comment 7•11 years ago
|
||
Comment on attachment 8537189 [details] [diff] [review]
Detect and use Webcrypto if available
Giving f+, since I'm formally not entitled to r+ code that I'm neither peer or module owner of :)
Attachment #8537189 -
Flags: review?(fbraun) → feedback+
Comment 8•11 years ago
|
||
Comment on attachment 8537189 [details] [diff] [review]
Detect and use Webcrypto if available
Good job as usual. Left some comments but nothing blocking. Thanks Antonio
Attachment #8537189 -
Flags: review?(josea.olivera) → review+
Assignee | ||
Comment 9•11 years ago
|
||
Comment on attachment 8537189 [details] [diff] [review]
Detect and use Webcrypto if available
I'm re-requesting review because I added a new unit test (to check the signUp function since I rewrote it again).
Attachment #8537189 -
Flags: review+ → review?(crdlc)
Comment 10•11 years ago
|
||
Comment on attachment 8537189 [details] [diff] [review]
Detect and use Webcrypto if available
LGTM, thanks Antonio
Attachment #8537189 -
Flags: review?(crdlc) → review+
Comment 11•11 years ago
|
||
in master:
https://github.com/mozilla-b2g/firefoxos-loop-client/commit/23110d0016d4199e78630a70178f6e8010d941e9
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•