fix: snowden mode could not decrypt its own output - #9
Merged
Conversation
encrypt 5.0.3 changed IV.fromLength(16) to return RANDOM bytes instead of
all zeros. The renderer and the reader each build their own IV, so every
snowden-mode QR code became undecryptable ("Invalid or corrupted pad
block"). tryParseBase64 swallows that exception, so the reader silently
ignored every code and an app using it looked like its camera was broken.
Use IV.allZerosOfLength(16) instead. This restores the previous behaviour
and produces byte-identical output to encrypt 5.0.1, so clients on 1.3.0
and earlier can still exchange codes with 1.4.0.
Also:
- Add onError to QrPlusReader, reporting a QrPlusReadError when a code is
detected but cannot be decoded. The silent catch is what made this bug
so hard to diagnose: an undecryptable code was indistinguishable from
the camera seeing nothing.
- Add crypto regression tests that pin the exact wire format, so any
future change in crypto behaviour fails loudly instead of shipping
codes no device can read.
- Fix a TTL test that asserted nothing because it built its crumb with
QrPlusMode.safe, which carries no TTL at all.
- Run CI on pushes to main, not only on pull requests. The 1.3.0
dependency update went straight to main and skipped CI entirely, which
is why the existing round-trip tests never flagged this.
- Bump the CI and CD Flutter versions, which were pinned to 3.10.0 and
3.7.0 and no longer satisfy this package's SDK constraint.
`dart format . --fix` no longer exists: the flag was removed from newer Dart SDKs, so bumping CI from Flutter 3.10.0 to 3.44.2 broke the format step with exit code 64. Formatting is written in place by default, and applying lint fixes is now a separate command (`dart fix --apply`). Also updates QrPlusReaderController's test, which had been failing since 44e26b0 deliberately changed `barcodes` from `const Stream.empty()` to forwarding `super.barcodes`. The implementation is intentional; the test was simply never updated. It stays deprecated because the values it emits are raw, still-encoded scanner data. Full CI pipeline now passes locally: pub get, format (0 changed), analyze --fatal-infos, and all 132 tests.
O-Hannonen
reviewed
Aug 24, 2026
O-Hannonen
left a comment
Collaborator
There was a problem hiding this comment.
LGTM with one nit, nice job! 🚀
| @@ -1,6 +1,6 @@ | |||
| name: qr_plus | |||
| description: Advanced all-in-one qr code package with support for safe qr codes. | |||
| version: 1.3.0 | |||
Collaborator
There was a problem hiding this comment.
Should this be a patch as 1.3.0 is broken? So 1.3.1?
Contributor
Author
There was a problem hiding this comment.
Added the onError callback so I think 1.4.0 is more suitable. Probably should have been its own pr though.
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.
encrypt 5.0.3 changed IV.fromLength(16) to return RANDOM bytes instead of all zeros. The renderer and the reader each build their own IV, so every snowden-mode QR code became undecryptable ("Invalid or corrupted pad block"). tryParseBase64 swallows that exception, so the reader silently ignored every code and an app using it looked like its camera was broken.
Use IV.allZerosOfLength(16) instead. This restores the previous behaviour and produces byte-identical output to encrypt 5.0.1, so clients on 1.3.0 and earlier can still exchange codes with 1.4.0.
Also:
Description
Conventional Type