SharpZipLib icon indicating copy to clipboard operation
SharpZipLib copied to clipboard

Decryption method not supported error when remove existing zip-entry and add new zip-entry with same name in zip file.

Open madanbhangre opened this issue 5 years ago • 2 comments

I am using SharpZipLib v1.2.0.246 to zip and unzip the files with AES encryption.

Steps to reproduce

  1. I have set the zipEntry.AESKeySize to 128 or 256
  2. I have a zip file which contains a zip-entry i.e. 'Test.xml' file which i reads during initialization.
  3. The Test.xml file contents is getting updated and i have to update the zip file accordingly.
  4. To do this firstly i am removing the 'Test.xml' from zip(deleting the file) and add new entry with same name using StaticDataSource.
  5. While doing this, the version of zip-entry is getting changed. i.e. when zip file is got created the version of zip entry was '51' but after deleting and adding new entry it became '20'. so i got the "Decryption method not supported, at ICSharpCode.SharpZipLib.Zip.ZipFile.CreateAndInitDecryptionStream(Stream baseStream, ZipEntry entry) in 'zipfilepath' "

Expected behavior

It should update zipfile with latest zip entry and should be AES encrypted.

Actual behavior

It throws exception : ICSharpCode.SharpZipLib.Zip.ZipException: 'Decryption method not supported at ICSharpCode.SharpZipLib.Zip.ZipFile.CreateAndInitDecryptionStream(Stream baseStream, ZipEntry entry) in C:\projects\sharpziplib\src\ICSharpCode.SharpZipLib\Zip\ZipFile.cs:line 3606 at ICSharpCode.SharpZipLib.Zip.ZipFile.GetInputStream(Int64 entryIndex) in C:\projects\sharpziplib\src\ICSharpCode.SharpZipLib\Zip\ZipFile.cs:line 867 at ICSharpCode.SharpZipLib.Zip.ZipFile.GetInputStream(ZipEntry entry) in C:\projects\sharpziplib\src\ICSharpCode.SharpZipLib\Zip\ZipFile.cs:line 835 at Knorr.DF.Zip.KBZipContainer.ExtractZipEntries(Stream str, String password, Int32 aesKeySize)

Version of SharpZipLib

ICSharpCode.SharpZipLib v1.2.0.246

Obtained from (only keep the relevant lines)

  • Package installed using NuGet

madanbhangre avatar Jan 17 '20 08:01 madanbhangre

Another one related to ZipFile not supporting the creation of AES encrypted entries I guess? (related to #385, but for modifying entries rather than adding them)

Numpsy avatar Jan 21 '20 17:01 Numpsy

Yeah, it should just be a matter of throwing the same exception as in https://github.com/icsharpcode/SharpZipLib/pull/420

piksel avatar Apr 20 '21 12:04 piksel