OpenPDF icon indicating copy to clipboard operation
OpenPDF copied to clipboard

"Unknown encryption type R = 5"

Open brettrowberry opened this issue 1 year ago • 9 comments

Is your feature request related to a problem? Please describe. Similar to #375, which resolved "R = 6" exceptions, I am getting "Unknown encryption type R = 5" with certain files.

Describe the solution you'd like Files with R = 5 encryption type supported.

Describe alternatives you've considered I could try PDFBox.

Your real name Brett Rowberry

Additional context Here's a file that can produce the exception r-equals-5.pdf.

brettrowberry avatar Aug 07 '24 21:08 brettrowberry

MKL implemented support for R=6 some time ago (one of the best additions to openPDF imho). However R=5 is a proprietary adobe extension which has been deprecated and should not be used. (Thats why it wasn't implemented) You are of course free to implement it - perhaps mkl can give you some pointers. Maybe it is only extending R=4 with AES256?

Lonzak avatar Aug 08 '24 07:08 Lonzak

@Lonzak already correctly explained that R=5 encryption is part of an Adobe extension to PDF that never became standard and only is mentioned as deprecated and forbidden to use in ISO 32000-2. In contrast to his assumption "Maybe it is only extending R=4 with AES256", though, the R=5 algorithm is more related to R=6 than R=4. The differences between R=5 and R=6 mostly are additional variable numbers of hashing rounds in the latter to make breaking the encryption harder for brute force and quantum approaches.

mkl-public avatar Aug 08 '24 09:08 mkl-public

In contrast to his assumption "Maybe it is only extending R=4 with AES256", though, the R=5 algorithm is more related to R=6 than R=4.

...was just a (wild) guess ;-)

Lonzak avatar Aug 08 '24 09:08 Lonzak

You are of course free to implement it

I'm going to keep getting PDFs with R = 5. So, either I'll have to:

  1. implement it as you suggest, or
  2. switch to PDFBox, which would be a pretty significant change to our code base.

brettrowberry avatar Aug 10 '24 05:08 brettrowberry

Let's pretend that I write a perfect PR adding R = 5 support and it's merged. How long would it take to get a new version out in Maven Central?

brettrowberry avatar Aug 10 '24 05:08 brettrowberry

@brettrowberry please submit that perfect PR adding R = 5 support. I am sure the new version would be available within reasonable time in Maven Central. I am also seeing this Unknown encryption type R = 5 error in production, however the percentage is not very large.

andreasrosdal avatar Aug 11 '24 14:08 andreasrosdal

@brettrowberry any progress on this?

melloware avatar Oct 23 '24 14:10 melloware

I am also encountering the Unknown Encryption type R=5 error. Can you fix this please? @brettrowberry

SirishaGorasa avatar Jan 23 '25 10:01 SirishaGorasa

I think we can safely say I'm not going to get around to doing this. Sorry!

brettrowberry avatar Apr 15 '25 15:04 brettrowberry