Bug 24752 - Fail to open encrypted PDF, which opens with Acrobat Reader.
Summary: Fail to open encrypted PDF, which opens with Acrobat Reader.
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-27 03:56 UTC by Alberto González Palomo
Modified: 2012-12-02 23:25 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Alberto González Palomo 2009-10-27 03:56:43 UTC
The file is an AES-256 encrypted PDF 1.7 file, available at:

http://www.bli.uni-saarland.de/lehre/Studienangebot%20Exi%202009-2010/Handout%20Management%20und%20Rechnungswesen%20WS%202009_2010.pdf

I have the correct password, and it opens in Acrobat Reader 9.2.

Evince asks for the password, but then rejects it as invalid.
In the console, it prints the following:

Error: Weird encryption info
Error: Incorrect password

This also happens with InkScape, although it does not seem to have any way of requesting the password.

Other unrelated PDF handling programs fail analogously: pdftk says "Error: Failed to open PDF file" even when given the correct password. I mention this because it would seem to point towards changes in the PDF format and not wrong implementation of previous versions of the specification.
Comment 1 Albert Astals Cid 2009-10-29 15:44:56 UTC
Yes, this uses AESV3 encryption that we do not support at the moment, help implementing this feature more than welcome
Comment 2 Alberto González Palomo 2009-10-30 00:19:57 UTC
Is there some document I can read to learn how to add a new encryption scheme?

I don't have much time for this, and actually I just need to open the files from that lecture so I can live with printing them to files from Acroreader, but at least I would like to implement detection of this encoding scheme so that we can print a more accurate error message, something like "this file is encrypted using AES-256, which libpoppler does not support yet".

Then I would look into adding the AES-256 decoding.
Are AES-128 and AES-192 supported?

Having specific pointers to source files and documentation pages (PDF spec or whatever) would greatly increase the odds of me being able to work on this. I don't have time to learn this whole codebase and specifications.
Comment 3 Brad Hards 2009-10-31 17:28:12 UTC
We don't really have documentation at this level. The applicable parts of poppler are in poppler/poppler/Decrypt.[cc,h] - you should be able to follow it from there. 

AES in that context is AES128.

The applicable section of the PDF spec is 3.5. You can get the information on the AES256 variant at: http://www.adobe.com/devnet/acrobat/pdfs/adobe_supplement_iso32000.pdf

It might help to compare that to the original crypto (RC4, AES128) parts of the spec, so you can see the code that needs to be changed / added. That is available from http://www.adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf

Good luck!

Brad
Comment 4 Brad Hards 2009-11-01 01:39:52 UTC
In addition to Decrypt.[cc,h], you'll also need to modify SecurityHandler.[cc,h] and add to the enum in Stream.h.

Comment 5 Jean-Philippe Fleury 2012-01-29 20:17:12 UTC
Ghostscript (version tested: GPL Ghostscript 9.04) and MuPDF support it. Maybe there's some code that can be used for Poppler. For example, see this commit adding AESv3 support for MuPDF:

http://www.ghostscript.com/pipermail/gs-cvs/2011-February/012272.html
Comment 6 madbiologist 2012-03-10 07:56:35 UTC
Alberto:  Are you able to open the file from this bug's description using recent versions of Evince and poppler?

I was unable to open the file from comment #9 of the Launchpad bug at https://bugs.launchpad.net/ubuntu/+source/poppler/+bug/472538 with Ubuntu 10.04 (which has libpoppler5 0.12.4-0ubuntu5.2) but I can open it with Ubuntu 12.04 "Precise Pangolin" beta 1, which uses the following packages.

Packages: evince 3.3.90-0ubuntu2
          libpoppler19 0.18.4-1ubuntu1
Comment 7 Alberto González Palomo 2012-03-10 12:13:53 UTC
(In reply to comment #6)
> Alberto:  Are you able to open the file from this bug's description using
> recent versions of Evince and poppler?
> 
> I was unable to open the file from comment #9 of the Launchpad bug at
> https://bugs.launchpad.net/ubuntu/+source/poppler/+bug/472538 with Ubuntu 10.04
> (which has libpoppler5 0.12.4-0ubuntu5.2) but I can open it with Ubuntu 12.04
> "Precise Pangolin" beta 1, which uses the following packages.
> 
> Packages: evince 3.3.90-0ubuntu2
>           libpoppler19 0.18.4-1ubuntu1

    Well, I have Ubuntu 11.10, and it still behaves exactly as
before.
    - evince 3.2.1-0ubuntu2.2
    - libpoppler13 0.16.7-2ubuntu2 

    I've tried running Ubuntu 12.04 Alpha 1 in a virtual machine,
and it's the same.
    - evince 3.2.1-1ubuntu1
    - libpoppler13 0.16.7-2ubuntu3

    Now I've run apt-get update+upgrade in the virtual machine,
which brings those packages to more or less the versions you have:
    - evince 3.3.90-0ubuntu3
    - libpoppler19 0.18.4-1ubuntu2

    At this point I still get the "Weird encryption info" error
(only visible when starting evince from the console), and it
fails to open the file with the correct password.
    I've opened it again with Acrobat Reader to make sure I was
not typing the wrong password. It works fine.

    I guess that if poppler understood the encryption scheme
it would not print the "Weird encryption info" message.

    Thanks for the follow-up.
Comment 8 Fabio D'Urso 2012-12-02 22:11:49 UTC
The file from the OP is no longer available, but we do support AES-256 now (starting from 0.19.0).
I guess this bug can be closed, please reopen if I'm missing something.
Comment 9 Alberto González Palomo 2012-12-02 23:07:22 UTC
(In reply to comment #8)
> The file from the OP is no longer available, but we do support AES-256 now
> (starting from 0.19.0).
> I guess this bug can be closed, please reopen if I'm missing something.

You are right, the original URL is no longer valid.
I've just tried with a local copy I had, and I still get the "Weird info" message from Evince.
I'll have to check that I'm using the correct password, but I'm quite sure I am.

I've put up a temporary copy of the file at:
http://matracas.org/tmp/Handout%20Management%20und%20Rechnungswesen%20WS%202009_2010.pdf

This is what happens when I start Evince from the command line:

00:02:34 ~$ evince /tmp/Handout\ Management\ und\ Rechnungswesen\ WS\ 2009_2010.pdf 
Error: Weird encryption info
Error: Incorrect password

Please note that it says "Incorrect password" even before I've typed anything in the "Enter password" dialog.
When I enter the password, I get again those two messages and the dialog comes up again.

I just tried again with acroread, gave the password, and it works.
Comment 10 Fabio D'Urso 2012-12-02 23:14:39 UTC
I've just tested and I don't get that message. Obviosuly I can't tell if it actually works because I don't have the password.
What poppler version do you have? Are you sure it is at least 0.19?
Comment 11 Alberto González Palomo 2012-12-02 23:17:32 UTC
(In reply to comment #10)
> I've just tested and I don't get that message. Obviosuly I can't tell if it
> actually works because I don't have the password.
> What poppler version do you have? Are you sure it is at least 0.19?

Could it be that Ubuntu 12.10 still has libpoppler 18, not 19?
The package is called "libpoppler19", but it says "Version: 0.18.4-1ubuntu2":

00:08:58 ~$ dpkg --status libpoppler19
Package: libpoppler19
Status: install ok installed
Multi-Arch: same
Priority: optional
Section: libs
Installed-Size: 2111
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Source: poppler
Version: 0.18.4-1ubuntu2
Depends: libc6 (>= 2.14), libfontconfig1 (>= 2.8.0), libfreetype6 (>= 2.2.1), libjpeg8 (>= 8c), liblcms2-2 (>= 2.2+git20110628-2), libpng12-0 (>= 1.2.13-4), libstdc++6 (>= 4.1.1), libtiff4
Pre-Depends: multiarch-support
Suggests: poppler-data
Description: PDF rendering library
 Poppler is a PDF rendering library based on Xpdf PDF viewer.
 .
 This package contains the shared core library.
Homepage: http://poppler.freedesktop.org/
Original-Maintainer: Loic Minier <lool@dooz.org>
00:09:18 ~$ evince --version
GNOME Document Viewer 3.4.0

The evince package does not list libpoppler (any version) as a dependency, though:
Depends: libatk1.0-0 (>= 1.12.4), libc6 (>= 2.4), libcairo2 (>= 1.10.0), libevince3-3 (= 3.4.0-0ubuntu1.4), libgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.31.8), libgnome-keyring0 (>= 2.22.2), libgtk-3-0 (>= 3.0.2), libice6 (>= 1:1.0.0), liblaunchpad-integration-3.0-1 (>= 0.1.17), libnautilus-extension1a (>= 1:2.91), libsm6, libx11-6, libxml2 (>= 2.7.4), evince-common (>= 3.4), evince-common (<< 3.5), gnome-icon-theme (>= 2.17.1), shared-mime-info

Also ldd on /usr/bin/evince does not list anything with "poppler" in its name.
Comment 12 Alberto González Palomo 2012-12-02 23:25:36 UTC
Hi! I just tried on an Ubuntu 13.04 system and yes, it works perfectly.

The evince version is 3.6.0, and the poppler package is called libpoppler28, which lists version 0.20.4-0ubuntu1.

Cheers!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.