LOG.finest( "salt = " + ByteArrayHelper.toString(salt) + " - " + salt.length );
LOG.finest( "pwVerif = " + ByteArrayHelper.toString(pwVerification) + " - " + pwVerification.length );
}
// encrypter throws ZipException for wrong password
AESDecrypter decrypter = new AESDecrypterBC( pwBytes, salt, pwVerification );
// create tmp file to contains the decrypted, but still compressed data
File tmpFile = new File( outFile.getPath() + "_TMP.zip" );
makeDir( new File(tmpFile.getParent()) );
ExtZipOutputStream zos = new ExtZipOutputStream( tmpFile );
ExtZipEntry tmpEntry = new ExtZipEntry( zipEntry );
tmpEntry.setPrimaryCompressionMethod( zipEntry.getMethod() );
zos.putNextEntry( tmpEntry );
raFile.seek( cde.getOffset() );
byte[] buffer = new byte[bufferSize];
int remaining = (int)zipEntry.getEncryptedDataSize();
while( remaining>0 ) {
int len = (remaining>buffer.length) ? buffer.length : remaining;
int read = raFile.readByteArray(buffer,len);
decrypter.decrypt( buffer, read );
zos.writeBytes( buffer, 0, read );
remaining -= len;
}
zos.finish();
byte[] storedMac = new byte[10];
raFile.readByteArray(storedMac,10);
byte[] calcMac = decrypter.getFinalAuthentication();
if( LOG.isLoggable(Level.FINE) ) {
LOG.fine( "storedMac=" + Arrays.toString(storedMac) );
LOG.fine( "calcMac=" + Arrays.toString(calcMac) );
}
if( !Arrays.equals(storedMac, calcMac ) ) {