Skip to content

Comments

Ensure packets are a multiple of the cipher block size#21

Merged
bjorn3 merged 1 commit intomainfrom
bjorn3/fix_padding
Jan 6, 2026
Merged

Ensure packets are a multiple of the cipher block size#21
bjorn3 merged 1 commit intomainfrom
bjorn3/fix_padding

Conversation

@bjorn3
Copy link
Collaborator

@bjorn3 bjorn3 commented Jan 6, 2026

Fixes #18

@bjorn3 bjorn3 requested a review from davidv1992 January 6, 2026 11:00
Copy link
Collaborator

@davidv1992 davidv1992 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strongly prefer to split this as the second commit will cause conflicts with #14 and the steps afterwards, and once that is in also isn't really needed.

@bjorn3 bjorn3 force-pushed the bjorn3/fix_padding branch from fb826f4 to b7d1010 Compare January 6, 2026 12:01
Copy link
Collaborator

@davidv1992 davidv1992 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed 1 part of the bug

let min_padding = 8 - (buf.len() - start) % 8;
let block_size = cipher_block_len.max(8);
let min_padding = block_size - (buf.len() - start) % block_size;
let padding_len = match min_padding < 4 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing 1 potential part of the bug here, namely that the packet also needs to be at least 16 bytes long.

@davidv1992
Copy link
Collaborator

Changed my mind, we can do the second part in a separate PR if thats desirable.

@bjorn3 bjorn3 merged commit 82972fd into main Jan 6, 2026
6 of 7 checks passed
@bjorn3 bjorn3 deleted the bjorn3/fix_padding branch January 6, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix bug in padding of packets

2 participants