| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| private static final int[][] | |
| private static final int[] | |
| pack-priv static int | |
| private static final byte[] |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static byte[] | Returns: the byte array for xor obfuscationthe password password)Creates an byte array for xor obfuscation (method 1) |
| public static int | Returns: the xor keythe password password)Create the xor key for xor obfuscation, which is used to create the xor array (method 1) |
| public static int | Returns: the verifier (actually a short value)the password password)Create the verifier for xor obfuscation (method 1) |
| public static int | Returns: the hashed passwordthe password password)This method generates the xor verifier for word documents < 2007 (method 2). |
| public static byte[] | generateIv(HashAlgorithm hashAlgorithm, byte[] salt, byte[] blockKey, int blockSize)
2.3.4.12 Initialization Vector Generation (Agile Encryption) Initialization vectors are used in all cases for agile encryption. |
| public static byte[] | Returns: intermediate keythe hashed password byte passwordHash, HashAlgorithm the hash algorithm hashAlgorithm, byte[] the block key blockKey, int the key size keySize)2.3.4.11 Encryption Key Generation (Agile Encryption) The final hash data that is used for an encryption key is then generated by using the following method: H_final = H(H_n + blockKey) |
| public static byte[] | Returns: the padded hashthe to be truncated/filled hash byte array hash, int the size of the returned byte array size)Returns a new byte array with a truncated to the given size. |
| private static byte[] | Returns: the padded hashthe to be truncated/filled hash byte array hash, int the size of the returned byte array size)Returns a new byte array with a truncated to the given size. |
| private static byte[] | |
| public static Cipher | Returns: the requested cipherthe secret key key, CipherAlgorithm the cipher algorithm cipherAlgorithm, ChainingMode the chaining mode chain, byte[] the initialization vector (IV), can be null vec, int Cipher.DECRYPT_MODE or Cipher.ENCRYPT_MODE cipherMode)Initialize a new cipher object with the given cipher properties and no padding If the given algorithm is not implemented in the JCE, it will try to load it from the bouncy castle provider. |
| public static Cipher | Returns: the requested cipherthe secret key key, CipherAlgorithm the cipher algorithm cipherAlgorithm, ChainingMode the chaining mode chain, byte[] the initialization vector (IV), can be null vec, int Cipher.DECRYPT_MODE or Cipher.ENCRYPT_MODE cipherMode, String the padding (null = NOPADDING, ANSIX923Padding, PKCS5Padding, PKCS7Padding, ISO10126Padding, ...) padding)Initialize a new cipher object with the given cipher properties If the given algorithm is not implemented in the JCE, it will try to load it from the bouncy castle provider. |
| public static Mac | |
| public static int | |
| public static MessageDigest | |
| public static byte[] | Returns: the hashed passwordthe password password, HashAlgorithm the hash algorithm hashAlgorithm, byte[] the initial salt value salt, int the repetition count spinCount)2.3.4.7 ECMA-376 Document Encryption Key Generation (Standard Encryption) 2.3.4.11 Encryption Key Generation (Agile Encryption) The encryption key for ECMA-376 document encryption [ECMA-376] using agile encryption MUST be generated by using the following method, which is derived from PKCS #5: Password-Based Cryptography Version 2.0 [RFC2898]. |
| public static byte[] | Returns: the hashed passwordthe pasword password, HashAlgorithm the hash algorighm hashAlgorithm, byte[] the initial salt value salt, int the repetition count spinCount, boolean if true, the iterator is hashed before the n-1 hash value,
if false the n-1 hash value is applied first iteratorFirst)Generalized method for read and write protection hash generation. |
| public static void | |
| private static byte | |
| private static short | |
| public static void | |
| private static byte[] | Returns: the ansi bytesthe password password)The provided Unicode password string is converted to a ANSI string |
| public static String | xorHashPassword(String password)
This method generates the xored-hashed password for word documents < 2007. |
| public static String | xorHashPasswordReversed(String password)
Convenience function which returns the reversed xored-hashed password for further processing in word documents 2007 and newer, which utilize a real hashing algorithm like sha1. |
| DEFAULT_MAX_RECORD_LENGTH | back to summary |
|---|---|
| private static final int DEFAULT_MAX_RECORD_LENGTH | |
| ENCRYPTION_MATRIX | back to summary |
|---|---|
| private static final int[][] ENCRYPTION_MATRIX | |
| INITIAL_CODE_ARRAY | back to summary |
|---|---|
| private static final int[] INITIAL_CODE_ARRAY | |
| MAX_RECORD_LENGTH | back to summary |
|---|---|
| pack-priv static int MAX_RECORD_LENGTH | |
| PAD_ARRAY | back to summary |
|---|---|
| private static final byte[] PAD_ARRAY | |
| CryptoFunctions | back to summary |
|---|---|
| private CryptoFunctions() | |
| createXorArray1 | back to summary |
|---|---|
| public static byte[] createXorArray1(String password) Creates an byte array for xor obfuscation (method 1)
| |
| createXorKey1 | back to summary |
|---|---|
| public static int createXorKey1(String password) Create the xor key for xor obfuscation, which is used to create the xor array (method 1)
| |
| createXorVerifier1 | back to summary |
|---|---|
| public static int createXorVerifier1(String password) Create the verifier for xor obfuscation (method 1)
| |
| createXorVerifier2 | back to summary |
|---|---|
| public static int createXorVerifier2(String password) This method generates the xor verifier for word documents < 2007 (method 2). Its output will be used as password input for the newer word generations which utilize a real hashing algorithm like sha1.
| |
| generateIv | back to summary |
|---|---|
| public static byte[] generateIv(HashAlgorithm hashAlgorithm, byte[] salt, byte[] blockKey, int blockSize) 2.3.4.12 Initialization Vector Generation (Agile Encryption) Initialization vectors are used in all cases for agile encryption. An initialization vector MUST be generated by using the following method, where H() is a hash function that MUST be the same as specified in section 2.3.4.11 and a plus sign (+) represents concatenation:
| |
| generateKey | back to summary |
|---|---|
| public static byte[] generateKey(byte[] passwordHash, HashAlgorithm hashAlgorithm, byte[] blockKey, int keySize) 2.3.4.11 Encryption Key Generation (Agile Encryption) The final hash data that is used for an encryption key is then generated by using the following method: H_final = H(H_n + blockKey) where blockKey represents an array of bytes used to prevent two different blocks from encrypting to the same cipher text. If the size of the resulting H_final is smaller than that of PasswordKeyEncryptor.keyBits, the key MUST be padded by appending bytes with a value of 0x36. If the hash value is larger in size than PasswordKeyEncryptor.keyBits, the key is obtained by truncating the hash value.
| |
| getBlock0 | back to summary |
|---|---|
| public static byte[] getBlock0(byte[] hash, int size) Returns a new byte array with a truncated to the given size. If the hash has less than size bytes, it will be filled with 0-bytes
| |
| getBlock36 | back to summary |
|---|---|
| private static byte[] getBlock36(byte[] hash, int size) Returns a new byte array with a truncated to the given size. If the hash has less than size bytes, it will be filled with 0x36-bytes
| |
| getBlockX | back to summary |
|---|---|
| private static byte[] getBlockX(byte[] hash, int size, byte fill) | |
| getCipher | back to summary |
|---|---|
| public static Cipher getCipher(SecretKey key, CipherAlgorithm cipherAlgorithm, ChainingMode chain, byte[] vec, int cipherMode) Initialize a new cipher object with the given cipher properties and no padding If the given algorithm is not implemented in the JCE, it will try to load it from the bouncy castle provider.
| |
| getCipher | back to summary |
|---|---|
| public static Cipher getCipher(Key key, CipherAlgorithm cipherAlgorithm, ChainingMode chain, byte[] vec, int cipherMode, String padding) Initialize a new cipher object with the given cipher properties If the given algorithm is not implemented in the JCE, it will try to load it from the bouncy castle provider.
| |
| getMac | back to summary |
|---|---|
| public static Mac getMac(HashAlgorithm hashAlgorithm) | |
| getMaxRecordLength | back to summary |
|---|---|
public static int getMaxRecordLength()
| |
| getMessageDigest | back to summary |
|---|---|
| public static MessageDigest getMessageDigest(HashAlgorithm hashAlgorithm) | |
| hashPassword | back to summary |
|---|---|
| public static byte[] hashPassword(String password, HashAlgorithm hashAlgorithm, byte[] salt, int spinCount) 2.3.4.7 ECMA-376 Document Encryption Key Generation (Standard Encryption) The encryption key for ECMA-376 document encryption [ECMA-376] using agile encryption MUST be generated by using the following method, which is derived from PKCS #5: Password-Based Cryptography Version 2.0 [RFC2898]. Let H() be a hashing algorithm as determined by the PasswordKeyEncryptor.hashAlgorithm element, H_n be the hash data of the n-th iteration, and a plus sign (+) represent concatenation. The password MUST be provided as an array of Unicode characters. Limitations on the length of the password and the characters used by the password are implementation-dependent. The initial password hash is generated as follows: H_0 = H(salt + password) The salt used MUST be generated randomly. The salt MUST be stored in the PasswordKeyEncryptor.saltValue element contained within the \EncryptionInfo stream as specified in section 2.3.4.10. The hash is then iterated by using the following approach: H_n = H(iterator + H_n-1) where iterator is an unsigned 32-bit value that is initially set to 0x00000000 and then incremented monotonically on each iteration until PasswordKey.spinCount iterations have been performed. The value of iterator on the last iteration MUST be one less than PasswordKey.spinCount. For POI, H_final will be calculated by
| |
| hashPassword | back to summary |
|---|---|
| public static byte[] hashPassword(String password, HashAlgorithm hashAlgorithm, byte[] salt, int spinCount, boolean iteratorFirst) Generalized method for read and write protection hash generation. The difference is, read protection uses the order iterator then hash in the hash loop, whereas write protection uses first the last hash value and then the current iterator value
| |
| registerBouncyCastle | back to summary |
|---|---|
public static void registerBouncyCastle()
| |
| rotateLeft | back to summary |
|---|---|
| private static byte rotateLeft(byte bits, int shift) | |
| rotateLeftBase15Bit | back to summary |
|---|---|
| private static short rotateLeftBase15Bit(short verifier) | |
| setMaxRecordLength | back to summary |
|---|---|
public static void setMaxRecordLength(int length)
| |
| toAnsiPassword | back to summary |
|---|---|
| private static byte[] toAnsiPassword(String password) The provided Unicode password string is converted to a ANSI string
| |
| xorHashPassword | back to summary |
|---|---|
| public static String xorHashPassword(String password) This method generates the xored-hashed password for word documents < 2007. | |
| xorHashPasswordReversed | back to summary |
|---|---|
| public static String xorHashPasswordReversed(String password) Convenience function which returns the reversed xored-hashed password for further processing in word documents 2007 and newer, which utilize a real hashing algorithm like sha1. | |