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

matrix-sdk-crypto-ffi | Scan QR code method is sensitive to base 64 padding when decoding #2531

Closed
BillCarsonFr opened this issue Sep 8, 2023 · 0 comments · Fixed by #2532
Assignees

Comments

@BillCarsonFr
Copy link
Member

BillCarsonFr commented Sep 8, 2023

Root cause of element-hq/element-ios#7660

Some clients will pass QR code data as base64 with padding and currently the rust-crypto-ffi will fail to process such qr codes due to the unexpected padding.

The sdk should be able to decode base64 indifferently of the padding.
The decoder used by the ffi crate is here

const STANDARD_NO_PAD: GeneralPurpose =

The one used by other parts of the SDK is this one:

const STANDARD_NO_PAD: GeneralPurpose = GeneralPurpose::new(
&alphabet::STANDARD,
general_purpose::NO_PAD
.with_decode_padding_mode(base64::engine::DecodePaddingMode::Indifferent),
);

The later is correctly using DecodePaddingMode::Indifferent

Notice that vodozemac as also a similar utility crate that is not public https://github.com/matrix-org/vodozemac/blob/e3b658526f6f1dd0a9065c1c96346b796712c425/src/utilities/mod.rs#L28

Proposed solution => Make the base64 encode/decode utility from vodozemac public and use it everywhere in the rust SDK

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 a pull request may close this issue.

2 participants