2015-09-07 23:53:43 +02:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
2015-07-22 21:48:08 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2016-04-28 00:54:31 +02:00
|
|
|
describe('Protocol Wrapper', function() {
|
2016-04-22 22:39:05 +02:00
|
|
|
var store = textsecure.storage.protocol;
|
2015-07-22 21:48:08 +02:00
|
|
|
var identifier = '+5558675309';
|
|
|
|
var another_identifier = '+5555590210';
|
2016-04-28 00:21:44 +02:00
|
|
|
var prekeys, identityKey, testKey;
|
|
|
|
this.timeout(5000);
|
|
|
|
before(function(done) {
|
|
|
|
localStorage.clear();
|
2016-04-29 00:07:34 +02:00
|
|
|
libsignal.KeyHelper.generateIdentityKeyPair().then(function(identityKey) {
|
2016-05-03 23:54:57 +02:00
|
|
|
return textsecure.storage.protocol.saveIdentity(identifier, identityKey);
|
2016-04-28 00:21:44 +02:00
|
|
|
}).then(done);
|
|
|
|
});
|
2016-04-28 00:54:31 +02:00
|
|
|
describe('processPreKey', function() {
|
2015-07-22 21:48:08 +02:00
|
|
|
it('rejects if the identity key changes', function(done) {
|
2016-05-01 23:46:16 +02:00
|
|
|
var address = new libsignal.SignalProtocolAddress(identifier, 1);
|
|
|
|
var builder = new libsignal.SessionBuilder(store, address);
|
|
|
|
return builder.processPreKey({
|
2016-04-28 00:21:44 +02:00
|
|
|
identityKey: textsecure.crypto.getRandomBytes(33),
|
2016-05-01 23:46:16 +02:00
|
|
|
encodedNumber: address.toString()
|
2015-07-22 21:48:08 +02:00
|
|
|
}).then(function() {
|
2016-04-28 00:21:44 +02:00
|
|
|
done(new Error('Allowed to overwrite identity key'));
|
|
|
|
}).catch(function(e) {
|
|
|
|
assert.strictEqual(e.message, 'Identity key changed');
|
|
|
|
done();
|
2015-07-22 21:48:08 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|