Giter Site home page Giter Site logo

Support AES-256bit encryption about pdfpig HOT 13 CLOSED

uglytoad avatar uglytoad commented on August 14, 2024
Support AES-256bit encryption

from pdfpig.

Comments (13)

Numpsy avatar Numpsy commented on August 14, 2024 1

I don't have any RC4 encrypted files to hand to test with, but in case it's of any interest I tried encrypting a trivial PDF with the online tool @ http://www.pdfill.com/pdftool_encrypt.html and the resulting file is opened and identified as RC4 40bit by Acrobat Reader, but reading it with PdfPig throws

UglyToad.PdfPig.Exceptions.PdfDocumentFormatException : The dictionary did not contain a number with the key /Size. Dictionary way: .
Result StackTrace:	
at UglyToad.PdfPig.Util.DictionaryTokenExtensions.GetInt(DictionaryToken token, NameToken name)
   at UglyToad.PdfPig.CrossReference.TrailerDictionary..ctor(DictionaryToken dictionary)
   at UglyToad.PdfPig.CrossReference.CrossReferenceTableBuilder.Build(Int64 firstCrossReferenceOffset, ILog log)
   at UglyToad.PdfPig.Parser.FileStructure.CrossReferenceParser.Parse(IInputBytes bytes, Boolean isLenientParsing, Int64 crossReferenceLocation, IPdfTokenScanner pdfScanner, ISeekableTokenScanner tokenScanner)
   at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytes inputBytes, ISeekableTokenScanner scanner, IContainer container, Boolean isLenientParsing, String password)
   at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytes inputBytes, ParsingOptions options)
   at UglyToad.PdfPig.PdfDocument.Open(Stream stream, ParsingOptions options)

Sample file:
rc4.pdf

from pdfpig.

EliotJones avatar EliotJones commented on August 14, 2024

Thanks for the feedback, I'll look into adding AES support as the next feature.

I think I've got a couple of documents in my test set which are AES encrypted, do you have any documents you're able to share so I can check it works once I've implemented it?

from pdfpig.

EliotJones avatar EliotJones commented on August 14, 2024

Can you please give the attached nuget package a go and let me know if it works for your files please? I've added support for revision 5 encryption defined in this supplement: https://www.adobe.com/content/dam/acom/en/devnet/flashplayer/pdfs/adobe_supplement_iso32000.pdf

Currently the PDF version 2 specification defines an additional encryption level (revision 6) but the specification is being held hostage by ISO who want a vast amount of money for it, I could port the line by line version of the PDFBox algorithm for that level but I'd rather avoid it if this works.

PdfPig.0.0.6.1.zip

from pdfpig.

jonmiller1 avatar jonmiller1 commented on August 14, 2024

I'm testing it now. I do not have any documents that I can share at this time.

from pdfpig.

jonmiller1 avatar jonmiller1 commented on August 14, 2024

I'm getting the error "Support for revision 6 encryption not supported"

from pdfpig.

EliotJones avatar EliotJones commented on August 14, 2024

OK, looks like revision 6 also needs to be implemented, I'll try to get round to it soon.

from pdfpig.

jonmiller1 avatar jonmiller1 commented on August 14, 2024

Thanks! I also noticed that I've got a lot of files that encrypted with 40-bit RC4 that don't open either. Is that cipher supported?

from pdfpig.

EliotJones avatar EliotJones commented on August 14, 2024

Hmm, I'm surprised the RC4 doesn't work, do you get a specific error, the details might be in the inner exception?

from pdfpig.

EliotJones avatar EliotJones commented on August 14, 2024

@Numpsy thanks, I didn't think to try using an online tool. I've tried a couple of documents from that site and they seem to have some problems with cross-reference table positions which I've fixed in the last commit, do you remember the password for the file you attached? I just want to check if it had a different problem to the one I think I resolved.

from pdfpig.

Numpsy avatar Numpsy commented on August 14, 2024

ah, sorry, forgot to say - the password should just be 'password'

from pdfpig.

EliotJones avatar EliotJones commented on August 14, 2024

I've found this tool https://www.sejda.com/encrypt-pdf which is capable of producing Revision 6 encrypted documents so can start an implementation soon. I've attached an example file for which the password is maltby.

encrypt-revision-6-maltby.pdf

from pdfpig.

EliotJones avatar EliotJones commented on August 14, 2024

Sorry for the delay in implementing this. I think it should now be working. Please try the attached package.

If you do encounter errors please try and post as many details as possible, particularly inner exceptions and stack traces.

PdfPig.0.0.6.34.1.zip

from pdfpig.

EliotJones avatar EliotJones commented on August 14, 2024

Are you happy to close this issue now? Hopefully the latest 0.0.7 version includes full encryption support but I've not had many documents to test against so just wanted to check if it's ok to close this issue.

from pdfpig.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.