[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-bugs] #5894 [EFF-HTTPS Everywhere]: Replace sha256.js and base64_encode() with Mozilla's internal equivalents
#5894: Replace sha256.js and base64_encode() with Mozilla's internal equivalents
----------------------------------+-----------------------------------------
Reporter: gk | Owner: pde
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: EFF-HTTPS Everywhere | Version:
Keywords: | Parent:
Points: | Actualpoints:
----------------------------------+-----------------------------------------
To reduce code bloat and avoid JavaScript's bit shifting inefficiencies it
would be good to replace sha256.js and base64_encode() in ssl-
observatory.js with functionality provided by Mozilla itself. The former
is quite easy using nsICryptoHash (see the the example "Computing the Hash
of a String" on
https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsICryptoHash).
The latter is not working directly using btoa(). The reason is that
|derData| is an array but btoa() needs a string as argument. But one can
construct a string out of the array and use that in turn as input. The
relevant code snipped would be something like
{{{
let result = "";
for (let j = 0, dataLength = derData.length; j < dataLength; ++j) {
result += String.fromCharCode(derData[j]);
}
base64Certs.push(btoa(result));
}}}
I have implemented both approaches in JonDoFox and they work as expected.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/5894>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs