Author: jahewson
Date: Mon Aug  4 19:23:47 2014
New Revision: 1615733

URL: http://svn.apache.org/r1615733
Log:
PDFBOX-538: Patch for CryptographyException on Adobe Distiller generated file, 
thanks to Luc Claes

Modified:
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java?rev=1615733&r1=1615732&r2=1615733&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java
 Mon Aug  4 19:23:47 2014
@@ -187,7 +187,7 @@ public final class StandardSecurityHandl
 
         int dicPermissions = encryption.getPermissions();
         int dicRevision = encryption.getRevision();
-        int dicLength = encryption.getLength()/8;
+        int dicLength = encryption.getVersion() == 1 ? 5 : 
encryption.getLength() / 8;
 
         //some documents may have not document id, see
         //test\encryption\encrypted_doc_no_id.pdf
@@ -568,10 +568,6 @@ public final class StandardSecurityHandl
                 digest = md.digest();
             }
         }
-        if( encRevision == 2 && length != 5 )
-        {
-            throw new IOException("Error: Expected length=5 actual=" + length 
);
-        }
 
         byte[] rc4Key = new byte[ (int)length ];
         System.arraycopy( digest, 0, rc4Key, 0, (int)length );
@@ -700,11 +696,6 @@ public final class StandardSecurityHandl
                 }
             }
 
-            if( encRevision == 2 && length != 5 )
-            {
-                throw new IOException(
-                    "Error: length should be 5 when revision is two actual=" + 
length );
-            }
             System.arraycopy( digest, 0, result, 0, length );
         }
 


Reply via email to