Skip to content

Commit

Permalink
#314 simpler (and correct) padding calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Oct 3, 2024
1 parent 41f8ab7 commit e693298
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions html5/js/Protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e693298

Please sign in to comment.