whitespace
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/745c0a4c Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/745c0a4c Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/745c0a4c Branch: refs/heads/master Commit: 745c0a4c0773c75e1b5322b322cc97a7e1a303f6 Parents: 5c53db1 Author: Stefan Bodewig <bode...@apache.org> Authored: Sun Dec 13 20:49:42 2015 +0100 Committer: Stefan Bodewig <bode...@apache.org> Committed: Sun Dec 13 20:49:42 2015 +0100 ---------------------------------------------------------------------- .../archivers/zip/PKWareExtraHeader.java | 12 +- .../archivers/zip/X0014_X509Certificates.java | 18 +-- .../zip/X0015_CertificateIdForFile.java | 18 +-- .../X0016_CertificateIdForCentralDirectory.java | 22 ++-- .../zip/X0017_StrongEncryptionHeader.java | 114 +++++++++---------- ...0019_EncryptionRecipientCertificateList.java | 18 +-- 6 files changed, 101 insertions(+), 101 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-compress/blob/745c0a4c/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java b/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java index 19e390d..9064c9d 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/PKWareExtraHeader.java @@ -24,14 +24,14 @@ import java.util.Map; /** * Base class for all PKWare strong crypto extra headers. - * + * * <p>This base class acts as a marker so you know you can ignore all * extra fields that extend this class if you are not interested in * the meta data of PKWare strong encryption.</p> * * <b>Algorithm IDs</b> - integer identifier of the encryption algorithm from * the following range - * + * * <ul> * <li>0x6601 - DES</li> * <li>0x6602 - RC2 (version needed to extract < 5.2)</li> @@ -46,10 +46,10 @@ import java.util.Map; * <li>0x6801 - RC4</li> * <li>0xFFFF - Unknown algorithm</li> * </ul> - * + * * <b>Hash Algorithms</b> - integer identifier of the hash algorithm from the * following range - * + * * <ul> * <li>0x0000 - none</li> * <li>0x0001 - CRC32</li> @@ -99,7 +99,7 @@ public abstract class PKWareExtraHeader implements ZipExtraField { /** * the algorithm id. - * + * * @return the PKWare AlgorithmId */ public int getCode() { @@ -149,7 +149,7 @@ public abstract class PKWareExtraHeader implements ZipExtraField { /** * the hash algorithm ID. - * + * * @return the PKWare hashAlg */ public int getCode() { http://git-wip-us.apache.org/repos/asf/commons-compress/blob/745c0a4c/src/main/java/org/apache/commons/compress/archivers/zip/X0014_X509Certificates.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X0014_X509Certificates.java b/src/main/java/org/apache/commons/compress/archivers/zip/X0014_X509Certificates.java index 2f8f637..0b067d8 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/X0014_X509Certificates.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/X0014_X509Certificates.java @@ -28,7 +28,7 @@ package org.apache.commons.compress.archivers.zip; * ignored in any other record. * * Note: all fields stored in Intel low-byte/high-byte order. - * + * * <pre> * Value Size Description * ----- ---- ----------- @@ -36,7 +36,7 @@ package org.apache.commons.compress.archivers.zip; * TSize 2 bytes Size of the store data * TData TSize Data about the store * </pre> - * + * * @NotThreadSafe */ public class X0014_X509Certificates extends PKWareExtraHeader implements ZipExtraField { @@ -45,7 +45,7 @@ public class X0014_X509Certificates extends PKWareExtraHeader implements ZipExtr /** * Get the header id. - * + * * @return the header id */ public ZipShort getHeaderId() { @@ -61,7 +61,7 @@ public class X0014_X509Certificates extends PKWareExtraHeader implements ZipExtr /** * Set the extra field data in the local file data - without Header-ID or * length specifier. - * + * * @param data * the field data to use */ @@ -71,7 +71,7 @@ public class X0014_X509Certificates extends PKWareExtraHeader implements ZipExtr /** * Get the length of the local data. - * + * * @return the length of the local data */ public ZipShort getLocalFileDataLength() { @@ -80,7 +80,7 @@ public class X0014_X509Certificates extends PKWareExtraHeader implements ZipExtr /** * Get the local data. - * + * * @return the local data */ public byte[] getLocalFileDataData() { @@ -95,7 +95,7 @@ public class X0014_X509Certificates extends PKWareExtraHeader implements ZipExtr /** * Set the extra field data in central directory. - * + * * @param data * the data to use */ @@ -106,7 +106,7 @@ public class X0014_X509Certificates extends PKWareExtraHeader implements ZipExtr /** * Get the central data length. If there is no central data, get the local * file data length. - * + * * @return the central data length */ public ZipShort getCentralDirectoryLength() { @@ -118,7 +118,7 @@ public class X0014_X509Certificates extends PKWareExtraHeader implements ZipExtr /** * Get the central data. - * + * * @return the central data if present, else return the local file data */ public byte[] getCentralDirectoryData() { http://git-wip-us.apache.org/repos/asf/commons-compress/blob/745c0a4c/src/main/java/org/apache/commons/compress/archivers/zip/X0015_CertificateIdForFile.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X0015_CertificateIdForFile.java b/src/main/java/org/apache/commons/compress/archivers/zip/X0015_CertificateIdForFile.java index 44295db..26fb806 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/X0015_CertificateIdForFile.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/X0015_CertificateIdForFile.java @@ -37,7 +37,7 @@ package org.apache.commons.compress.archivers.zip; * HashAlg 2 bytes Hash algorithm identifier. (inferred) * TData TSize Signature Data * </pre> - * + * * @NotThreadSafe */ public class X0015_CertificateIdForFile extends PKWareExtraHeader implements ZipExtraField { @@ -46,7 +46,7 @@ public class X0015_CertificateIdForFile extends PKWareExtraHeader implements Zip /** * Get the header id. - * + * * @return the header id */ public ZipShort getHeaderId() { @@ -61,7 +61,7 @@ public class X0015_CertificateIdForFile extends PKWareExtraHeader implements Zip private int rcount; private HashAlgorithm hashAlg; - + /** * Get record count. * @return @@ -81,7 +81,7 @@ public class X0015_CertificateIdForFile extends PKWareExtraHeader implements Zip /** * Set the extra field data in the local file data - without Header-ID or * length specifier. - * + * * @param data * the field data to use */ @@ -91,7 +91,7 @@ public class X0015_CertificateIdForFile extends PKWareExtraHeader implements Zip /** * Get the length of the local data. - * + * * @return the length of the local data */ public ZipShort getLocalFileDataLength() { @@ -100,7 +100,7 @@ public class X0015_CertificateIdForFile extends PKWareExtraHeader implements Zip /** * Get the local data. - * + * * @return the local data */ public byte[] getLocalFileDataData() { @@ -115,7 +115,7 @@ public class X0015_CertificateIdForFile extends PKWareExtraHeader implements Zip /** * Set the extra field data in central directory. - * + * * @param data * the data to use */ @@ -126,7 +126,7 @@ public class X0015_CertificateIdForFile extends PKWareExtraHeader implements Zip /** * Get the central data length. If there is no central data, get the local * file data length. - * + * * @return the central data length */ public ZipShort getCentralDirectoryLength() { @@ -138,7 +138,7 @@ public class X0015_CertificateIdForFile extends PKWareExtraHeader implements Zip /** * Get the central data. - * + * * @return the central data if present, else return the local file data */ public byte[] getCentralDirectoryData() { http://git-wip-us.apache.org/repos/asf/commons-compress/blob/745c0a4c/src/main/java/org/apache/commons/compress/archivers/zip/X0016_CertificateIdForCentralDirectory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X0016_CertificateIdForCentralDirectory.java b/src/main/java/org/apache/commons/compress/archivers/zip/X0016_CertificateIdForCentralDirectory.java index 2696c61..2ce7ef0 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/X0016_CertificateIdForCentralDirectory.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/X0016_CertificateIdForCentralDirectory.java @@ -38,7 +38,7 @@ package org.apache.commons.compress.archivers.zip; * HashAlg 2 bytes Hash algorithm identifier. (inferred) * TData TSize Data * </pre> - * + * * @NotThreadSafe */ public class X0016_CertificateIdForCentralDirectory extends PKWareExtraHeader implements ZipExtraField { @@ -47,7 +47,7 @@ public class X0016_CertificateIdForCentralDirectory extends PKWareExtraHeader im /** * Get the header id. - * + * * @return the header id */ public ZipShort getHeaderId() { @@ -70,7 +70,7 @@ public class X0016_CertificateIdForCentralDirectory extends PKWareExtraHeader im public int getRecordCount() { return rcount; } - + /** * Get hash algorithm. * @return @@ -78,11 +78,11 @@ public class X0016_CertificateIdForCentralDirectory extends PKWareExtraHeader im public HashAlgorithm getHashAlgorithm() { return hashAlg; } - + /** * Set the extra field data in the local file data - without Header-ID or * length specifier. - * + * * @param data * the field data to use */ @@ -92,7 +92,7 @@ public class X0016_CertificateIdForCentralDirectory extends PKWareExtraHeader im /** * Get the length of the local data. - * + * * @return the length of the local data */ public ZipShort getLocalFileDataLength() { @@ -101,7 +101,7 @@ public class X0016_CertificateIdForCentralDirectory extends PKWareExtraHeader im /** * Get the local data. - * + * * @return the local data */ public byte[] getLocalFileDataData() { @@ -116,7 +116,7 @@ public class X0016_CertificateIdForCentralDirectory extends PKWareExtraHeader im /** * Set the extra field data in central directory. - * + * * @param data * the data to use */ @@ -127,7 +127,7 @@ public class X0016_CertificateIdForCentralDirectory extends PKWareExtraHeader im /** * Get the central data length. If there is no central data, get the local * file data length. - * + * * @return the central data length */ public ZipShort getCentralDirectoryLength() { @@ -139,7 +139,7 @@ public class X0016_CertificateIdForCentralDirectory extends PKWareExtraHeader im /** * Get the central data. - * + * * @return the central data if present, else return the local file data */ public byte[] getCentralDirectoryData() { @@ -151,7 +151,7 @@ public class X0016_CertificateIdForCentralDirectory extends PKWareExtraHeader im /** * This should never be called for this header type. - * + * * @param data * the array of bytes. * @param offset http://git-wip-us.apache.org/repos/asf/commons-compress/blob/745c0a4c/src/main/java/org/apache/commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java b/src/main/java/org/apache/commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java index ca9c829..e271975 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/X0017_StrongEncryptionHeader.java @@ -32,13 +32,13 @@ package org.apache.commons.compress.archivers.zip; * AlgID 2 bytes Encryption algorithm identifier * Bitlen 2 bytes Bit length of encryption key (32-448 bits) * Flags 2 bytes Processing flags - * RCount 4 bytes Number of recipients. + * RCount 4 bytes Number of recipients. * HashAlg 2 bytes Hash algorithm identifier * HSize 2 bytes Hash size * SRList (var) Simple list of recipients hashed public keys - * + * * Flags - This defines the processing flags. - * + * * <ul> * <li>0x0007 - reserved for future use * <li>0x000F - reserved for future use @@ -51,30 +51,30 @@ package org.apache.commons.compress.archivers.zip; * same algorithm used for encrypting the file contents. * <li>0x8000 - reserved for future use * </ul> - * + * * RCount - This defines the number intended recipients whose * public keys were used for encryption. This identifies * the number of elements in the SRList. - * + * * see also: reserved1 - * + * * HashAlg - This defines the hash algorithm used to calculate * the public key hash of each public key used * for encryption. This field currently supports * only the following value for SHA-1 - * + * * 0x8004 - SHA1 - * + * * HSize - This defines the size of a hashed public key. - * + * * SRList - This is a variable length list of the hashed * public keys for each intended recipient. Each * element in this list is HSize. The total size of * SRList is determined using RCount * HSize. * </pre> - * + * * Password-based Extra Field 0x0017 in central header only. - * + * * <pre> * Value Size Description * ----- ---- ----------- @@ -89,9 +89,9 @@ package org.apache.commons.compress.archivers.zip; * * <b>Format</b> - the data format identifier for this record. The only value * allowed at this time is the integer value 2. - * + * * Password-based Extra Field 0x0017 preceding compressed file data. - * + * * <pre> * Value Size Description * ----- ---- ----------- @@ -110,17 +110,17 @@ package org.apache.commons.compress.archivers.zip; * VSize 2 bytes Size of password validation data * VData VSize-4 Password validation data * VCRC32 4 bytes Standard ZIP CRC32 of password validation data - * + * * IVData - The size of the IV should match the algorithm block size. * The IVData can be completely random data. If the size of * the randomly generated data does not match the block size * it should be complemented with zero's or truncated as * necessary. If IVSize is 0,then IV = CRC32 + Uncompressed * File Size (as a 64 bit little-endian, unsigned integer value). - * + * * Format - the data format identifier for this record. The only * value allowed at this time is the integer value 2. - * + * * ErdData - Encrypted random data is used to store random data that * is used to generate a file session key for encrypting * each file. SHA1 is used to calculate hash data used to @@ -130,66 +130,66 @@ package org.apache.commons.compress.archivers.zip; * the value 0x4000, then the ErdData field must be * decrypted using 3DES. If the value 0x4000 is not set, * then the ErdData field must be decrypted using AlgId. - * + * * Reserved1 - Reserved for certificate processing, if value is * zero, then Reserved2 data is absent. See the explanation * under the Certificate Processing Method for details on * this data structure. - * + * * Reserved2 - If present, the size of the Reserved2 data structure * is located by skipping the first 4 bytes of this field * and using the next 2 bytes as the remaining size. See * the explanation under the Certificate Processing Method * for details on this data structure. - * + * * VSize - This size value will always include the 4 bytes of the * VCRC32 data and will be greater than 4 bytes. - * + * * VData - Random data for password validation. This data is VSize * in length and VSize must be a multiple of the encryption - * block size. VCRC32 is a checksum value of VData. + * block size. VCRC32 is a checksum value of VData. * VData and VCRC32 are stored encrypted and start the * stream of encrypted data for a file. * </pre> - * - * + * + * * Reserved1 - Certificate Decryption Header Reserved1 Data: - * + * * <pre> * Value Size Description * ----- ---- ----------- * RCount 4 bytes Number of recipients. * </pre> - * + * * RCount - This defines the number intended recipients whose public keys were * used for encryption. This defines the number of elements in the REList field * defined below. - * - * + * + * * Reserved2 - Certificate Decryption Header Reserved2 Data Structures: - * + * * <pre> * Value Size Description * ----- ---- ----------- * HashAlg 2 bytes Hash algorithm identifier * HSize 2 bytes Hash size * REList (var) List of recipient data elements - * + * * HashAlg - This defines the hash algorithm used to calculate * the public key hash of each public key used * for encryption. This field currently supports * only the following value for SHA-1 - * + * * 0x8004 - SHA1 - * + * * HSize - This defines the size of a hashed public key * defined in REHData. - * - * REList - This is a variable length of list of recipient data. + * + * REList - This is a variable length of list of recipient data. * Each element in this list consists of a Recipient * Element data structure as follows: * </pre> - * + * * Recipient Element (REList) Data Structure: * * <pre> @@ -198,28 +198,28 @@ package org.apache.commons.compress.archivers.zip; * RESize 2 bytes Size of REHData + REKData * REHData HSize Hash of recipients public key * REKData (var) Simple key blob - * - * + * + * * RESize - This defines the size of an individual REList * element. This value is the combined size of the * REHData field + REKData field. REHData is defined by * HSize. REKData is variable and can be calculated * for each REList element using RESize and HSize. - * + * * REHData - Hashed public key for this recipient. - * + * * REKData - Simple Key Blob. The format of this data structure * is identical to that defined in the Microsoft * CryptoAPI and generated using the CryptExportKey() * function. The version of the Simple Key Blob * supported at this time is 0x02 as defined by * Microsoft. - * + * * For more details see https://msdn.microsoft.com/en-us/library/aa920051.aspx * </pre> - * + * * <b>Flags</b> - Processing flags needed for decryption - * + * * <ul> * <li>0x0001 - Password is required to decrypt</li> * <li>0x0002 - Certificates only</li> @@ -247,7 +247,7 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z /** * Get the header id. - * + * * @return the header id */ public ZipShort getHeaderId() { @@ -271,11 +271,11 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z // encryption data private byte ivData[]; private byte erdData[]; - + // encryption key private byte recipientKeyHash[]; private byte keyBlob[]; - + // password verification data private byte vData[]; private byte vCRC32[]; @@ -287,7 +287,7 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z public long getRecordCount() { return rcount; } - + /** * Get hash algorithm. * @return @@ -295,7 +295,7 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z public HashAlgorithm getHashAlgorithm() { return hashAlg; } - + /** * Get encryption algorithm. * @return @@ -303,11 +303,11 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z public EncryptionAlgorithm getEncryptionAlgorithm() { return algId; } - + /** * Set the extra field data in the local file data - without Header-ID or * length specifier. - * + * * @param data * the field data to use */ @@ -317,7 +317,7 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z /** * Get the length of the local data. - * + * * @return the length of the local data */ public ZipShort getLocalFileDataLength() { @@ -326,7 +326,7 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z /** * Get the local data. - * + * * @return the local data */ public byte[] getLocalFileDataData() { @@ -341,7 +341,7 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z /** * Set the extra field data in central directory. - * + * * @param data * the data to use */ @@ -352,7 +352,7 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z /** * Get the central data length. If there is no central data, get the local * file data length. - * + * * @return the central data length */ public ZipShort getCentralDirectoryLength() { @@ -364,7 +364,7 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z /** * Get the central data. - * + * * @return the central data if present, else return the local file data */ public byte[] getCentralDirectoryData() { @@ -376,7 +376,7 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z /** * Parse central directory format. - * + * * @param data * @param offset * @param length @@ -402,7 +402,7 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z /** * Parse file header format. (Password only?) - * + * * @param data * @param offset * @param length @@ -421,7 +421,7 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z int erdSize = ZipShort.getValue(data, offset + ivSize + 14); this.erdData = new byte[erdSize]; System.arraycopy(data, offset + ivSize + 16, this.erdData, 0, erdSize); - + this.rcount = ZipLong.getValue(data, offset + ivSize + 16 + erdSize); System.out.println("rcount: " + rcount); if (rcount == 0) { @@ -445,7 +445,7 @@ public class X0017_StrongEncryptionHeader extends PKWareExtraHeader implements Z System.arraycopy(data, offset + ivSize + 22 + erdSize + resize, this.vData, 0, vSize - 4); System.arraycopy(data, offset + ivSize + 22 + erdSize + resize + vSize - 4, vCRC32, 0, 4); } - + // validate values? } http://git-wip-us.apache.org/repos/asf/commons-compress/blob/745c0a4c/src/main/java/org/apache/commons/compress/archivers/zip/X0019_EncryptionRecipientCertificateList.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/X0019_EncryptionRecipientCertificateList.java b/src/main/java/org/apache/commons/compress/archivers/zip/X0019_EncryptionRecipientCertificateList.java index 2fad277..04b0904 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/X0019_EncryptionRecipientCertificateList.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/X0019_EncryptionRecipientCertificateList.java @@ -20,7 +20,7 @@ package org.apache.commons.compress.archivers.zip; /** * PKCS#7 Encryption Recipient Certificate List (0x0019) - * + * * This field MAY contain information about each of the certificates used in * encryption processing and it can be used to identify who is allowed to * decrypt encrypted files. This field should only appear in the archive extra @@ -44,7 +44,7 @@ package org.apache.commons.compress.archivers.zip; * details. Refer to the section in this document entitled * "Incorporating PKWARE Proprietary Technology into Your Product" for more * information.</b> - * + * * @NotThreadSafe */ public class X0019_EncryptionRecipientCertificateList extends PKWareExtraHeader implements ZipExtraField { @@ -53,7 +53,7 @@ public class X0019_EncryptionRecipientCertificateList extends PKWareExtraHeader /** * Get the header id. - * + * * @return the header id */ public ZipShort getHeaderId() { @@ -69,7 +69,7 @@ public class X0019_EncryptionRecipientCertificateList extends PKWareExtraHeader /** * Set the extra field data in the local file data - without Header-ID or * length specifier. - * + * * @param data * the field data to use */ @@ -79,7 +79,7 @@ public class X0019_EncryptionRecipientCertificateList extends PKWareExtraHeader /** * Get the length of the local data. - * + * * @return the length of the local data */ public ZipShort getLocalFileDataLength() { @@ -88,7 +88,7 @@ public class X0019_EncryptionRecipientCertificateList extends PKWareExtraHeader /** * Get the local data. - * + * * @return the local data */ public byte[] getLocalFileDataData() { @@ -103,7 +103,7 @@ public class X0019_EncryptionRecipientCertificateList extends PKWareExtraHeader /** * Set the extra field data in central directory. - * + * * @param data * the data to use */ @@ -114,7 +114,7 @@ public class X0019_EncryptionRecipientCertificateList extends PKWareExtraHeader /** * Get the central data length. If there is no central data, get the local * file data length. - * + * * @return the central data length */ public ZipShort getCentralDirectoryLength() { @@ -126,7 +126,7 @@ public class X0019_EncryptionRecipientCertificateList extends PKWareExtraHeader /** * Get the central data. - * + * * @return the central data if present, else return the local file data */ public byte[] getCentralDirectoryData() {