feat: Guard against malformed ciphertext

This commit is contained in:
2023-06-15 16:42:17 +02:00
parent f1ec8d1793
commit 6c301ab88f
5 changed files with 42 additions and 30 deletions

View File

@@ -152,14 +152,20 @@ class OmemoManager {
return Result(InvalidMessageHMACError());
}
// TODO: Handle an exception from the crypto implementation
final result = await aes256CbcDecrypt(
ciphertext,
derivedKeys.encryptionKey,
derivedKeys.iv,
);
if (result.isType<MalformedCiphertextError>()) {
return Result(
result.get<MalformedCiphertextError>(),
);
}
return Result(
utf8.decode(
await aes256CbcDecrypt(
ciphertext,
derivedKeys.encryptionKey,
derivedKeys.iv,
),
result.get<List<int>>(),
),
);
}
@@ -316,8 +322,6 @@ class OmemoManager {
kexMessage.ek,
KeyPairType.x25519,
);
// TODO: Guard against invalid signatures
final kex = await x3dhFromInitialMessage(
X3DHMessage(
kexIk,