0

I already asked the first half of my question so for future references I recommend reading that question in order to fix my problem (I was suggested writing a new question based on the information i got from that question, click here). Roughly said, my problem is that PdfReader.ComputeUserPassword() returns null. It's caused by the library which isn't able to compute the user's password from an AES256 encrypted PDF file. This is the lib's code that returns null:

public byte[] ComputeUserPassword() {
    if (!encrypted || !ownerPasswordUsed) return null;
    return decrypt.ComputeUserPassword(password);
}

My question is, how can I compute the user's password from an AES256 encrypted PDF?

(Is it necessary to update from 5.5.13.1 to a 7.* version of itextsharp? This isn't relevant right now because the current version [v7.1.7] of itextsharp still doesn't support AES256 encryption when trying to obtain the user's password of an AES256 encrypted PDF file, as you can see in the "Edit"-part)

Edit:

I don't see any reason of updating to v7.* because AES256 encryption still isn't supported for computing the user's password (this hasn't changed from v7.1.1 to v7.1.7).

https://api.itextpdf.com/iText7/7.1.1/com/itextpdf/kernel/pdf/PdfReader.html#computeUserPassword--

public byte[] computeUserPassword()

Computes user password if standard encryption handler is used with Standard40, Standard128 or AES128 encryption algorithm.

Returns: user password, or null if not a standard encryption handler was used or if ownerPasswordUsed wasn't use to open the document.

JieBaef
  • 122
  • 1
  • 11
  • If you upgrade to the latest, does it fix it? – mjwills Jul 15 '19 at 12:30
  • the problem that comes with updating it to v7.* is that the entire lib changed and i cant access my used code the way i do right now so i will have to rewrite my entire project. That's what i try to bypass – JieBaef Jul 15 '19 at 12:34
  • Can you make a [mcve] with just the minimal part necessary to test this very specific code? Don't try and upgrade - just make a small little sample. Does it work? – mjwills Jul 15 '19 at 12:36
  • so i just ran into the first main issue of v7.* (atleast it feels like for me, did no research on it yet). If i open the pdf by using the user's password `PdfReader.IsOpenedWithFullPermission()` returns `true` tho it shouldn't. edit: i just manually checked the users permissions and they are restricted so that's not a problem. edit2: according to the doc it shouldn't happen the way it did (`true if the document was opened with the owner password or if it's not encrypted, false if the document was opened with the user password.`) – JieBaef Jul 15 '19 at 12:55
  • i just did research on ComputeUserPassword in v7.* and came across something that I'll add to the question as information – JieBaef Jul 15 '19 at 13:02
  • The procedure used for AES-256 encryption is considerably different from the procedures used by other encryption algorithms in PDFs. Thus, there probably simply is no easy way to retrieve the user password anymore for AES-256... – mkl Jul 19 '19 at 15:07

0 Answers0