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

Mk/add support for extracting password protected LZMA(2) 7z archives #324

Merged
merged 2 commits into from Dec 4, 2017

Conversation

Projects
None yet
3 participants
@CharlieBP
Contributor

CharlieBP commented Dec 3, 2017

Added initial support for Password protected 7z (LZMA / LZMA2) archives and added unit tests to confirm the working.

@CharlieBP CharlieBP changed the title from Mk/add seven zip aes support to Mk/add support for extracting password protected LZMA(2) 7z archives Dec 3, 2017

@CharlieBP

This comment has been minimized.

Show comment
Hide comment
@CharlieBP

CharlieBP Dec 4, 2017

Contributor

Possibly resolves #208

Contributor

CharlieBP commented Dec 4, 2017

Possibly resolves #208

@adamhathcock

This comment has been minimized.

Show comment
Hide comment
@adamhathcock

adamhathcock Dec 4, 2017

Owner

Looks great! Thanks.

Owner

adamhathcock commented Dec 4, 2017

Looks great! Thanks.

@adamhathcock adamhathcock merged commit c2528cf into adamhathcock:master Dec 4, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@michalpenka

This comment has been minimized.

Show comment
Hide comment
@michalpenka

michalpenka Mar 28, 2018

I have a few problems with the archive attached, password "password", created with 7zip 16.04. Had to zip it first to be able to upload it here:
LZMA.AES.7z.zip

Firstly, there is no way to test if archive is encrypted or not. The IsEncrypted property of all the entries is false. To explain a business case - often we get a list of 7z archives and a list of passwords - we need to try the passwords if needed.

Secondly, with password "fdsa" the first two file entries are "successfully" extracted to stream with no exception thrown. The content of these files is, however, still somehow encrypted. The third entry throws an exception.

Thirdly, the invalid password exception would be appreciated. Currently there is no way to catch SharpCompress exceptions as they are protected.

Finally, I have managed to work around the issues mentioned above by trying to extract all the entries into the temp stream first and catching any kind of exception. If no exception is thrown, I know I have a good password (if any). This is of course not ideal as we run through the extraction twice. Also, there is a risk that no exception will be thrown as observed with the first two entries.

Any comments/suggestions/fixes are appreciated.

Thanks for your efforts to support 7z.

michalpenka commented Mar 28, 2018

I have a few problems with the archive attached, password "password", created with 7zip 16.04. Had to zip it first to be able to upload it here:
LZMA.AES.7z.zip

Firstly, there is no way to test if archive is encrypted or not. The IsEncrypted property of all the entries is false. To explain a business case - often we get a list of 7z archives and a list of passwords - we need to try the passwords if needed.

Secondly, with password "fdsa" the first two file entries are "successfully" extracted to stream with no exception thrown. The content of these files is, however, still somehow encrypted. The third entry throws an exception.

Thirdly, the invalid password exception would be appreciated. Currently there is no way to catch SharpCompress exceptions as they are protected.

Finally, I have managed to work around the issues mentioned above by trying to extract all the entries into the temp stream first and catching any kind of exception. If no exception is thrown, I know I have a good password (if any). This is of course not ideal as we run through the extraction twice. Also, there is a risk that no exception will be thrown as observed with the first two entries.

Any comments/suggestions/fixes are appreciated.

Thanks for your efforts to support 7z.

@adamhathcock

This comment has been minimized.

Show comment
Hide comment
@adamhathcock

adamhathcock Mar 28, 2018

Owner

Sounds like there could be some reworking of encryption handling. I think creating an issue is more valid here.

I need to check the zip spec but sometimes (maybe just RAR) you only know if the decryption worked if there's an exception. No other way to know if a password is valid.

Owner

adamhathcock commented Mar 28, 2018

Sounds like there could be some reworking of encryption handling. I think creating an issue is more valid here.

I need to check the zip spec but sometimes (maybe just RAR) you only know if the decryption worked if there's an exception. No other way to know if a password is valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment