/** * this library currently only supports 256bit keys * * @return keySize - 1=128bit | 2=192bit | 3=256bit */ public byte getEncryptionStrength() throws IOException { return raFile.readByte( getExtraFieldOffset() + 8 ); }
public void init(String password, int keySize) { salt = createSalt(keySize / 16); utils = new AESUtilsJCA(password, keySize, salt); }
public boolean isAesEncrypted() { return isEncrypted() && centralDirectoryEntry!=null && centralDirectoryEntry.isAesEncrypted(); }
/** copy all "non-compression" attributes */ public ExtZipEntry(ExtZipEntry entry) { super(entry.getName()); setCompressedSize(entry.getCompressedSize()); setSize(entry.getSize()); setComment(entry.getComment()); setTime(entry.getTime()); setMethod(entry.getMethod()); }
/** * @return position within zip file where the actual data of the entry (file) starts * (after encryption salt + pw data) */ public int getOffset() { return (int)(getLocalHeaderOffset() + getLocalHeaderSize() + getCryptoHeaderLength()); }
@Override public void encrypt(byte[] in, int length) { utils.cryptUpdate(in, length); utils.authUpdate(in, length); }
@Override public byte[] getFinalAuthentication() { return utils.getFinalAuthentifier(); } }
/** * Client is required to call this method after he added all entries so the final archive part is * written. */ public void close() throws IOException { zipOS.finish(); }
/** * perform pseudo "in-place" encryption */ public void decrypt( byte[] in, int length ) { int pos = 0; while( pos<in.length && pos<length ) { decryptBlock( in, pos, length ); pos += blockSize; } }
/** * perform pseudo "in-place" encryption */ public void encrypt( byte[] in, int length ) { int pos = 0; while( pos<in.length && pos<length ) { encryptBlock( in, pos, length ); pos += blockSize; } }
public CentralDirectoryEntry( ExtRandomAccessFile raFile, long fileOffset ) throws IOException { this.raFile = raFile; this.fileOffset = fileOffset; initFromRaFile(); }
public static byte[] toByteArray(int in,int outSize) { byte[] out = new byte[outSize]; byte[] intArray = toByteArray(in); for( int i=0; i<intArray.length && i<outSize; i++ ) { out[i] = intArray[i]; } return out; }
/** * * @param outFile * output file (aes encrypted zip file) */ public AesZipFileEncrypter(File outFile, AESEncrypter encrypter) throws IOException { zipOS = new ExtZipOutputStream(outFile); this.encrypter = encrypter; }
/** * @return position within zip file where the actual data of the entry (file) starts * (after encryption salt + pw data) */ public int getOffset() { return (int)(getLocalHeaderOffset() + getLocalHeaderSize() + getCryptoHeaderLength()); }
/** * this library currently only supports 256bit keys * * @return keySize - 1=128bit | 2=192bit | 3=256bit */ public byte getEncryptionStrength() throws IOException { return raFile.readByte( getExtraFieldOffset() + 8 ); }
public void init(String password, int keySize) { salt = createSalt(keySize / 16); utils = new AESUtilsJCA(password, keySize, salt); }
@Override public void decrypt(byte[] in, int length) { utils.authUpdate(in, length); utils.cryptUpdate(in, length); }
@Override public byte[] getFinalAuthentication() { return utils.getFinalAuthentifier(); } }
/** * Client is required to call this method after he added all entries so the final archive part is * written. */ public void close() throws IOException { zipOS.finish(); }
/** * perform pseudo "in-place" encryption */ public void decrypt( byte[] in, int length ) { int pos = 0; while( pos<in.length && pos<length ) { decryptBlock( in, pos, length ); pos += blockSize; } }