Skip to content

Test the header MAC byte by byte, and Bech32's two padding rules - #145

Merged
pscheid92 merged 3 commits into
mainfrom
test/review-gaps
Nov 30, 2026
Merged

pscheid92 merged 3 commits into
mainfrom
test/review-gaps

Conversation

@pscheid92

@pscheid92 pscheid92 commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Tests, and a fix to CI's downloads. The 2026-11-30 review removed 25 security checks one at a time; three removals left both suites green. Each now fails a test.

Check removed Where Test that now fails
Comparing only 31 of the MAC's 32 bytes Age/Format/Header.cs:91 HeaderMacTests.AFileWithOneByteOfItsMacChanged_FailsAuthentication(31)
Padding bits that are not zero Age/Crypto/Bech32.cs:207 Bech32Tests.PaddingBitsThatAreNotZero_AreRejected (3 cases)
A whole group of padding Age/Crypto/Bech32.cs:204 Bech32Tests.AWholeGroupOfPadding_IsRejected
  • The MAC test changes each of the 32 bytes in turn, re-encodes the line canonically, and checks first that the header still parses, so the refusal is the MAC's.
  • The Bech32 tests respell a key with an encoder of their own, because the library's cannot write a non-canonical string. That encoder is checked against BIP-173's published vectors and the library's output before anything is concluded from it.

Checked

  • Each of the three deletions re-applied in a scratch copy: the unit suite fails with 1, 3 and 1 failures.
  • dotnet test and dotnet test -c Release -p:ForcePortableAead=true -p:TreatWarningsAsErrors=true: 1,176 vectors and 1,636 unit tests pass.

CI downloads

Two runs of this PR failed in "Install rage", on macOS and then on Windows: GitHub's release download answered 618 jwt:expired. In .github/workflows/test.yml every age and rage download now retries five times on any error. The curl ones write to a file that tar then reads, instead of piping into it.

The 2026-11-30 review removed 25 checks one at a time, and three removals
left every test green: comparing only 31 of the MAC's 32 bytes, accepting
padding bits that are not zero in a Bech32 key, and accepting a whole
group of padding. Each now fails a test.

The Bech32 tests respell a key with an encoder of their own, since the
library's cannot write a non-canonical string; that encoder is held to
BIP-173's published vectors and to the library's output first.
The macOS job failed in "Install rage" with tar's "Unrecognized archive
format": the download had failed, and curl without --fail passes the
error page on to tar. The same URL served the archive a minute later.
The six downloads now fail on an HTTP error and retry three times.
The Windows job failed in "Install rage" as the macOS job had: GitHub's
release download answered "618 jwt:expired" from its cache. curl's
--retry alone does not retry a status like that, and Invoke-WebRequest
did not retry at all.

Every download now retries five times on any error. The curl ones write
to a file that tar then reads, so a retry cannot follow half an archive
down a pipe.
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.60%. Comparing base (061fee0) to head (d129e88).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #145      +/-   ##
==========================================
+ Coverage   97.48%   97.60%   +0.11%     
==========================================
  Files          75       75              
  Lines        5001     5001              
  Branches      688      688              
==========================================
+ Hits         4875     4881       +6     
+ Misses         76       73       -3     
+ Partials       50       47       -3     
Flag Coverage Δ
macos-latest 97.50% <ø> (+0.07%) ⬆️
ubuntu-latest 97.56% <ø> (+0.07%) ⬆️
windows-latest 97.44% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pscheid92
pscheid92 merged commit fffb287 into main Nov 30, 2026
6 checks passed
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 this pull request may close these issues.

1 participant