You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Unreviewed crypto verification for self
This commit is contained in:
@@ -77,25 +77,41 @@ export class ReciprocateQRCode extends Base {
|
|||||||
const masterKey = xsignInfo.getId("master");
|
const masterKey = xsignInfo.getId("master");
|
||||||
const masterKeyId = `ed25519:${masterKey}`;
|
const masterKeyId = `ed25519:${masterKey}`;
|
||||||
const keys = {[masterKeyId]: masterKey};
|
const keys = {[masterKeyId]: masterKey};
|
||||||
|
|
||||||
|
const devices = (await this._baseApis.getStoredDevicesForUser(this.userId)) || [];
|
||||||
|
const targetDevice = devices.find(d => d.deviceId === this.request.estimatedTargetDevice.deviceId);
|
||||||
|
if (!targetDevice) throw new Error("Device not found, somehow");
|
||||||
|
keys[`ed25519:${targetDevice.deviceId}`] = targetDevice.getFingerprint();
|
||||||
|
|
||||||
|
if (this.request.requestingUserId === this.request.receivingUserId) {
|
||||||
|
delete keys[masterKeyId];
|
||||||
|
}
|
||||||
|
|
||||||
await this._verifyKeys(this.userId, keys, (keyId, device, keyInfo) => {
|
await this._verifyKeys(this.userId, keys, (keyId, device, keyInfo) => {
|
||||||
if (keyInfo !== masterKey) {
|
const targetKey = keys[keyId];
|
||||||
|
if (!targetKey) throw newKeyMismatchError();
|
||||||
|
|
||||||
|
if (keyInfo !== targetKey) {
|
||||||
console.error("key ID from key info does not match");
|
console.error("key ID from key info does not match");
|
||||||
throw newKeyMismatchError();
|
throw newKeyMismatchError();
|
||||||
}
|
}
|
||||||
if (keyId !== masterKeyId) {
|
// if (keyId !== masterKeyId) {
|
||||||
console.error("key id doesn't match");
|
// console.error("key id doesn't match");
|
||||||
throw newKeyMismatchError();
|
// throw newKeyMismatchError();
|
||||||
}
|
// }
|
||||||
if (device.deviceId !== masterKey) {
|
// if (device.deviceId !== targetKey) {
|
||||||
console.error("master key does not match device ID");
|
// console.error("master key does not match device ID");
|
||||||
throw newKeyMismatchError();
|
// throw newKeyMismatchError();
|
||||||
}
|
// }
|
||||||
for (const deviceKeyId in device.keys) {
|
for (const deviceKeyId in device.keys) {
|
||||||
if (deviceKeyId !== masterKeyId) {
|
if (!deviceKeyId.startsWith("ed25519")) continue;
|
||||||
console.error("device key ID does not match");
|
const deviceTargetKey = keys[deviceKeyId];
|
||||||
throw newKeyMismatchError();
|
if (!deviceTargetKey) throw newKeyMismatchError();
|
||||||
}
|
// if (deviceKeyId !== masterKeyId) {
|
||||||
if (device.keys[deviceKeyId] !== masterKey) {
|
// console.error("device key ID does not match");
|
||||||
|
// throw newKeyMismatchError();
|
||||||
|
// }
|
||||||
|
if (device.keys[deviceKeyId] !== deviceTargetKey) {
|
||||||
console.error("master key does not match");
|
console.error("master key does not match");
|
||||||
throw newKeyMismatchError();
|
throw newKeyMismatchError();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user