archiveSessionOnMatch: Check for ratchet key match as well

This commit is contained in:
Scott Nonnenberg 2021-07-23 10:44:21 -07:00 committed by GitHub
parent fdec47d637
commit b0eaae93f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View File

@ -1926,6 +1926,7 @@ class MessageReceiverInner extends EventTarget {
groupId: envelope.groupId,
requesterDevice: sourceDevice,
requesterUuid: sourceUuid,
ratchetKey: request.ratchetKey(),
senderDevice: request.deviceId(),
sentAt: request.timestamp(),
});

View File

@ -2,6 +2,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable max-classes-per-file */
import { PublicKey } from '@signalapp/signal-client';
import { SignalService as Proto } from '../protobuf';
import { ProcessedDataMessage, ProcessedSent } from './Types.d';
import type {
@ -92,6 +94,7 @@ export class DecryptionErrorEvent extends Event {
export type RetryRequestEventData = Readonly<{
groupId?: string;
ratchetKey?: PublicKey;
requesterUuid: string;
requesterDevice: number;
senderDevice: number;

View File

@ -158,6 +158,7 @@ export async function onDecryptionError(
// Helpers
async function archiveSessionOnMatch({
ratchetKey,
requesterUuid,
requesterDevice,
senderDevice,
@ -166,9 +167,17 @@ async function archiveSessionOnMatch({
window.textsecure.storage.user.getDeviceId(),
'archiveSessionOnMatch/getDeviceId'
);
if (ourDeviceId === senderDevice) {
const address = `${requesterUuid}.${requesterDevice}`;
window.log.info('archiveSessionOnMatch: Devices match, archiving session');
if (ourDeviceId !== senderDevice || !ratchetKey) {
return;
}
const address = `${requesterUuid}.${requesterDevice}`;
const session = await window.textsecure.storage.protocol.loadSession(address);
if (session && session.currentRatchetKeyMatches(ratchetKey)) {
window.log.info(
'archiveSessionOnMatch: Matching device and ratchetKey, archiving session'
);
await window.textsecure.storage.protocol.archiveSession(address);
}
}
@ -200,7 +209,7 @@ async function sendDistributionMessageOrNullMessage(
if (group && distributionId) {
window.log.info(
`sendDistributionMessageOrNullMessage/${logId}: Found matching group, sending sender key distribution message'`
`sendDistributionMessageOrNullMessage/${logId}: Found matching group, sending sender key distribution message`
);
try {