fix padding for medium group
This commit is contained in:
parent
8123508b51
commit
215c964fab
|
@ -21,15 +21,19 @@ import { StringUtils } from '../session/utils';
|
|||
import { UserUtil } from '../util';
|
||||
|
||||
export async function handleContentMessage(envelope: EnvelopePlus) {
|
||||
const plaintext = await decrypt(envelope, envelope.content);
|
||||
try {
|
||||
const plaintext = await decrypt(envelope, envelope.content);
|
||||
|
||||
if (!plaintext) {
|
||||
window.log.warn('handleContentMessage: plaintext was falsey');
|
||||
return;
|
||||
} else if (plaintext instanceof ArrayBuffer && plaintext.byteLength === 0) {
|
||||
return;
|
||||
if (!plaintext) {
|
||||
window.log.warn('handleContentMessage: plaintext was falsey');
|
||||
return;
|
||||
} else if (plaintext instanceof ArrayBuffer && plaintext.byteLength === 0) {
|
||||
return;
|
||||
}
|
||||
await innerHandleContentMessage(envelope, plaintext);
|
||||
} catch (e) {
|
||||
window.log.warn(e);
|
||||
}
|
||||
await innerHandleContentMessage(envelope, plaintext);
|
||||
}
|
||||
|
||||
async function decryptForMediumGroup(
|
||||
|
@ -86,7 +90,7 @@ async function decryptForMediumGroup(
|
|||
sourceAsStr
|
||||
);
|
||||
|
||||
return plaintext;
|
||||
return unpad(plaintext);
|
||||
}
|
||||
|
||||
function unpad(paddedData: ArrayBuffer): ArrayBuffer {
|
||||
|
|
|
@ -52,7 +52,7 @@ export async function encrypt(
|
|||
const plainText = padPlainTextBuffer(plainTextBuffer);
|
||||
|
||||
if (encryptionType === EncryptionType.MediumGroup) {
|
||||
return encryptForMediumGroup(device, plainTextBuffer);
|
||||
return encryptForMediumGroup(device, plainText);
|
||||
}
|
||||
|
||||
const address = new window.libsignal.SignalProtocolAddress(device.key, 1);
|
||||
|
|
|
@ -108,7 +108,7 @@ export class ChatMessage extends DataMessage {
|
|||
}
|
||||
dataMessage.profile = profile;
|
||||
}
|
||||
if (this.profileKey) {
|
||||
if (this.profileKey && this.profileKey.length) {
|
||||
dataMessage.profileKey = this.profileKey;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ export class ExpirationTimerUpdateMessage extends DataMessage {
|
|||
if (this.expireTimer) {
|
||||
data.expireTimer = this.expireTimer;
|
||||
}
|
||||
if (this.profileKey) {
|
||||
if (this.profileKey && this.profileKey.length) {
|
||||
data.profileKey = this.profileKey;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue