public void initEncryptedEntry() { setCrc(0); // CRC-32 / for encrypted files it's 0 as AES/MAC checks integritiy this.flag |= 1; // bit0 - encrypted // flag |= 8; // bit3 - use data descriptor this.primaryCompressionMethod = 0x63; byte[] extraBytes = new byte[11]; extraBytes = new byte[11]; // extra data header ID for AES encryption is 0x9901 extraBytes[0] = 0x01; extraBytes[1] = (byte)0x99; // data size (currently 7, but subject to possible increase in the // future) extraBytes[2] = 0x07; // data size extraBytes[3] = 0x00; // data size // Integer version number specific to the zip vendor extraBytes[4] = 0x02; // version number extraBytes[5] = 0x00; // version number // 2-character vendor ID extraBytes[6] = 0x41; // vendor id extraBytes[7] = 0x45; // vendor id // AES encryption strength - 1=128, 2=192, 3=256 extraBytes[8] = 0x03; // actual compression method - 0x0000==stored (no compression) - 2 bytes extraBytes[9] = (byte) (getMethod() & 0xff); extraBytes[10] = (byte) ((getMethod() & 0xff00) >> 8); setExtra(extraBytes); }
public void initEncryptedEntry() { setCrc(0); // CRC-32 / for encrypted files it's 0 as AES/MAC checks integritiy this.flag |= 1; // bit0 - encrypted // flag |= 8; // bit3 - use data descriptor this.primaryCompressionMethod = 0x63; byte[] extraBytes = new byte[11]; extraBytes = new byte[11]; // extra data header ID for AES encryption is 0x9901 extraBytes[0] = 0x01; extraBytes[1] = (byte)0x99; // data size (currently 7, but subject to possible increase in the // future) extraBytes[2] = 0x07; // data size extraBytes[3] = 0x00; // data size // Integer version number specific to the zip vendor extraBytes[4] = 0x02; // version number extraBytes[5] = 0x00; // version number // 2-character vendor ID extraBytes[6] = 0x41; // vendor id extraBytes[7] = 0x45; // vendor id // AES encryption strength - 1=128, 2=192, 3=256 extraBytes[8] = 0x03; // actual compression method - 0x0000==stored (no compression) - 2 bytes extraBytes[9] = (byte) (getMethod() & 0xff); extraBytes[10] = (byte) ((getMethod() & 0xff00) >> 8); setExtra(extraBytes); }
crc32.update(buffer, 0, read); tmpEntry.setCrc(crc32.getValue()); zos.finish(); byte[] storedMac = new byte[10];