Skip to content

MemberCheck verifies BLAKE2sp, plain or keyed, alongside CRC32 (RustyGet) - #368

Merged
xbmc4lyfe merged 2 commits into
mainfrom
member-check-blake2sp
Nov 30, 2026
Merged

xbmc4lyfe merged 2 commits into
mainfrom
member-check-blake2sp

Conversation

@xbmc4lyfe

Copy link
Copy Markdown
Collaborator

Backs RustyGet#817 (direct RAR 5.0 BLAKE2sp member verification).

What changes

  • MemberMap::member_check no longer returns NoCrc32 for a BLAKE2sp-only RAR 5.0 member (-htb). The check carries the recorded CRC32, BLAKE2sp, or both.
  • MemberCheck::verify(plain_crc32: Option<u32>, plain_blake2sp: Option<&[u8; 32]>) passes only when every checksum the member records was given and matches, so both when both are recorded. A value given for an unrecorded checksum is ignored.
  • MemberCheck::matches_blake2sp(&[u8; 32]) compares the BLAKE2sp alone.
  • A keyed member (-p with the hash-key flag) has its BLAKE2sp tweaked with the derived hash key before comparing, exactly like the CRC32. The caller always passes plain digests (zipfast::blake2sp::Blake2sp).
  • zipfast::crypto::rar5_tweak_blake2sp is now pub, beside rar5_tweak_crc32.
  • recorded_blake2sp() -> Option<[u8; 32]> is new.

API changes

  • Breaking: recorded_crc32() returns Option<u32> (it was u32).
  • matches(crc) is false for a member that records no CRC32.
  • NoCrc32 now means no checksum at all: a directory, or a 7z member of a multi-member folder without its own digest.
  • Debug shows whether a BLAKE2sp is recorded, and still never shows the hash key.

Tests

tests/member_check.rs, 5 new tests, 10 in total:

  • a BLAKE2sp-only member;
  • a member with both checksums, where verify needs both;
  • a keyed BLAKE2sp, including PasswordRequired and a wrong password never matching;
  • a keyed CRC32 plus keyed BLAKE2sp;
  • an encrypted member without the hash-key flag, which records a plain digest.

rar5_encrypted, member_map and the doctests also pass. fmt and both clippy runs are clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LG44gYJFfVCupfunL2idYi

…Get)

A BLAKE2sp-only RAR 5.0 member (-htb) used to have no check (NoCrc32). MemberCheck now carries the recorded CRC32,
BLAKE2sp, or both. verify(crc, blake) passes only when every recorded value is given and matches; matches_blake2sp
compares the digest alone. A keyed (-p, hash-key flag) BLAKE2sp is tweaked with the derived hash key, like the
CRC32. crypto::rar5_tweak_blake2sp is now public beside rar5_tweak_crc32.

API change: recorded_crc32() returns Option<u32>. matches(crc) is false for a member that records no CRC32.
NoCrc32 now means no checksum at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gYJFfVCupfunL2idYi
@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

@codex review

A caller that treated NoCrc32 as "unverifiable" would have compiled unchanged and then rejected good output, since a
BLAKE2sp-only member now gets a check whose matches(crc) is false. The rename makes such code fail to compile so it
is revisited. New test: a two-volume keyed BLAKE2sp member takes its whole-output digest and hash-key flag from the
final part, never part 1's packed hash, and is Incomplete without the final volume.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gYJFfVCupfunL2idYi
@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

Local CI @ 7055dd2 (up to date with origin/main): ALL GATES PASSED on all three platforms: x86_64 (spot rustyget-x86-q), arm64 (spot rustyget-arm-g) and macOS (m4air). Each ran fmt, clippy x2, tests x2 and doctests x2.
Codex appears to be out of usage (no response), so a clean-room subagent review was done instead: verdict ship. Its medium finding was addressed in 7055dd2: NoCrc32 was renamed to NoChecksum so a caller that treated it as "unverifiable" fails to compile rather than silently rejecting good BLAKE2sp-only output. A split -p -htb member test was added. Merging.

@xbmc4lyfe
xbmc4lyfe merged commit d438cad into main Nov 30, 2026
0 of 7 checks passed
@xbmc4lyfe
xbmc4lyfe deleted the member-check-blake2sp branch November 30, 2026 16:34
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