Skip to content

Commit cb22552

Browse files
Update outgoing message size calculation
1 parent 0afe686 commit cb22552

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ts/textsecure/OutgoingMessage.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,19 @@ function ciphertextMessageTypeToEnvelopeType(type: number) {
8888
);
8989
}
9090

91+
const PADDING_BLOCK = 80;
92+
9193
function getPaddedMessageLength(messageLength: number): number {
9294
const messageLengthWithTerminator = messageLength + 1;
93-
let messagePartCount = Math.floor(messageLengthWithTerminator / 160);
95+
let messagePartCount = Math.floor(
96+
messageLengthWithTerminator / PADDING_BLOCK
97+
);
9498

95-
if (messageLengthWithTerminator % 160 !== 0) {
99+
if (messageLengthWithTerminator % PADDING_BLOCK !== 0) {
96100
messagePartCount += 1;
97101
}
98102

99-
return messagePartCount * 160;
103+
return messagePartCount * PADDING_BLOCK;
100104
}
101105

102106
export function padMessage(messageBuffer: Uint8Array): Uint8Array {

0 commit comments

Comments
 (0)