Repository navigation
Accept unpadded base64 in Olm message bodies - #9
Merged
Merged
Conversation
libolm padded Olm message bodies; vodozemac (matrix-dart-sdk 10.x,
Element) emits them unpadded, so the canonical-padding base64 decoder
rejected every inbound body whose length was not a multiple of 4
("prekey body is not valid base64" / "olm body is not valid base64"),
dropping it. Decode with DecodePaddingMode::Indifferent so
mxc_olm_create_inbound and mxc_olm_decrypt accept both padded and unpadded
bodies; encoding stays padded, which peers already accept. Restores inbound
Olm from vodozemac peers, including MatrixRTC call encryption keys.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Decode Olm message bodies with a padding-indifferent base64 engine so both padded (libolm) and unpadded (vodozemac) bodies open.
Why
mxc_olm_create_inbound()andmxc_olm_decrypt()decoded the Olm message body withbase64 0.22STANDARD, whose default decode padding mode isRequireCanonical. vodozemac (matrix-dart-sdk 10.x, Element, modern FluffyChat) emits Olm bodies unpadded, so every inbound body whose length was not a multiple of 4 was rejected (prekey body is not valid base64/olm body is not valid base64) and silently dropped. This blocked inbound Olm from modern clients generally, and surfaced as MatrixRTC call encryption keys never decrypting (one-way audio only).Change
B64is now aGeneralPurposeengine on the STANDARD alphabet withDecodePaddingMode::Indifferent. Both decode sites (create_inbound,decrypt) accept padded and unpadded; encoding stays canonical (padded), which peers already accept. vodozemac's ownfrom_base64calls (megolm, keys, signatures) were already tolerant, so only the two raw-body decodes needed the change.test_olm.R: builds real Olm bodies, strips their padding to mimic vodozemac, and confirmscreate_inboundanddecryptboth open them (and that padded bodies still work), stepping plaintext length across AES-CBC block boundaries so a genuinely padded body is exercised.Verification
Isolated-library build clean; full
tinytestsuite green including the new regression. Confirmed live: two-way MatrixRTC audio with a FluffyChat fork once tiny ran this build.