diff --git a/js/crypto.js b/js/crypto.js index 6f94bc1f..2dfea2b8 100644 --- a/js/crypto.js +++ b/js/crypto.js @@ -359,7 +359,7 @@ window.crypto = (function() { var initSessionFromPreKeyWhisperMessage = function(encodedNumber, message) { var preKeyPair = crypto_storage.getAndRemovePreKeyPair(message.preKeyId); - if (message.registrationId != storage.getUnencrypted("registrationId)) + if (message.registrationId != storage.getUnencrypted("registrationId")) throw new Error("Got a message encrypted for a different registration"); var session = crypto_storage.getSessionOrIdentityKeyByBaseKey(encodedNumber, toArrayBuffer(message.baseKey)); diff --git a/js/test.js b/js/test.js index a67efe0d..c23aa1ee 100644 --- a/js/test.js +++ b/js/test.js @@ -220,7 +220,7 @@ registerOnLoadFunction(function() { ourIdentityKey: hexToArrayBuffer('a05fd14abb42ff393004eee526e3167441ee51021c6d801b784720c15637747c'), theirPreKey: hexToArrayBuffer('05fee424a5b6ccb717d85ef2207e2057ab1144c40afe89cdc80e9c424dd90c146e'), theirPreKeyId: 13845842, - theirRegistrationId: 11593,//TODO: Figure out wtf this is for + theirRegistrationId: 11593, theirIdentityKey: hexToArrayBuffer('05276e4df34557386f67df38b708eeddb1a8924e0428b9eefdc9213c3e8927cc7d'), //expectedPlaintext: hexToArrayBuffer('0a0e4120202020202020202020202020'), //expectedCounter: 0, @@ -264,6 +264,7 @@ registerOnLoadFunction(function() { type: 3, ourPreKey: hexToArrayBuffer('799706c9a19c663b6970690beccb5ffdc55b9f592f1dcbcd954f3662842c076b'), preKeyId: 13845842, + registrationId: 11593, ourIdentityKey: hexToArrayBuffer('5024f863ed4a17505a5588cb464aa3cb349201f786e6f871a22cbed1ea6dd97c'), newEphemeralKey: hexToArrayBuffer('d1d52b5a4403c32e81bc242b10502ad222ed47af16ba6548496217416c934252'), //expectedPlaintext: hexToArrayBuffer(''), @@ -355,6 +356,7 @@ registerOnLoadFunction(function() { storage.putEncrypted("25519KeyidentityKey", keyPair); return crypto_tests.privToPub(data.ourPreKey, false).then(function(keyPair) { storage.putEncrypted("25519KeypreKey" + data.preKeyId, keyPair); + storage.putUnencrypted("registrationId", data.registrationId); return postLocalKeySetup(); }); }); @@ -440,6 +442,7 @@ registerOnLoadFunction(function() { v[0][1] = { message: orig[1][1].message, type: orig[1][1].type, expectedSmsText: orig[1][1].expectedSmsText }; v[0][1].ourPreKey = orig[0][1].ourPreKey; v[0][1].preKeyId = orig[0][1].preKeyId; + v[0][1].registrationId = orig[0][1].registrationId; v[0][1].ourIdentityKey = orig[0][1].ourIdentityKey; v[0][1].newEphemeralKey = orig[0][1].newEphemeralKey; @@ -498,6 +501,7 @@ registerOnLoadFunction(function() { v[0][1] = { message: orig[1][1].message, type: orig[1][1].type, expectedSmsText: orig[1][1].expectedSmsText }; v[0][1].ourPreKey = orig[0][1].ourPreKey; v[0][1].preKeyId = orig[0][1].preKeyId; + v[0][1].registrationId = orig[0][1].registrationId; v[0][1].ourIdentityKey = orig[0][1].ourIdentityKey; v[0][1].newEphemeralKey = orig[0][1].newEphemeralKey;