Fix up array buffer comparison

Well that didn't work. Luckily this comparison is primarily enforced at
the libaxolotl level.

With this and the corresponding change to libaxolotl, remote identity
keys are always going to be stored as array buffers going forward. This
will cause incompatibility with existing keys stored as strings, so
updating to this point requires you to purge your identity key and
session store.
This commit is contained in:
lilia 2015-07-15 13:24:50 -07:00
parent 853b578551
commit 1f8040998f

View file

@ -56,13 +56,16 @@
} }
function equalArrayBuffers(ab1, ab2) { function equalArrayBuffers(ab1, ab2) {
if (ab1.bytelength !== ab2.bytelength) { if (!(ab1 instanceof ArrayBuffer && ab2 instanceof ArrayBuffer)) {
return false;
}
if (ab1.byteLength !== ab2.byteLength) {
return false; return false;
} }
var result = true; var result = true;
var ta1 = new Uint8Array(ab1); var ta1 = new Uint8Array(ab1);
var ta2 = new Uint8Array(ab2); var ta2 = new Uint8Array(ab2);
for (var i = 0; i < ab1.bytelength; ++i) { for (var i = 0; i < ab1.byteLength; ++i) {
if (ta1[i] !== ta2[i]) { result = false; } if (ta1[i] !== ta2[i]) { result = false; }
} }
return result; return result;