throw new ZipException("zipEntry must NOT be NULL");
}
if( zipEntry.isEncrypted() ) {
byte[] pwBytes = password.getBytes(charset);
CentralDirectoryEntry cde = zipEntry.getCentralDirectoryEntry();
int cryptoHeaderOffset = zipEntry.getOffset() - cde.getCryptoHeaderLength();
byte[] salt = raFile.readByteArray( cryptoHeaderOffset, 16 );
byte[] pwVerification = raFile.readByteArray( cryptoHeaderOffset+16, 2 );
if( LOG.isLoggable(Level.FINEST) ) {
LOG.finest( "\n" + cde.toString() );
LOG.finest( "offset = " + zipEntry.getOffset() );
LOG.finest( "cryptoOff = " + cryptoHeaderOffset );
LOG.finest( "pwBytes = " + ByteArrayHelper.toString(pwBytes) + " - " + pwBytes.length );
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);