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