Repository navigation
Conversation
…styGet) (#362) ZipCrypto's keys before member output byte n depend only on the password, the 12-byte encryption header and the plaintext 0..n, so a handover that holds that plaintext rolls the keys over it and decrypts from packed byte 12 + n on. - member_restart reports StoredSequential with the new RestartGrain::KnownPlaintext; open_at plans Start::ZipCrypto { donor: 0..n } with spans = header (0..12), then 12 + n to the end (n may equal the size). - resume_zipcrypto / complete_zipcrypto (and ZipCryptoResume::new without a map) verify the check byte (time high byte with a data descriptor, CRC high byte otherwise), roll the keys, decrypt the rest and prove the whole output by the member's CRC32. The prefix CRC is always computed from the bytes the keys were rolled over; a given one must match. - skipped_spans keeps the header of a ZipCrypto plan. - tests/zip_crypto_restart.rs over Info-ZIP (descriptor) and 7-Zip (no descriptor) fixtures: offsets 0, 1, 11, 12, 13, mid, size-1, size, a counting reader, wrong password, corrupted prefix, hostile inputs. Clean-room from PKWARE APPNOTE.TXT and observed behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LG44gYJFfVCupfunL2idYi
Collaborator
Author
|
@codex review |
Collaborator
Author
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.
Closes #362 (RustyGet#813, prybar#225).
A stored ZipCrypto member can now restart at any offset from the known plaintext before it. Before, it could only restart at its start.
How it works
member_restartnow reportsStoredSequentialwith the newRestartGrain::KnownPlaintext(the enum is#[non_exhaustive]).open_atreturnsStart::ZipCrypto { donor }. The spans are the header followed by12 + target..end, andtarget == sizeis allowed.resume_zipcryptochecks the check byte first: the CRC high byte, or the time high byte when bit 3 is set. It then rolls the keys over the header and the known plaintext and returns a positionedZipCryptoResume.complete_zipcryptodecrypts the rest and proves the member by CRC32 over the known prefix plus the rest.Crc, never as accepted output. A suppliedprefix_crcis checked, not trusted.ZipCryptoResume::new(&ZipCryptoEntry, ...).OpenAtError::ZipCrypto(ZipCryptoError::…).ZipCrypto::absorbrolls the keys over plaintext.zipcrypto_checkis now shared with the ZIP mapper.Tests
tests/zip_crypto_restart.rs:u64::MAX, and truncated or over-long data are refused without panics.Fixtures (
tests/fixtures/zip-crypto-restart/): one made with Info-ZIPzip -0 -P(bit 3 set, so its check byte is the time byte), one with 7-Zip-mem=ZipCrypto(no descriptor). The binaries were run in docker; the README gives the commands.Clean-room: written from PKWARE APPNOTE only.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LG44gYJFfVCupfunL2idYi