chore: More try catch in bootstrap

This commit is contained in:
Christian Pauly 2021-01-29 11:18:18 +01:00
parent a6ee805367
commit ad39e3af25
1 changed files with 117 additions and 111 deletions

View File

@ -205,8 +205,14 @@ class Bootstrap {
throw BootstrapBadStateException('Wrong State');
}
if (use) {
try {
newSsssKey = encryption.ssss.open(encryption.ssss.defaultKeyId);
state = BootstrapState.openExistingSsss;
} catch (e, s) {
Logs().e('[Bootstrapping] Error open SSSS', e, s);
state = BootstrapState.error;
return;
}
} else if (badSecrets().isNotEmpty) {
state = BootstrapState.askBadSsss;
} else {
@ -233,9 +239,8 @@ class Bootstrap {
for (final key in keys) {
oldSsssKeys[key] = encryption.ssss.open(key);
}
} catch (e) {
// very bad
Logs().e('[Bootstrapping] Error construction ssss key', e);
} catch (e, s) {
Logs().e('[Bootstrapping] Error construction ssss key', e, s);
state = BootstrapState.error;
return;
}
@ -346,6 +351,7 @@ class Bootstrap {
checkOnlineKeyBackup();
return;
}
try {
Uint8List masterSigningKey;
final secretsToStore = <String, String>{};
MatrixCrossSigningKey masterKey;
@ -388,7 +394,8 @@ class Bootstrap {
final keyObj = olm.PkSigning();
try {
keyObj.init_with_seed(masterSigningKey);
return keyObj.sign(String.fromCharCodes(canonicalJson.encode(object)));
return keyObj
.sign(String.fromCharCodes(canonicalJson.encode(object)));
} finally {
keyObj.free();
}
@ -443,7 +450,6 @@ class Bootstrap {
userSigning.free();
}
}
try {
// upload the keys!
state = BootstrapState.loading;
await client.uiaRequestBackground(
@ -533,6 +539,7 @@ class Bootstrap {
state = BootstrapState.done;
return;
}
try {
final keyObj = olm.PkDecryption();
String pubKey;
Uint8List privKey;
@ -542,7 +549,6 @@ class Bootstrap {
} finally {
keyObj.free();
}
try {
// create the new backup version
await client.createRoomKeysBackup(
RoomKeysAlgorithmType.v1Curve25519AesSha2,