Bug 1433003 - Optimize sync by using digestBytes instead of digestUTF8. r=markh

MozReview-Commit-ID: IbyeOUjKdi9

--HG--
extra : rebase_source : 3eb55106004ef68f749a9188f232dbb60f9d1e3d
This commit is contained in:
Thom Chiovoloni 2018-01-24 20:09:16 -05:00
parent 52f4c19c6b
commit fca1cd0193
2 changed files with 5 additions and 2 deletions

View File

@ -56,7 +56,10 @@ this.CryptoUtils = {
*/
digestBytes: function digestBytes(message, hasher) {
// No UTF-8 encoding for you, sunshine.
let bytes = Array.prototype.slice.call(message).map(b => b.charCodeAt(0));
let bytes = new Uint8Array(message.length);
for (let i = 0; i < message.length; ++i) {
bytes[i] = message.charCodeAt(i) & 0xff;
}
hasher.update(bytes, bytes.length);
let result = hasher.finish(false);
if (hasher instanceof Ci.nsICryptoHMAC) {

View File

@ -124,7 +124,7 @@ CryptoWrapper.prototype = {
throw new Error("Cannot compute HMAC without an HMAC key.");
}
return CommonUtils.bytesAsHex(Utils.digestUTF8(this.ciphertext, hasher));
return CommonUtils.bytesAsHex(Utils.digestBytes(this.ciphertext, hasher));
},
/*