decryptFromSignalWithCallback method
Future<Uint8List>
decryptFromSignalWithCallback(
- SignalMessage cipherText,
- DecryptionCallback? callback
Implementation
Future<Uint8List> decryptFromSignalWithCallback(
SignalMessage cipherText, DecryptionCallback? callback) async {
if (!await _sessionStore.containsSession(_remoteAddress)) {
throw NoSessionException('No session for: $_remoteAddress');
}
final sessionRecord = await _sessionStore.loadSession(_remoteAddress);
final plaintext = _decrypt(sessionRecord, cipherText);
if (!await _identityKeyStore.isTrustedIdentity(
_remoteAddress,
sessionRecord.sessionState.getRemoteIdentityKey(),
Direction.receiving)) {
throw UntrustedIdentityException(_remoteAddress.getName(),
sessionRecord.sessionState.getRemoteIdentityKey());
}
await _identityKeyStore.saveIdentity(
_remoteAddress, sessionRecord.sessionState.getRemoteIdentityKey());
if (callback != null) {
callback(plaintext);
}
await _sessionStore.storeSession(_remoteAddress, sessionRecord);
return plaintext;
}