You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2021/10/02 12:48:32 UTC
svn commit: r1893812 - in
/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption:
ProtectionPolicy.java SecurityHandler.java
Author: tilman
Date: Sat Oct 2 12:48:32 2021
New Revision: 1893812
URL: http://svn.apache.org/viewvc?rev=1893812&view=rev
Log:
PDFBOX-4892: reduce memory usage, as suggested by valerybokov
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/ProtectionPolicy.java
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/ProtectionPolicy.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/ProtectionPolicy.java?rev=1893812&r1=1893811&r2=1893812&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/ProtectionPolicy.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/ProtectionPolicy.java Sat Oct 2 12:48:32 2021
@@ -30,9 +30,9 @@ package org.apache.pdfbox.pdmodel.encryp
public abstract class ProtectionPolicy
{
- private static final int DEFAULT_KEY_LENGTH = 40;
+ private static final short DEFAULT_KEY_LENGTH = 40;
- private int encryptionKeyLength = DEFAULT_KEY_LENGTH;
+ private short encryptionKeyLength = DEFAULT_KEY_LENGTH;
private boolean preferAES = false;
/**
@@ -49,7 +49,7 @@ public abstract class ProtectionPolicy
{
throw new IllegalArgumentException("Invalid key length '" + l + "' value must be 40, 128 or 256!");
}
- encryptionKeyLength = l;
+ encryptionKeyLength = (short) l;
}
/**
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java?rev=1893812&r1=1893811&r2=1893812&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandler.java Sat Oct 2 12:48:32 2021
@@ -61,7 +61,7 @@ public abstract class SecurityHandler
{
private static final Log LOG = LogFactory.getLog(SecurityHandler.class);
- private static final int DEFAULT_KEY_LENGTH = 40;
+ private static final short DEFAULT_KEY_LENGTH = 40;
// see 7.6.2, page 58, PDF 32000-1:2008
private static final byte[] AES_SALT = { (byte) 0x73, (byte) 0x41, (byte) 0x6c, (byte) 0x54 };
@@ -69,7 +69,7 @@ public abstract class SecurityHandler
/**
* The length in bits of the secret key used to encrypt the document. Will become private in 3.0.
*/
- protected int keyLength = DEFAULT_KEY_LENGTH;
+ protected short keyLength = DEFAULT_KEY_LENGTH;
/** The encryption key that will used to encrypt / decrypt. Will become private in 3.0. */
protected byte[] encryptionKey;
@@ -676,7 +676,7 @@ public abstract class SecurityHandler
*/
public void setKeyLength(int keyLen)
{
- this.keyLength = keyLen;
+ this.keyLength = (short) keyLen;
}
/**