diff --git a/libs/pplib/ChangeLog b/libs/pplib/ChangeLog index dc14799022..a9e6d8fa69 100644 --- a/libs/pplib/ChangeLog +++ b/libs/pplib/ChangeLog @@ -1,2 +1,6 @@ +2023-05-23 Luigi Scarso luigi.scarso@gmail.com + * sync with the upstrem repo.: + fixes decryption failure on unreadable perms (Paweł Jackowski) + 2020-04-18 Luigi Scarso luigi.scarso@gmail.com * Moved luatexdir/luapplib under libs/pplib. \ No newline at end of file diff --git a/libs/pplib/pplib-src/doc/_build/doctrees/environment.pickle b/libs/pplib/pplib-src/doc/_build/doctrees/environment.pickle index c4d657a111..5d5fcb14a4 100644 Binary files a/libs/pplib/pplib-src/doc/_build/doctrees/environment.pickle and b/libs/pplib/pplib-src/doc/_build/doctrees/environment.pickle differ diff --git a/libs/pplib/pplib-src/doc/_build/doctrees/ppapi-1.x.doctree b/libs/pplib/pplib-src/doc/_build/doctrees/ppapi-1.x.doctree index bd22032c65..54e4f6f3e3 100644 Binary files a/libs/pplib/pplib-src/doc/_build/doctrees/ppapi-1.x.doctree and b/libs/pplib/pplib-src/doc/_build/doctrees/ppapi-1.x.doctree differ diff --git a/libs/pplib/pplib-src/doc/_build/doctrees/ppapi-2.x.doctree b/libs/pplib/pplib-src/doc/_build/doctrees/ppapi-2.x.doctree index d8c91b48be..ddf23cd91c 100644 Binary files a/libs/pplib/pplib-src/doc/_build/doctrees/ppapi-2.x.doctree and b/libs/pplib/pplib-src/doc/_build/doctrees/ppapi-2.x.doctree differ diff --git a/libs/pplib/pplib-src/doc/_build/doctrees/ppcode.doctree b/libs/pplib/pplib-src/doc/_build/doctrees/ppcode.doctree index a33b506208..a8e4dba8cb 100644 Binary files a/libs/pplib/pplib-src/doc/_build/doctrees/ppcode.doctree and b/libs/pplib/pplib-src/doc/_build/doctrees/ppcode.doctree differ diff --git a/libs/pplib/pplib-src/doc/_build/doctrees/pplib.doctree b/libs/pplib/pplib-src/doc/_build/doctrees/pplib.doctree index 0d5e84fe5a..36be14515f 100644 Binary files a/libs/pplib/pplib-src/doc/_build/doctrees/pplib.doctree and b/libs/pplib/pplib-src/doc/_build/doctrees/pplib.doctree differ diff --git a/libs/pplib/pplib-src/doc/_build/doctrees/ppnew.doctree b/libs/pplib/pplib-src/doc/_build/doctrees/ppnew.doctree index 5c152d321a..f79b5923a5 100644 Binary files a/libs/pplib/pplib-src/doc/_build/doctrees/ppnew.doctree and b/libs/pplib/pplib-src/doc/_build/doctrees/ppnew.doctree differ diff --git a/libs/pplib/pplib-src/doc/_build/html/_sources/ppapi-2.x.rst.txt b/libs/pplib/pplib-src/doc/_build/html/_sources/ppapi-2.x.rst.txt index 250cd8fcd3..c6779145a5 100644 --- a/libs/pplib/pplib-src/doc/_build/html/_sources/ppapi-2.x.rst.txt +++ b/libs/pplib/pplib-src/doc/_build/html/_sources/ppapi-2.x.rst.txt @@ -677,15 +677,14 @@ It is a common practise to *protect* documents with an empty password. Such docu for a password), but some features (eg. printing) may restricted by the application. When ``pplib`` detects encryption, it follows Acrobat approach and first tries an empty password. If it succeeds, ``pplib`` proceeeds normally, providing -an access to decrypted strings and streams, as if they weren't ciphered. If the document is protected with non-empty password, ``pplib`` gives -a way to provide a password and proceed. Until you provide a password, ``ppdoc`` object returned by ``ppdoc_load()`` function has all object wntries -set to ``null``. +an access to decrypted strings and streams, as if they weren't ciphered. If the document is protected with non-empty password, you have to call +``ppdoc_crypt_pass()``. Until you provide a password, ``ppdoc`` object returned by ``ppdoc_load()`` function has all object entries set to ``null``. -After loading a document you should check encryption status with:: +Once the document is loaded, encryption status can be checked with:: ppcrypt_status ppdoc_crypt_status (ppdoc *pdf); -``ppcrypt_status`` (integer) may have the following values: +``ppcrypt_status`` (enum) may have the following values: ``PPCRYPT_NONE`` - no encryption, go ahead ``PPCRYPT_DONE`` - encryption present but password succeeded, go ahead @@ -697,10 +696,12 @@ If a password is needed, you can provide one with:: ppcrypt_status ppdoc_crypt_pass (ppdoc *pdf, const void *userpass, size_t userpasslength, const void *ownerpass, size_t ownerpasslength); -Well, yes, there are actually two passwords in encrypted documents. Relation between them is obscure to me, but enough -to know that having one of them is enough to decrypt the document. If you know the password, you probably mean -``userpass``, in which case you should put ``NULL`` as ``ownerpass``. The function returns ``PPCRYPT_DONE`` if the password -succeeds and the previous status otherwise. Your custom loader function may look like that:: +Providing one of two is enough to decrypt the document. +It is ok to use the same password for owner and user -- ``pplib`` will try both. + +The function returns ``PPCRYPT_DONE`` if the password succeeds and the previous crypt status otherwise. + +Your custom loader function may look like that:: ppdoc *pdf; pdf = ppdoc_load("file.pdf"); @@ -712,8 +713,7 @@ succeeds and the previous status otherwise. Your custom loader function may look case PPCRYPT_DONE: return pdf; case PPCRYPT_PASS: - if (ppdoc_crypt_pass(pdf, "dummy", 5, NULL, 0) == PPCRYPT_DONE || - ppdoc_crypt_pass(pdf, NULL, 0, "dummy", 5) == PPCRYPT_DONE) + if (ppdoc_crypt_pass(pdf, "dummy", 5, "dummy", 5) == PPCRYPT_DONE) return pdf; printf("sorry, password needed\n"); ppdoc_free(pdf); @@ -724,7 +724,7 @@ succeeds and the previous status otherwise. Your custom loader function may look return NULL; } -[If you get ``PPCRYPT_FAIL`` it might mean *I failed*, so treat as a bug.] +See ``pplib`` tests suite for a complete code. If you'd like to know what permissions are given/restricted to encrypted document:: @@ -751,6 +751,15 @@ In encrypted documents most of streams are encrypted. To check if a given stream Encryption is independent from compression, don't confuse with ``ppstream_compressed()`` +.. caution:: + Starting from ``pplib v2.10`` all passwords should be passed as ``UTF-8``. + Earlier PDF encryption algorithms (/V 1..4, PDF 1.7) were based on ``PdfDocEncoding``. + Newer algorithms (/V 5, PDF 1.8-2.0) expect Unicode encoded as ``UTF-8``. + ``pplib`` API now expects ``UTF-8`` and if opening documents with older encryption methods, + it tries to make a conversion to 8-bit encoding. In earlier versions ``pplib`` didn't + make any password preprocessing, treating them as raw byte arrays. + So in case of passwords with fancy characters, it may behave differently. + Pages ----- diff --git a/libs/pplib/pplib-src/doc/_build/html/_sources/ppcode.rst.txt b/libs/pplib/pplib-src/doc/_build/html/_sources/ppcode.rst.txt index ebe92465d8..e9f6dc7adb 100644 --- a/libs/pplib/pplib-src/doc/_build/html/_sources/ppcode.rst.txt +++ b/libs/pplib/pplib-src/doc/_build/html/_sources/ppcode.rst.txt @@ -95,7 +95,7 @@ v2.05 uint8_t instead of ppbyte in internals; ppbyte intent is "the most natural 8-bit integer", so it is 'char', but internally we almost always need uint8_t (char may be signed or not..) -TODO -==== -- external streams (egzotic) - +v2.10 +----- +Rework on encryption; algorithms /V5 /R6. +Passwords passed to ppdoc_crypt_pass() should be UTF-8 (backward incompatible). diff --git a/libs/pplib/pplib-src/doc/_build/html/genindex.html b/libs/pplib/pplib-src/doc/_build/html/genindex.html index 24eed9d3c2..4e8b364757 100644 --- a/libs/pplib/pplib-src/doc/_build/html/genindex.html +++ b/libs/pplib/pplib-src/doc/_build/html/genindex.html @@ -79,7 +79,7 @@