Fixes for Sender Key: Receive

This commit is contained in:
Scott Nonnenberg 2021-05-24 11:59:45 -07:00 committed by GitHub
parent 09ef4d85e0
commit e76252d3b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1128,33 +1128,7 @@ class MessageReceiverInner extends EventTarget {
ArrayBuffer | { isMe: boolean } | { isBlocked: boolean } | undefined ArrayBuffer | { isMe: boolean } | { isBlocked: boolean } | undefined
>; >;
if (envelope.type === envelopeTypeEnum.SENDERKEY) { if (envelope.type === envelopeTypeEnum.CIPHERTEXT) {
window.log.info('sender key message from', this.getEnvelopeId(envelope));
if (!identifier) {
throw new Error(
'MessageReceiver.decrypt: No identifier for SENDERKEY message'
);
}
if (!sourceDevice) {
throw new Error(
'MessageReceiver.decrypt: No sourceDevice for SENDERKEY message'
);
}
const senderKeyStore = new SenderKeys();
const address = `${identifier}.${sourceDevice}`;
const messageBuffer = Buffer.from(ciphertext.toArrayBuffer());
promise = window.textsecure.storage.protocol.enqueueSenderKeyJob(
address,
() =>
groupDecrypt(
ProtocolAddress.new(identifier, sourceDevice),
senderKeyStore,
messageBuffer
).then(plaintext => this.unpad(typedArrayToArrayBuffer(plaintext))),
zone
);
} else if (envelope.type === envelopeTypeEnum.CIPHERTEXT) {
window.log.info('message from', this.getEnvelopeId(envelope)); window.log.info('message from', this.getEnvelopeId(envelope));
if (!identifier) { if (!identifier) {
throw new Error( throw new Error(
@ -1282,7 +1256,7 @@ class MessageReceiverInner extends EventTarget {
sealedSenderSourceDevice sealedSenderSourceDevice
), ),
senderKeyStore, senderKeyStore,
buffer messageContent.contents()
), ),
zone zone
); );
@ -1317,7 +1291,7 @@ class MessageReceiverInner extends EventTarget {
return result; return result;
} }
if (result instanceof Buffer) { if (result instanceof Buffer) {
return this.unpad(typedArrayToArrayBuffer(result)); return typedArrayToArrayBuffer(result);
} }
const content = typedArrayToArrayBuffer(result.message()); const content = typedArrayToArrayBuffer(result.message());