Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make int_to_bytes and numberToByteArray encode 0 as b'\x00' #527

Merged
merged 2 commits into from
Aug 29, 2024

Conversation

tomato42
Copy link
Member

@tomato42 tomato42 commented Aug 28, 2024

make int_to_bytes() and numberToByteArray() consistent with int().to_bytes() from python3, that means encoding zero as a single null byte, not as an empty byte string

also fix the bug hidden by it:
ClientKeyExchange: correctly detect too short key shares

the field for DH key shares is defined as

case explicit: opaque DH_Yc<1..2^16-1>;

so the share must be at least 1 byte long, update the code to abort if it is too short


This change is Reviewable

make int_to_bytes() and numberToByteArray() consistent with
int().to_bytes() from python3, that means encoding zero as
a single null byte, not as an empty byte string
@tomato42 tomato42 added the bug unintented behaviour in tlslite-ng code label Aug 28, 2024
@tomato42 tomato42 self-assigned this Aug 28, 2024
the field is defined as
```
case explicit: opaque DH_Yc<1..2^16-1>;
```
so the share must be at least 1 byte long
Copy link
Collaborator

@ep69 ep69 left a comment

Choose a reason for hiding this comment

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

LGTM

@tomato42 tomato42 merged commit 77ef321 into master Aug 29, 2024
87 checks passed
@tomato42 tomato42 deleted the correct-int-to-bytes branch August 29, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unintented behaviour in tlslite-ng code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants