Page 1 of 1

Opening password protected files

Posted: Wed Oct 24, 2018 6:08 pm
by jPV
I just can't seem to be able to open password protected PDF files. Is there some tricks, requirements, certain formats that's supported, or what could be wrong? I've tried to download some test files from Internet, and also tried to create an encrypted file with Preview under OSX, but can't seem to get any of them open. I've tried to open files under MorphOS and OSX 10.5.8, and fails on both...

Here's one test:

Code: Select all

@REQUIRE "polybios"
f$="pdfpwtest.pdf"
If Not Exists(f$)
    ; Download a test file from http://www.novapdf.com/kb/pdf-example-files-created-with-novapdf-138.html
    ; The password should be "test"
    DownloadFile("http://www.novapdf.com/uploads/novapdf_en/media_items/pdf-example-password.original.pdf", {File=f$})
EndIf
If Exists(f$)
    pdf.OpenDocument(1, f$, {Password = "test"}) ; <- Fails here always
    PDF_DOCUMENT=pdf.GetObjectType()
    pdfpages=GetAttribute(PDF_DOCUMENT, 1, #PDFATTRPAGES)
    DebugPrint(pdfpages)
EndIf

Re: Opening password protected files

Posted: Fri Oct 26, 2018 10:57 pm
by airsoftsoftwair
Works on Windows so it could be an endian issue if it fails on all PPC systems but works on x86... I'll try to fix it for the next version.

Re: Opening password protected files

Posted: Tue Nov 06, 2018 11:51 am
by Juan Carlos
airsoftsoftwair wrote: Fri Oct 26, 2018 10:57 pm Works on Windows so it could be an endian issue if it fails on all PPC systems but works on x86... I'll try to fix it for the next version.
Neither it works for 68k, only in Windows.

Re: Opening password protected files

Posted: Wed Nov 07, 2018 5:42 pm
by airsoftsoftwair
Well, 68k is big endian as well so this just confirms my theory. The best test would be to compare the behaviour on PPC Linux/macOS to the behaviour on x86 Linux/macOS. If it works on x86 Linux/macOS but fails on PPC Linux/macOS, then we can be almost certain it's an endian issue. Any volunteers? :)

Re: Opening password protected files

Posted: Wed Nov 07, 2018 6:59 pm
by jPV
Yes, I now tested that it works on Intel Mac, but doesn't work on PPC Mac.

Re: Opening password protected files

Posted: Sun Nov 11, 2018 10:19 pm
by airsoftsoftwair
That's very suspicious :)

Re: Opening password protected files

Posted: Tue May 07, 2019 9:50 pm
by airsoftsoftwair

Code: Select all

- Fix [BigEndian]: Password-protected PDFs couldn't be opened on big endian architectures because of
  an endian issue in the encryption key generator in PDFium; when will people finally learn to write
  endian-independent code?