also send master key on verification and stuffs
This commit is contained in:
parent
80c7125d1d
commit
2ecf4151b9
|
@ -55,7 +55,9 @@ class CrossSigning {
|
||||||
signatures[key.userId] = <String, dynamic>{};
|
signatures[key.userId] = <String, dynamic>{};
|
||||||
}
|
}
|
||||||
if (!signatures[key.userId].containsKey(key.identifier)) {
|
if (!signatures[key.userId].containsKey(key.identifier)) {
|
||||||
signatures[key.userId][key.identifier] = key.toJson();
|
signatures[key.userId][key.identifier] =
|
||||||
|
Map<String, dynamic>.from(key.toJson());
|
||||||
|
signatures[key.userId][key.identifier].remove('signatures');
|
||||||
}
|
}
|
||||||
if (!signatures[key.userId][key.identifier].containsKey('signatures')) {
|
if (!signatures[key.userId][key.identifier].containsKey('signatures')) {
|
||||||
signatures[key.userId][key.identifier]
|
signatures[key.userId][key.identifier]
|
||||||
|
@ -79,18 +81,19 @@ class CrossSigning {
|
||||||
final signature = client.signString(key.signingContent);
|
final signature = client.signString(key.signingContent);
|
||||||
addSignature(
|
addSignature(
|
||||||
key,
|
key,
|
||||||
client.userDeviceKeys[client.userID].deviceKeys[client.deviceID],
|
client
|
||||||
|
.userDeviceKeys[client.userID].deviceKeys[client.deviceID],
|
||||||
signature);
|
signature);
|
||||||
}
|
}
|
||||||
// we don't care about signing other cross-signing keys
|
// we don't care about signing other cross-signing keys
|
||||||
} else if (key.identifier != client.deviceID) {
|
} else if (key.identifier != client.deviceID) {
|
||||||
// okay, we'll sign a device key with our self signing key
|
// okay, we'll sign a device key with our self signing key
|
||||||
selfSigningKey ??=
|
selfSigningKey ??= base64
|
||||||
base64.decode(await client.ssss.getCached(SELF_SIGNING_KEY) ?? '');
|
.decode(await client.ssss.getCached(SELF_SIGNING_KEY) ?? '');
|
||||||
if (selfSigningKey != null) {
|
if (selfSigningKey != null) {
|
||||||
final signature = _sign(key.signingContent, selfSigningKey);
|
final signature = _sign(key.signingContent, selfSigningKey);
|
||||||
addSignature(key, client.userDeviceKeys[client.userID].selfSigningKey,
|
addSignature(key,
|
||||||
signature);
|
client.userDeviceKeys[client.userID].selfSigningKey, signature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (key is CrossSigningKey && key.usage.contains('master')) {
|
} else if (key is CrossSigningKey && key.usage.contains('master')) {
|
||||||
|
@ -99,8 +102,8 @@ class CrossSigning {
|
||||||
base64.decode(await client.ssss.getCached(USER_SIGNING_KEY) ?? '');
|
base64.decode(await client.ssss.getCached(USER_SIGNING_KEY) ?? '');
|
||||||
if (userSigningKey != null) {
|
if (userSigningKey != null) {
|
||||||
final signature = _sign(key.signingContent, userSigningKey);
|
final signature = _sign(key.signingContent, userSigningKey);
|
||||||
addSignature(
|
addSignature(key, client.userDeviceKeys[client.userID].userSigningKey,
|
||||||
key, client.userDeviceKeys[client.userID].userSigningKey, signature);
|
signature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,8 +362,8 @@ class KeyVerification {
|
||||||
if (verifiedMasterKey && userId == client.userID) {
|
if (verifiedMasterKey && userId == client.userID) {
|
||||||
// it was our own master key, let's request the cross signing keys
|
// it was our own master key, let's request the cross signing keys
|
||||||
// we do it in the background, thus no await needed here
|
// we do it in the background, thus no await needed here
|
||||||
unawaited(client.ssss.maybeRequestAll(
|
unawaited(client.ssss
|
||||||
_verifiedDevices.whereType<DeviceKeys>().toList()));
|
.maybeRequestAll(_verifiedDevices.whereType<DeviceKeys>().toList()));
|
||||||
}
|
}
|
||||||
await send('m.key.verification.done', {});
|
await send('m.key.verification.done', {});
|
||||||
|
|
||||||
|
@ -727,6 +727,17 @@ class _KeyVerificationMethodSas extends _KeyVerificationMethod {
|
||||||
_calculateMac(client.fingerprintKey, baseInfo + deviceKeyId);
|
_calculateMac(client.fingerprintKey, baseInfo + deviceKeyId);
|
||||||
keyList.add(deviceKeyId);
|
keyList.add(deviceKeyId);
|
||||||
|
|
||||||
|
final masterKey = client.userDeviceKeys.containsKey(client.userID)
|
||||||
|
? client.userDeviceKeys[client.userID].masterKey
|
||||||
|
: null;
|
||||||
|
if (masterKey != null && masterKey.verified) {
|
||||||
|
// we have our own master key verified, let's send it!
|
||||||
|
final masterKeyId = 'ed25519:${masterKey.publicKey}';
|
||||||
|
mac[masterKeyId] =
|
||||||
|
_calculateMac(masterKey.publicKey, baseInfo + masterKeyId);
|
||||||
|
keyList.add(masterKeyId);
|
||||||
|
}
|
||||||
|
|
||||||
keyList.sort();
|
keyList.sort();
|
||||||
final keys = _calculateMac(keyList.join(','), baseInfo + 'KEY_IDS');
|
final keys = _calculateMac(keyList.join(','), baseInfo + 'KEY_IDS');
|
||||||
await request.send('m.key.verification.mac', {
|
await request.send('m.key.verification.mac', {
|
||||||
|
|
Loading…
Reference in a new issue