mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 14:25:52 +00:00
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:
parent
52f4c19c6b
commit
fca1cd0193
@ -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) {
|
||||
|
@ -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));
|
||||
},
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user