lukas-kubik / winzipaes

Automatically exported from code.google.com/p/winzipaes
0 stars 0 forks source link

extract encrypted entries by AesZipFileDecrypter failed #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I downloaded a file windiff.zip from internet and use this component to
encrpt it, then decrypt it. The encrypt works perfectly. I can open and
extract files from the encrypted zip file test_encrypted1.zip by WinZip.
But I got the following error when decrypt and extract by this component.

I've attached test code and test files to this issue.

java.util.zip.ZipException: stored authentication (mac) value does not
match calculated one
    at
de.idyl.crypto.zip.AesZipFileDecrypter.extractEntry(AesZipFileDecrypter.java:184
)
    at TestEncryptZipFile.testDecryptZipFile(TestEncryptZipFile.java:35)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.j
ava:99)
    at
org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java
:81)
    at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunne
r.java:34)
    at
org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
    at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
    at
org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMeth
odsRunner.java:66)
    at
org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.jav
a:35)
    at
org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java
:42)
    at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunne
r.java:34)
    at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
    at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReferen
ce.java:38)
    at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:460)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner
.java:673)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java
:386)
    at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.jav
a:196)

import org.junit.Test;

import de.idyl.crypto.zip.AesZipFileDecrypter;
import de.idyl.crypto.zip.AesZipFileEncrypter;
import de.idyl.crypto.zip.impl.ExtZipEntry;

public class TestEncryptZipFile {

    //@Test
    public void testEncryptZipFile()throws Exception{

      AesZipFileEncrypter enc = new AesZipFileEncrypter(
"c:/test_encrypted1.zip" );
      enc.addEncrypted(new File("c:/windiff.zip"), "abcdef");

      System.out.println("---success! ---");
    }

    @Test
    public void testDecryptZipFile()throws Exception{

      AesZipFileDecrypter d = new AesZipFileDecrypter( new File(
"c:/test_encrypted1.zip" ));

      List<ExtZipEntry> list = d.getEntryList();

      int n = list.size();

      for (int i=0; i<n; i++){
          ExtZipEntry entry = list.get(i)         ;
          String name= entry.getName();
          System.out.println("name="+name);
          d.extractEntry( entry, new File("C:\\Temp\\windiffziptest\\"+name),
"abcdef" );
      }

      System.out.println("---success! ---");
    }   

}

Original issue reported on code.google.com by Yizhuan...@gmail.com on 29 Sep 2009 at 2:56

Attachments:

GoogleCodeExporter commented 9 years ago
Issue 7 has been merged into this issue.

Original comment by olaf.merkert on 3 Oct 2009 at 5:26

GoogleCodeExporter commented 9 years ago

Original comment by olaf.merkert on 3 Oct 2009 at 5:26

GoogleCodeExporter commented 9 years ago
code change in AesZipFileDecrypter to fix bug introduced with fix for issue 5 -
unfortunately the error only occured for larger files

@Yizhuan.Yu: Thanks for your input + please verify the fix

Original comment by olaf.merkert on 3 Oct 2009 at 6:34

GoogleCodeExporter commented 9 years ago
I tested the fix, it works for me! Thanks Olaf! That was a very quick fix!

Original comment by Yizhuan...@gmail.com on 7 Oct 2009 at 9:11

GoogleCodeExporter commented 9 years ago
where do i see the fix?

Original comment by limkwee...@gmail.com on 12 May 2013 at 4:24

GoogleCodeExporter commented 9 years ago
https://code.google.com/p/winzipaes/source/detail?r=40

Original comment by olaf.merkert on 12 May 2013 at 5:36

GoogleCodeExporter commented 9 years ago
What is the problem exactly? What causes this error to appear?

Original comment by limkwee...@gmail.com on 12 May 2013 at 6:55

GoogleCodeExporter commented 9 years ago
As the fix was made nearly 4 years ago, I can only interpret the diff: the seek 
must be done before the while loop (as it's otherwise performed too often and 
data is subsequently read from the beginning of the entry data) - the error 
only occurs for larger entries as small ones are read within one loop iteration

Original comment by olaf.merkert on 12 May 2013 at 9:28