fix: Fixed dysfunctional key-verification (Emoji+manual)

- added snippet from Nico in matrix_keys.dart
Fixes #24
This commit is contained in:
Malin Errenst 2022-08-25 17:55:14 +02:00
parent f2ab312091
commit ea93867b94
3 changed files with 25 additions and 8 deletions

2
.gitignore vendored
View File

@ -2,7 +2,7 @@
*.class
*.log
*.pyc
*.swp
*.sw*
.DS_Store
.atom/
.buildlog/

View File

@ -42,8 +42,25 @@ abstract class MatrixSignableKey {
userId = json['user_id'] as String,
keys = Map<String, String>.from(json['keys'] as Map<String, dynamic>),
// we need to manually copy to ensure that our map is Map<String, Map<String, String>>
signatures = json.tryGetMap<String, Map<String, String>>('signatures'),
unsigned = json.tryGetMap<String, dynamic>('unsigned');
signatures = (() {
final orig = json.tryGetMap<String, dynamic>('signatures');
final res = <String, Map<String, String>>{};
for (final entry
in (orig?.entries ?? <MapEntry<String, dynamic>>[])) {
final deviceSigs = entry.value;
if (deviceSigs is Map<String, dynamic>) {
for (final nestedEntry in deviceSigs.entries) {
final nestedValue = nestedEntry.value;
if (nestedValue is String) {
(res[entry.key] ??= <String, String>{})[nestedEntry.key] =
nestedValue;
}
}
}
}
return res;
}()),
unsigned = json.tryGetMap<String, dynamic>('unsigned')?.copy();
Map<String, dynamic> toJson() {
final data = _json ?? <String, dynamic>{};

View File

@ -1197,7 +1197,7 @@ void main() {
'ed25519:82mAXjsmbTbrE6zyShpR869jnrANO75H8nYY0nDLoJ8':
'82mAXjsmbTbrE6zyShpR869jnrANO75H8nYY0nDLoJ8',
},
'signatures': <String, dynamic>{},
'signatures': <String, Map<String, String>>{},
});
final selfSigningKey = MatrixCrossSigningKey.fromJson({
'user_id': '@test:fakeServer.notExisting',
@ -1206,7 +1206,7 @@ void main() {
'ed25519:F9ypFzgbISXCzxQhhSnXMkc1vq12Luna3Nw5rqViOJY':
'F9ypFzgbISXCzxQhhSnXMkc1vq12Luna3Nw5rqViOJY',
},
'signatures': <String, dynamic>{},
'signatures': <String, Map<String, String>>{},
});
final userSigningKey = MatrixCrossSigningKey.fromJson({
'user_id': '@test:fakeServer.notExisting',
@ -1215,7 +1215,7 @@ void main() {
'ed25519:0PiwulzJ/RU86LlzSSZ8St80HUMN3dqjKa/orIJoA0g':
'0PiwulzJ/RU86LlzSSZ8St80HUMN3dqjKa/orIJoA0g',
},
'signatures': <String, dynamic>{},
'signatures': <String, Map<String, String>>{},
});
await matrixApi.uploadCrossSigningKeys(
masterKey: masterKey,
@ -1638,7 +1638,7 @@ void main() {
final algorithm = BackupAlgorithm.mMegolmBackupV1Curve25519AesSha2;
final authData = <String, dynamic>{
'public_key': 'GXYaxqhNhUK28zUdxOmEsFRguz+PzBsDlTLlF0O0RkM',
'signatures': <String, dynamic>{},
'signatures': <String, Map<String, String>>{},
};
final ret = await matrixApi.postRoomKeysVersion(algorithm, authData);
expect(
@ -1663,7 +1663,7 @@ void main() {
final algorithm = BackupAlgorithm.mMegolmBackupV1Curve25519AesSha2;
final authData = <String, dynamic>{
'public_key': 'GXYaxqhNhUK28zUdxOmEsFRguz+PzBsDlTLlF0O0RkM',
'signatures': <String, dynamic>{},
'signatures': <String, Map<String, String>>{},
};
await matrixApi.putRoomKeysVersion('5', algorithm, authData);
});