From e6932982d4ff0dfa88d37295def0c98f99b5c6c4 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Thu, 3 Oct 2024 22:30:14 +0700 Subject: [PATCH] #314 simpler (and correct) padding calculation --- html5/js/Protocol.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html5/js/Protocol.js b/html5/js/Protocol.js index 651ff441..b03bc59c 100644 --- a/html5/js/Protocol.js +++ b/html5/js/Protocol.js @@ -301,11 +301,11 @@ class XpraProtocol { let packet_size = [4, 5, 6, 7].reduce((accumulator, value) => accumulator * 0x1_00 + this.header[value], 0); - // work out padding if necessary + // add padding if encryption is enabled let padding = 0; if (encrypted && this.cipher_in_block_size > 0) { // PKCS#7 has always at least one byte of padding! - padding = this.cipher_in_block_size + 1 - (packet_size + 1) % this.cipher_in_block_size; + padding = this.cipher_in_block_size - packet_size % this.cipher_in_block_size; packet_size += padding; }