From 666557e67ce684c4bf05d14b58fe91320dd676a8 Mon Sep 17 00:00:00 2001 From: "valery.bokov" Date: Sat, 29 Aug 2026 18:21:17 +0200 Subject: [PATCH] use SecurityHandler.encryptDataRC4(byte[], byte[], OutputStream) method instead of encryptDataRC4(byte[], InputStream, OutputStream) --- .../pdfbox/pdmodel/encryption/StandardSecurityHandler.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java index 7b58f563408..8f04c78905a 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/StandardSecurityHandler.java @@ -16,7 +16,6 @@ */ package org.apache.pdfbox.pdmodel.encryption; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.math.BigInteger; @@ -888,7 +887,7 @@ else if (encRevision == REVISION_3 || encRevision == REVISION_4) { iterationKey[j] = (byte)(iterationKey[j] ^ i); } - ByteArrayInputStream input = new ByteArrayInputStream(result.toByteArray()); + byte[] input = result.toByteArray(); result.reset(); encryptDataRC4(iterationKey, input, result); } @@ -926,7 +925,7 @@ public byte[] computeOwnerPassword(byte[] ownerPassword, byte[] userPassword, byte[] paddedUser = truncateOrPad( userPassword ); ByteArrayOutputStream encrypted = new ByteArrayOutputStream(); - encryptDataRC4(rc4Key, new ByteArrayInputStream(paddedUser), encrypted); + encryptDataRC4(rc4Key, paddedUser, encrypted); if (encRevision == REVISION_3 || encRevision == REVISION_4) { @@ -938,7 +937,7 @@ public byte[] computeOwnerPassword(byte[] ownerPassword, byte[] userPassword, { iterationKey[j] = (byte)(iterationKey[j] ^ (byte)i); } - ByteArrayInputStream input = new ByteArrayInputStream( encrypted.toByteArray() ); + byte[] input = encrypted.toByteArray(); encrypted.reset(); encryptDataRC4(iterationKey, input, encrypted ); }