Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Info-Zip password check spec for ZipCrypto. #472

Merged
merged 2 commits into from
Mar 13, 2024
Merged

Add support for Info-Zip password check spec for ZipCrypto. #472

merged 2 commits into from
Mar 13, 2024

Conversation

lukemalcolm
Copy link
Contributor

@lukemalcolm lukemalcolm commented Mar 5, 2024

Introduction

Currently, ADM-ZIP ZipCrypto (PKCRYPT method) rejects valid passwords that use the Info-Zip standard of password validation.

This specification uses the high bit of the headers modified time, instead of the crc to compare against the LSB of the decrypted 12 bit salt and is only applicable when bit 3 of the general purpose bit flag is set.

This method of password checking looks like it originated in the Info-Zip standard, is still used by a number of older zip generators and is gracefully handled by all other zip tools I tried (7zip, WinZip, Windows etc).

Spec References:

Info-Zip Standard - Line 2806
minizip-ng implementation - Line 193

Relates to issue #471
Possibly relates to #467 and #385

The changes

The code does the following:

headers/entryHeader.js : The high byte of the headers modified time is exposed as timeHighByte()

methods/zipcrypto.js : The header flags are read to see if bit 3 is set. If it is, the password salt check is based on the high byte of the modified time, rather than the crc. If the flags are undefined (and I'm not sure when they would be), then the crc is used.

test/methods/zipcrypto.test.js : Header flags are provided into the getData function calls, to better represent the reality of a zip file and to allow the two code paths to be tested. Additional tests have been added to test the Info-Zip paths.

test/issue_471/infozip-password.test.js : A full file decryption test for Info-Zip generated files that tests valid and invalid passwords.

Testing

I've run the test suite and all tests pass. I've also added the testing route for Info-Zip generated encrypted zips.

To: @cthackers

…h byte of header modified time, rather than crc). Updates current tests to handle.
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.

2 participants