Sender Key: Flags to disable, send to unrestricted

This commit is contained in:
Scott Nonnenberg 2021-08-03 18:02:35 -07:00 committed by GitHub
parent d5810d6bac
commit f048066693
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 7 deletions

View file

@ -11,13 +11,14 @@ export type ConfigKeyType =
| 'desktop.disableGV1' | 'desktop.disableGV1'
| 'desktop.groupCalling' | 'desktop.groupCalling'
| 'desktop.gv2' | 'desktop.gv2'
| 'desktop.internalUser'
| 'desktop.mandatoryProfileSharing' | 'desktop.mandatoryProfileSharing'
| 'desktop.mediaQuality.levels' | 'desktop.mediaQuality.levels'
| 'desktop.messageRequests' | 'desktop.messageRequests'
| 'desktop.retryReceiptLifespan' | 'desktop.retryReceiptLifespan'
| 'desktop.retryRespondMaxAge' | 'desktop.retryRespondMaxAge'
| 'desktop.screensharing2' | 'desktop.screensharing2'
| 'desktop.senderKey.send'
| 'desktop.senderKey.retry'
| 'desktop.storage' | 'desktop.storage'
| 'desktop.storageWrite3' | 'desktop.storageWrite3'
| 'desktop.worksAtSignal' | 'desktop.worksAtSignal'

View file

@ -41,6 +41,13 @@ export async function onRetryRequest(event: RetryRequestEvent): Promise<void> {
window.log.info(`onRetryRequest/${logId}: Starting...`); window.log.info(`onRetryRequest/${logId}: Starting...`);
if (!RemoteConfig.isEnabled('desktop.senderKey.retry')) {
window.log.warn(
`onRetryRequest/${logId}: Feature flag disabled, returning early.`
);
return;
}
if (window.RETRY_DELAY) { if (window.RETRY_DELAY) {
window.log.warn( window.log.warn(
`onRetryRequest/${logId}: Delaying because RETRY_DELAY is set...` `onRetryRequest/${logId}: Delaying because RETRY_DELAY is set...`
@ -145,7 +152,10 @@ export async function onDecryptionError(
await conversation.getProfiles(); await conversation.getProfiles();
} }
if (conversation.get('capabilities')?.senderKey) { if (
conversation.get('capabilities')?.senderKey &&
RemoteConfig.isEnabled('desktop.senderKey.retry')
) {
await requestResend(decryptionError); await requestResend(decryptionError);
} else { } else {
await startAutomaticSessionReset(decryptionError); await startAutomaticSessionReset(decryptionError);

View file

@ -12,6 +12,7 @@ import {
UnidentifiedSenderMessageContent, UnidentifiedSenderMessageContent,
} from '@signalapp/signal-client'; } from '@signalapp/signal-client';
import { typedArrayToArrayBuffer as toArrayBuffer } from '../Crypto'; import { typedArrayToArrayBuffer as toArrayBuffer } from '../Crypto';
import * as Bytes from '../Bytes';
import { senderCertificateService } from '../services/senderCertificate'; import { senderCertificateService } from '../services/senderCertificate';
import { import {
padMessage, padMessage,
@ -42,6 +43,7 @@ import {
multiRecipient410ResponseSchema, multiRecipient410ResponseSchema,
} from '../textsecure/WebAPI'; } from '../textsecure/WebAPI';
import { SignalService as Proto } from '../protobuf'; import { SignalService as Proto } from '../protobuf';
import * as RemoteConfig from '../RemoteConfig';
import { strictAssert } from './assert'; import { strictAssert } from './assert';
import { isGroupV2 } from './whatTypeOfConversation'; import { isGroupV2 } from './whatTypeOfConversation';
@ -57,6 +59,9 @@ const MAX_CONCURRENCY = 5;
// sendWithSenderKey is recursive, but we don't want to loop back too many times. // sendWithSenderKey is recursive, but we don't want to loop back too many times.
const MAX_RECURSION = 10; const MAX_RECURSION = 10;
const ACCESS_KEY_LENGTH = 16;
const ZERO_ACCESS_KEY = Bytes.toBase64(new Uint8Array(ACCESS_KEY_LENGTH));
// TODO: remove once we move away from ArrayBuffers // TODO: remove once we move away from ArrayBuffers
const FIXMEU8 = Uint8Array; const FIXMEU8 = Uint8Array;
@ -142,6 +147,7 @@ export async function sendContentMessageToGroup({
if ( if (
ourConversation?.get('capabilities')?.senderKey && ourConversation?.get('capabilities')?.senderKey &&
RemoteConfig.isEnabled('desktop.senderKey.send') &&
isGroupV2(conversation.attributes) isGroupV2(conversation.attributes)
) { ) {
try { try {
@ -744,7 +750,6 @@ async function handle410Response(
} }
function getXorOfAccessKeys(devices: Array<DeviceType>): Buffer { function getXorOfAccessKeys(devices: Array<DeviceType>): Buffer {
const ACCESS_KEY_LENGTH = 16;
const uuids = getUuidsFromDevices(devices); const uuids = getUuidsFromDevices(devices);
const result = Buffer.alloc(ACCESS_KEY_LENGTH); const result = Buffer.alloc(ACCESS_KEY_LENGTH);
@ -1008,13 +1013,17 @@ function getAccessKey(
): string | undefined { ): string | undefined {
const { sealedSender, accessKey } = attributes; const { sealedSender, accessKey } = attributes;
if ( if (sealedSender === SEALED_SENDER.ENABLED) {
sealedSender === SEALED_SENDER.ENABLED ||
sealedSender === SEALED_SENDER.UNKNOWN
) {
return accessKey || undefined; return accessKey || undefined;
} }
if (
sealedSender === SEALED_SENDER.UNKNOWN ||
sealedSender === SEALED_SENDER.UNRESTRICTED
) {
return ZERO_ACCESS_KEY;
}
return undefined; return undefined;
} }