pdfbox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Klink (Jira)" <j...@apache.org>
Subject [jira] [Commented] (PDFBOX-4660) Can't decrypt PDF when password contains special national characters
Date Fri, 27 Sep 2019 11:55:00 GMT

    [ https://issues.apache.org/jira/browse/PDFBOX-4660?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16939356#comment-16939356

Michael Klink commented on PDFBOX-4660:

Other than that ISO 32000-2 has clarified for the older encryption versions:
{panel:title=Section Algorithm 2: Computing a file encryption key in order to encrypt
a document (revision 4 and earlier)}
The password string is generated from host system codepage characters (or system scripts)
by first converting the string to *PDFDocEncoding*. If the input is Unicode, first convert
to a codepage encoding, and then to *PDFDocEncoding* for backward compatibility
To me this appears to imply that many _special national characters_ will eventually be mapped
to '?', many because of the reduction to *PDFDocEncoding* and some more due to the detour
via _a codepage encoding_ which depends on the computer the software is run on.

In particular, if you encrypt with a password with _special national characters_ which are
present in the local codepage and in *PDFDocEncoding* and someone in another Locale with a
different codepage on which those characters aren't present, that person cannot decrypt the

[~tilman] - thus, what you reproduced may still differ from what can be observed in [~fastcoretux]'

In other words, don't ever use non-ASCII characters in a password for a _revision 4 and earlier_
PDF encryption unless you want decryption trouble.

> Can't decrypt PDF when password contains special national characters
> --------------------------------------------------------------------
>                 Key: PDFBOX-4660
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4660
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Crypto
>    Affects Versions: 2.0.17
>            Reporter: Fastcore Tux
>            Priority: Major
> I tried to encrypt PDF by user password which contains national characters. Encryption
was successful but I can't open it and decrypt it in any PDF browser.
> Due to Cookbook example (https://pdfbox.apache.org/2.0/cookbook/encryption.html) it could
be tested by changing StandardProtectionPolicy instantiation.
> {code:java}
> StandardProtectionPolicy spp = new StandardProtectionPolicy("ěšč", "řžý", ap);
> {code}
> Maybe my usage is wrong... In this case please accept my apology.
> Thank you!

This message was sent by Atlassian Jira

To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org

View raw message