aboutsummaryrefslogtreecommitdiffstats
path: root/poi/src
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-10-21 18:42:11 +0000
committerPJ Fanning <fanningpj@apache.org>2021-10-21 18:42:11 +0000
commite216997950365f8424b624a1f12e1f5f230eec24 (patch)
treea66b0ab581f03ff6e410b10f177e344235b2ff4b /poi/src
parent04c130b8d5d540f1cdfa553ddb1e55fbe532babd (diff)
downloadpoi-e216997950365f8424b624a1f12e1f5f230eec24.tar.gz
poi-e216997950365f8424b624a1f12e1f5f230eec24.zip
make max record sizes configurable
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894454 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src')
-rw-r--r--poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java29
1 files changed, 6 insertions, 23 deletions
diff --git a/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java b/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java
index 0acf5d8241..4df5540517 100644
--- a/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java
+++ b/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java
@@ -67,27 +67,9 @@ import org.w3c.dom.Document;
public class AgileEncryptor extends Encryptor {
- //arbitrarily selected; may need to increase
- private static final int DEFAULT_MAX_RECORD_LENGTH = 1_000_000;
- private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
-
private byte[] integritySalt;
private byte[] pwHash;
- /**
- * @param length the max record length allowed for AgileEncryptor
- */
- public static void setMaxRecordLength(int length) {
- MAX_RECORD_LENGTH = length;
- }
-
- /**
- * @return the max record length allowed for AgileEncryptor
- */
- public static int getMaxRecordLength() {
- return MAX_RECORD_LENGTH;
- }
-
protected AgileEncryptor() {}
protected AgileEncryptor(AgileEncryptor other) {
@@ -105,11 +87,12 @@ public class AgileEncryptor extends Encryptor {
int keySize = header.getKeySize()/8;
int hashSize = header.getHashAlgorithm().hashSize;
- byte[] newVerifierSalt = IOUtils.safelyAllocate(blockSize, MAX_RECORD_LENGTH)
- , newVerifier = IOUtils.safelyAllocate(blockSize, MAX_RECORD_LENGTH)
- , newKeySalt = IOUtils.safelyAllocate(blockSize, MAX_RECORD_LENGTH)
- , newKeySpec = IOUtils.safelyAllocate(keySize, MAX_RECORD_LENGTH)
- , newIntegritySalt = IOUtils.safelyAllocate(hashSize, MAX_RECORD_LENGTH);
+ int maxLen = CryptoFunctions.getMaxRecordLength();
+ byte[] newVerifierSalt = IOUtils.safelyAllocate(blockSize, maxLen)
+ , newVerifier = IOUtils.safelyAllocate(blockSize, maxLen)
+ , newKeySalt = IOUtils.safelyAllocate(blockSize, maxLen)
+ , newKeySpec = IOUtils.safelyAllocate(keySize, maxLen)
+ , newIntegritySalt = IOUtils.safelyAllocate(hashSize, maxLen);
r.nextBytes(newVerifierSalt); // blocksize
r.nextBytes(newVerifier); // blocksize
r.nextBytes(newKeySalt); // blocksize