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

Fails to decode messages which are base64 encoded with padding #77

Open
ctron opened this issue May 27, 2022 · 1 comment
Open

Fails to decode messages which are base64 encoded with padding #77

ctron opened this issue May 27, 2022 · 1 comment

Comments

@ctron
Copy link

ctron commented May 27, 2022

Describe the bug

libolm fails to decode megolm messages with are base64 encoded and have padding. The error it returns is "BAD_SIGNATURE".

To Reproduce
Steps to reproduce the behavior:

  1. Create a new inbound group session
  2. Try to decode a message which is base64 and has padding

Expected behavior

Should work or at least return "INVALID_BASE64".

Additional context

Encountered while writing a reproducer as part of matrix-org/vodozemac#69

@uhoreg
Copy link
Member

uhoreg commented Aug 31, 2022

Note to self for later on: It looks like libolm doesn't handle padded base64 at all. Probably the easiest way to fix this would be add a new function that takes the input buffer and length, checks for padding, and returns a new length for the unpadded string. Then, whenever we base64-decode a string, we do something like input_length = base64_unpadded_length(input_buffer, input_length); before decoding.

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

No branches or pull requests

2 participants