public long lastPosOf(byte[] bytesToFind) throws IOException { long out = -1; for( long seekPos=file.length()-1-bytesToFind.length; seekPos>3 && out==-1; seekPos-- ) { byte[] buffer = readByteArray(seekPos,bytesToFind.length); if( Arrays.equals(bytesToFind,buffer) ) { out = seekPos; } } return out; }
byte[] salt = raFile.readByteArray(cryptoHeaderOffset, 16); byte[] pwVerification = raFile.readByteArray(cryptoHeaderOffset + 16, 2); if (LOG.isLoggable(Level.FINEST)) { LOG.finest("\n" + cde.toString()); int remaining = total - count; int len = (remaining > buffer.length) ? buffer.length : remaining; int read = raFile.readByteArray(buffer, len); decrypter.decrypt(buffer, read); zos.writeBytes(buffer, 0, read);
public long lastPosOf(byte[] bytesToFind) throws IOException { long out = -1; for( long seekPos=file.length()-1-bytesToFind.length; seekPos>3 && out==-1; seekPos-- ) { byte[] buffer = readByteArray(seekPos,bytesToFind.length); if( Arrays.equals(bytesToFind,buffer) ) { out = seekPos; } } return out; }
protected void initDirOffsetPosAndComment() throws IOException { // zip files without a comment contain the offset/position of the central directory at this fixed position this.dirOffsetPos = zipFile.length() - 6; final int dirOffset = raFile.readInt( this.dirOffsetPos - 16 ); if( dirOffset!=ENDSIG ) { // if a comment is present, search the ENDSIG constant, starting at the end of the zip file byte[] endsig = ByteArrayHelper.toByteArray((int)ZipConstants.ENDSIG); long endsigPos = raFile.lastPosOf(endsig); if( endsigPos==-1 ) { throw new ZipException("expected ENDSIC not found (marks the beginning of the central directory at end of the zip file)"); } else { this.dirOffsetPos = endsigPos+16; short commentLength = raFile.readShort( this.dirOffsetPos + 4 ); this.comment = new String( raFile.readByteArray( this.dirOffsetPos+6, commentLength ) ); } } }
protected void initDirOffsetPosAndComment() throws IOException { // zip files without a comment contain the offset/position of the central directory at this fixed position this.dirOffsetPos = zipFile.length() - 6; final int dirOffset = raFile.readInt( this.dirOffsetPos - 16 ); if( dirOffset!=ENDSIG ) { // if a comment is present, search the ENDSIG constant, starting at the end of the zip file byte[] endsig = ByteArrayHelper.toByteArray((int)ZipConstants.ENDSIG); long endsigPos = raFile.lastPosOf(endsig); if( endsigPos==-1 ) { throw new ZipException("expected ENDSIC not found (marks the beginning of the central directory at end of the zip file)"); } else { this.dirOffsetPos = endsigPos+16; short commentLength = raFile.readShort( this.dirOffsetPos + 4 ); this.comment = new String( raFile.readByteArray( this.dirOffsetPos+6, commentLength ) ); } } }
byte[] fileNameBytes = raFile.readByteArray( fileOffset + 46, fileNameLength ); this.fileName = new String( fileNameBytes, AesZipFileDecrypter.charset ); if( LOG.isLoggable(Level.FINE) ) { byte[] efhid = raFile.readByteArray( this.extraFieldOffset, 2 ); if( efhid[0]!=0x01 || efhid[1]!=(byte)0x99 ) { this.extraFieldOffset = localHeaderOffset+30+fileNameLength; throw new ZipException("extra field is of length 0 - this is probably not a WinZip AES encrypted entry"); efhid = raFile.readByteArray( extraFieldOffset, 2); if( efhid[0]==0x01 && efhid[1]==(byte)0x99 ) { this.isAesEncrypted = true;
byte[] fileNameBytes = raFile.readByteArray( fileOffset + 46, fileNameLength ); this.fileName = new String( fileNameBytes, AesZipFileDecrypter.charset ); if( LOG.isLoggable(Level.FINE) ) { byte[] efhid = raFile.readByteArray( this.extraFieldOffset, 2 ); if( efhid[0]!=0x01 || efhid[1]!=(byte)0x99 ) { this.extraFieldOffset = localHeaderOffset+30+fileNameLength; throw new ZipException("extra field is of length 0 - this is probably not a WinZip AES encrypted entry"); efhid = raFile.readByteArray( extraFieldOffset, 2); if( efhid[0]==0x01 && efhid[1]==(byte)0x99 ) { this.isAesEncrypted = true;
byte[] salt = raFile.readByteArray(cryptoHeaderOffset, 16); byte[] pwVerification = raFile.readByteArray(cryptoHeaderOffset + 16, 2); if (LOG.isLoggable(Level.FINEST)) { LOG.finest("\n" + cde.toString()); 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); raFile.readByteArray(storedMac, 10); byte[] calcMac = decrypter.getFinalAuthentication(); if (LOG.isLoggable(Level.FINE)) {
byte[] salt = raFile.readByteArray( cryptoHeaderOffset, 16 ); byte[] pwVerification = raFile.readByteArray( cryptoHeaderOffset+16, 2 ); 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 ); raFile.readByteArray(storedMac,10); byte[] calcMac = decrypter.getFinalAuthentication(); if( LOG.isLoggable(Level.FINE) ) {
byte[] salt = raFile.readByteArray( cryptoHeaderOffset, 16 ); byte[] pwVerification = raFile.readByteArray( cryptoHeaderOffset+16, 2 ); 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 ); raFile.readByteArray(storedMac,10); byte[] calcMac = decrypter.getFinalAuthentication(); if( LOG.isLoggable(Level.FINE) ) {
byte[] salt = raFile.readByteArray(cryptoHeaderOffset, 16); byte[] pwVerification = raFile.readByteArray(cryptoHeaderOffset + 16, 2); if (LOG.isLoggable(Level.FINEST)) { LOG.finest("\n" + cde.toString()); 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); zos.finish(); byte[] storedMac = new byte[10]; raFile.readByteArray(storedMac, 10); byte[] calcMac = decrypter.getFinalAuthentication(); if (LOG.isLoggable(Level.FINE)) {
byte[] fileNameBytes = raFile.readByteArray( fileOffsetPos+4, fileNameLength ); long nextFileOffset = raFile.getFilePointer(); String fileName = new String( fileNameBytes, charset );
byte[] fileNameBytes = raFile.readByteArray( fileOffsetPos+4, fileNameLength ); long nextFileOffset = raFile.getFilePointer(); String fileName = new String( fileNameBytes, charset );