Hi, thank you very much. I have now got some AESV2 encrypted PDF, that are created with Acrobat X. These currently crash in PoDoFo because they have multiple XRef streams and XRef streams are never encrypted. But in PdfParser::ReadObjectsInternal m_pEncrypt is set for these XRef objects. I have added a patch to skip all XRef objects in PdfParser::ReadObjectsInternal. With that AESV2 encryption from Acrobat X should work. Bye Andreas Am 09.03.2014 14:18, schrieb zyx:
Hello, I created a little test program for the encryption (see the attached test.cpp), which is testing all encryption algorithms. Your patch works as you said, it fixes AESv2 decryption and keeps the AESv3 unchanged (still broken). There is one change in behaviour, it exists with an exception for AESv3: PoDoFo encounter an error. Error: 8 ePdfError_InternalLogic Error Description: An internal error occurred. Callstack: #0 Error Source: .../src/base/PdfEncrypt.cpp:1314 Information: Error AES-decryption data finalinstead of failing silently, which is better in my opinion. This doesn't seem to fix decrypt of an AcroForm elements, but that might not be related to your changes at all (it didn't work even before). In any case, I committed your patch to trunk as revision 1583: http://sourceforge.net/p/podofo/code/1583 Thanks and bye, zyx --
Andreas Brzesowsky
dots Software GmbH http://www.dots.de
Amtsgericht (District Court): Berlin Charlottenburg HRB 65201
|
Index: src/base/PdfParser.cpp =================================================================== --- src/base/PdfParser.cpp (revision 1583) +++ src/base/PdfParser.cpp (working copy) @@ -980,6 +980,13 @@ pObject->SetLoadOnDemand( m_bLoadOnDemand ); try { pObject->ParseFile( m_pEncrypt ); + PdfObject* pObjType = pObject->IsDictionary() ? pObject->GetDictionary().GetKey( PdfName::KeyType ) : 0; + if( pObjType && pObjType->IsName() && pObjType->GetName() == "XRef" ) { + // Never add the XRef to m_vecObjects because if it has a stream it is not encrypted + // (So setting m_pEncrypt for it would throw exception if the stream is read later on.) + delete pObject; + continue; + } nLast = pObject->Reference().ObjectNumber(); /*
------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech
_______________________________________________ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users