mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Implement simple handling of incoming decryption error message
This commit is contained in:
parent
1f48ce1f39
commit
baed2b7ead
4 changed files with 29 additions and 3 deletions
|
@ -233,6 +233,16 @@ public final class IncomingMessageHandler {
|
||||||
if (content.getDecryptionErrorMessage().isPresent()) {
|
if (content.getDecryptionErrorMessage().isPresent()) {
|
||||||
var message = content.getDecryptionErrorMessage().get();
|
var message = content.getDecryptionErrorMessage().get();
|
||||||
logger.debug("Received a decryption error message (resend request for {})", message.getTimestamp());
|
logger.debug("Received a decryption error message (resend request for {})", message.getTimestamp());
|
||||||
|
if (message.getRatchetKey().isPresent()) {
|
||||||
|
if (message.getDeviceId() == account.getDeviceId() && account.getSessionStore()
|
||||||
|
.isCurrentRatchetKey(sender, senderDeviceId, message.getRatchetKey().get())) {
|
||||||
|
logger.debug("Renewing the session with sender");
|
||||||
|
actions.add(new RenewSessionAction(sender));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.debug("Reset shared sender keys with this recipient");
|
||||||
|
account.getSenderKeyStore().deleteSharedWith(sender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (content.getDataMessage().isPresent()) {
|
if (content.getDataMessage().isPresent()) {
|
||||||
|
|
|
@ -75,7 +75,9 @@ public class SenderKeyRecordStore implements org.whispersystems.libsignal.groups
|
||||||
cachedSenderKeys.clear();
|
cachedSenderKeys.clear();
|
||||||
final var keys = getKeysLocked(recipientId);
|
final var keys = getKeysLocked(recipientId);
|
||||||
for (var key : keys) {
|
for (var key : keys) {
|
||||||
if (key.distributionId.equals(distributionId)) deleteSenderKeyLocked(key);
|
if (key.distributionId.equals(distributionId)) {
|
||||||
|
deleteSenderKeyLocked(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,8 +163,9 @@ public class SenderKeySharedStore {
|
||||||
|
|
||||||
public void deleteAllFor(final DistributionId distributionId) {
|
public void deleteAllFor(final DistributionId distributionId) {
|
||||||
synchronized (sharedSenderKeys) {
|
synchronized (sharedSenderKeys) {
|
||||||
sharedSenderKeys.remove(distributionId.asUuid());
|
if (sharedSenderKeys.remove(distributionId.asUuid()) != null) {
|
||||||
saveLocked();
|
saveLocked();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.whispersystems.libsignal.NoSessionException;
|
import org.whispersystems.libsignal.NoSessionException;
|
||||||
import org.whispersystems.libsignal.SignalProtocolAddress;
|
import org.whispersystems.libsignal.SignalProtocolAddress;
|
||||||
|
import org.whispersystems.libsignal.ecc.ECPublicKey;
|
||||||
import org.whispersystems.libsignal.protocol.CiphertextMessage;
|
import org.whispersystems.libsignal.protocol.CiphertextMessage;
|
||||||
import org.whispersystems.libsignal.state.SessionRecord;
|
import org.whispersystems.libsignal.state.SessionRecord;
|
||||||
import org.whispersystems.signalservice.api.SignalServiceSessionStore;
|
import org.whispersystems.signalservice.api.SignalServiceSessionStore;
|
||||||
|
@ -91,6 +92,18 @@ public class SessionStore implements SignalServiceSessionStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCurrentRatchetKey(RecipientId recipientId, int deviceId, ECPublicKey ratchetKey) {
|
||||||
|
final var key = new Key(recipientId, deviceId);
|
||||||
|
|
||||||
|
synchronized (cachedSessions) {
|
||||||
|
final var session = loadSessionLocked(key);
|
||||||
|
if (session == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return session.currentRatchetKeyMatches(ratchetKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeSession(SignalProtocolAddress address, SessionRecord session) {
|
public void storeSession(SignalProtocolAddress address, SessionRecord session) {
|
||||||
final var key = getKey(address);
|
final var key = getKey(address);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue