1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00
This commit is contained in:
David Baker
2019-10-28 15:42:42 +00:00
parent 3bec28b2ff
commit de1b545df1
6 changed files with 27 additions and 17 deletions

View File

@@ -144,7 +144,9 @@ describe("Cross Signing", function() {
alice.uploadKeySignatures = expect.createSpy().andCall(async (content) => { alice.uploadKeySignatures = expect.createSpy().andCall(async (content) => {
await olmlib.verifySignature( await olmlib.verifySignature(
alice._crypto._olmDevice, alice._crypto._olmDevice,
content["@alice:example.com"]["nqOvzeuGWT/sRx3h7+MHoInYj3Uk2LD/unI9kDYcHwk"], content["@alice:example.com"][
"nqOvzeuGWT/sRx3h7+MHoInYj3Uk2LD/unI9kDYcHwk"
],
"@alice:example.com", "@alice:example.com",
"Osborne2", alice._crypto._olmDevice.deviceEd25519Key, "Osborne2", alice._crypto._olmDevice.deviceEd25519Key,
); );
@@ -694,7 +696,7 @@ describe("Cross Signing", function() {
it("should offer to upgrade device verifications to cross-signing", async function() { it("should offer to upgrade device verifications to cross-signing", async function() {
const alice = await makeTestClient( const alice = await makeTestClient(
{userId: "@alice:example.com", deviceId: "Osborne2"} {userId: "@alice:example.com", deviceId: "Osborne2"},
); );
const bob = await makeTestClient( const bob = await makeTestClient(
{userId: "@bob:example.com", deviceId: "Dynabook"}, {userId: "@bob:example.com", deviceId: "Dynabook"},
@@ -720,7 +722,7 @@ describe("Cross Signing", function() {
}, },
verified: 1, verified: 1,
known: true, known: true,
} },
}); });
alice._crypto._deviceList.storeCrossSigningForUser( alice._crypto._deviceList.storeCrossSigningForUser(
"@bob:example.com", "@bob:example.com",

View File

@@ -27,7 +27,6 @@ import olmlib from '../../../../lib/crypto/olmlib';
import sdk from '../../../..'; import sdk from '../../../..';
import {verificationMethods} from '../../../../lib/crypto'; import {verificationMethods} from '../../../../lib/crypto';
import DeviceInfo from '../../../../lib/crypto/deviceinfo';
import SAS from '../../../../lib/crypto/verification/SAS'; import SAS from '../../../../lib/crypto/verification/SAS';
@@ -109,12 +108,16 @@ describe("SAS verification", function() {
}, },
}; };
alice.client._crypto._deviceList.storeDevicesForUser("@bob:example.com", BOB_DEVICES); alice.client._crypto._deviceList.storeDevicesForUser(
"@bob:example.com", BOB_DEVICES,
);
alice.downloadKeys = () => { alice.downloadKeys = () => {
return Promise.resolve(); return Promise.resolve();
}; };
bob.client._crypto._deviceList.storeDevicesForUser("@alice:example.com", ALICE_DEVICES); bob.client._crypto._deviceList.storeDevicesForUser(
"@alice:example.com", ALICE_DEVICES,
);
bob.downloadKeys = () => { bob.downloadKeys = () => {
return Promise.resolve(); return Promise.resolve();
}; };
@@ -265,7 +268,9 @@ describe("SAS verification", function() {
it("should verify a cross-signing key", async function() { it("should verify a cross-signing key", async function() {
const privateKeys = {}; const privateKeys = {};
alice.httpBackend.when('POST', '/keys/device_signing/upload').respond(200, {}); alice.httpBackend.when('POST', '/keys/device_signing/upload').respond(
200, {},
);
alice.httpBackend.when('POST', '/keys/signatures/upload').respond(200, {}); alice.httpBackend.when('POST', '/keys/signatures/upload').respond(200, {});
alice.client.on("cross-signing.savePrivateKeys", function(e) { alice.client.on("cross-signing.savePrivateKeys", function(e) {
privateKeys.alice = e; privateKeys.alice = e;
@@ -288,9 +293,11 @@ describe("SAS verification", function() {
await bob.client.resetCrossSigningKeys(); await bob.client.resetCrossSigningKeys();
bob.client._crypto._deviceList.storeCrossSigningForUser("@alice:example.com", { bob.client._crypto._deviceList.storeCrossSigningForUser(
keys: alice.client._crypto._crossSigningInfo.keys, "@alice:example.com", {
}); keys: alice.client._crypto._crossSigningInfo.keys,
},
);
alice.httpBackend.when('POST', '/keys/query').respond(200, { alice.httpBackend.when('POST', '/keys/query').respond(200, {
failures: {}, failures: {},

View File

@@ -53,8 +53,6 @@ import { encodeRecoveryKey, decodeRecoveryKey } from './crypto/recoverykey';
import { keyForNewBackup, keyForExistingBackup } from './crypto/backup_password'; import { keyForNewBackup, keyForExistingBackup } from './crypto/backup_password';
import { randomString } from './randomstring'; import { randomString } from './randomstring';
import IndexedDBCryptoStore from './crypto/store/indexeddb-crypto-store';
// Disable warnings for now: we use deprecated bluebird functions // Disable warnings for now: we use deprecated bluebird functions
// and need to migrate, but they spam the console with warnings. // and need to migrate, but they spam the console with warnings.
Promise.config({warnings: false}); Promise.config({warnings: false});

View File

@@ -756,7 +756,7 @@ class DeviceListUpdateSerialiser {
downloadUsers, opts, downloadUsers, opts,
).then((res) => { ).then((res) => {
const dk = res.device_keys || {}; const dk = res.device_keys || {};
const master_keys = res.master_keys || {}; const masterKeys = res.masterKeys || {};
const ssks = res.self_signing_keys || {}; const ssks = res.self_signing_keys || {};
const usks = res.user_signing_keys || {}; const usks = res.user_signing_keys || {};
@@ -770,7 +770,7 @@ class DeviceListUpdateSerialiser {
prom = prom.delay(5).then(() => { prom = prom.delay(5).then(() => {
return this._processQueryResponseForUser( return this._processQueryResponseForUser(
userId, dk[userId], { userId, dk[userId], {
master: master_keys[userId], master: masterKeys[userId],
self_signing: ssks[userId], self_signing: ssks[userId],
user_signing: usks[userId], user_signing: usks[userId],
}, },

View File

@@ -19,7 +19,7 @@ import logger from '../logger';
import olmlib from './olmlib'; import olmlib from './olmlib';
import { randomString } from '../randomstring'; import { randomString } from '../randomstring';
import { keyForNewBackup } from './backup_password'; import { keyForNewBackup } from './backup_password';
import { encodeRecoveryKey, decodeRecoveryKey } from './recoverykey'; import { encodeRecoveryKey } from './recoverykey';
/** /**
* Implements secret storage and sharing (MSC-1946) * Implements secret storage and sharing (MSC-1946)

View File

@@ -104,7 +104,8 @@ const KEY_BACKUP_KEYS_PER_REQUEST = 200;
*/ */
export default function Crypto(baseApis, sessionStore, userId, deviceId, export default function Crypto(baseApis, sessionStore, userId, deviceId,
clientStore, cryptoStore, roomList, verificationMethods) { clientStore, cryptoStore, roomList, verificationMethods) {
this._onDeviceListUserCrossSigningUpdated = this._onDeviceListUserCrossSigningUpdated.bind(this); this._onDeviceListUserCrossSigningUpdated =
this._onDeviceListUserCrossSigningUpdated.bind(this);
this._reEmitter = new ReEmitter(this); this._reEmitter = new ReEmitter(this);
this._baseApis = baseApis; this._baseApis = baseApis;
@@ -147,7 +148,9 @@ export default function Crypto(baseApis, sessionStore, userId, deviceId,
); );
// XXX: This isn't removed at any point, but then none of the event listeners // XXX: This isn't removed at any point, but then none of the event listeners
// this class sets seem to be removed at any point... :/ // this class sets seem to be removed at any point... :/
this._deviceList.on('userCrossSigningUpdated', this._onDeviceListUserCrossSigningUpdated); this._deviceList.on(
'userCrossSigningUpdated', this._onDeviceListUserCrossSigningUpdated,
);
this._reEmitter.reEmit(this._deviceList, ["crypto.devicesUpdated"]); this._reEmitter.reEmit(this._deviceList, ["crypto.devicesUpdated"]);
// the last time we did a check for the number of one-time-keys on the // the last time we did a check for the number of one-time-keys on the