Skip to main content
Known Participant
June 15, 2016
Question

Adobe plug-in SDK. How to open a pdf document protected by custom security handler?

  • June 15, 2016
  • 11 replies
  • 5982 views

The encryption dictionary is as follow:

20 0 obj<</Filter /FOPN_foweb /V 2 /Length 128 ... ...>>endobj

I invoke the following codes to open the pdf document, but PDDocOpen causes an exception and the error code does not make sense.

DURING

     PDDoc pdDoc = PDDocOpen(fileNameWrite, fileSys, MyPDAuthProc, FALSE);

HANDLER

     ASErrorCode  errorCode = ASGetExceptionErrorCode();

END_HANDLER

I am using Adobe plug-in SDK. How to open a pdf document protected by custom security handler?

11 replies

Legend
June 24, 2016

Sadly I do not. As I have often said here, if you find out, please let us know. Last I heard it was $200.

Legend
June 20, 2016

Have you fully implemented BOTH the stream AND string decrypt procedures? Have you implemented the AuthorizeProc? Is your filter registered as MyFilter0 - it doesn't look like it (this should work but is a very poor name - please register and use a company prefix, for everyone's sake).

lrosenth
Adobe Employee
Adobe Employee
June 20, 2016

You may also want to open a formal support ticket with Adobe as this is getting into something in your code which we can’t necessary handle here.

Legend
June 18, 2016

Ok, if it complies to the standard you can indeed write a security handler. It must simply decrypt on demand in the appropriate callback which may be called many times. No assumptions can be made about the order of objects to be decrypted.

Legend
June 18, 2016

I think part of the confusion is your reference to Open. The fittest step is to encrypt the file, save it, and close it. Only then is opening relevant. Your questions all seem to be about decrypting, do you propose a different scheme for encrypting? Perhaps encrypting the whole PDF? If so, you cannot: refer to point 2 in my previous reply.

Known Participant
June 18, 2016

Not encrypt the whole PDF. I have created a encrypted PDF document by another app. It complies with the PDF standard, just encrypt the string objects and stream objects. I have to decrypt it by developing a Adobe plug-in.

Legend
June 18, 2016

More info: the SDK sample does not define a crypt filter, just uses standard security. This took some study to relearn. I believe this is deliberate, to stop developers releasing code using Adobe's sample encryption (hence, insecure)

Legend
June 18, 2016

So you want to make your own scheme? Why didn't you say so in the first post?? All your questions suggested you wanted to open the PDF you quoted in the first post i.e. a FileOpen secured file, secured with the FileOpen custom handler. Yes, you can create your own custom handler which both decrypts and encrypts.

1. You should register a developer prefix with Adobe so that your security handler is uniquely named.

2. Be sure you fully understand the PDF encryption model as described in the PDF Reference. You have to work within this, but the encryption method used is not limited.

3. I think the reference to RC4 is old. You are not limited to RC4.

4. You must create a PDCryptHandler with many callbacks to implement your security. Some will not be needed. It is complicated because there are many options, you won't need to support all of them.

5. There is a security handler example in the SDK.

Known Participant
June 18, 2016

Yes. I want to make my own scheme. I have built the security handler example in the SDK. But it does not explain how to handle the custom algorithm. Does it support the following scene?

1. Open the protected documnet

2. Adobe Reader passes the encrypted data to plug-in one object by one object

3. Plug-in decrypts the data

4. Plug-in passes the decrypted data back to Adobe Reader

5. Adobe Reader renders and displays the document

Legend
June 18, 2016

Ok but what you describe cannot work. Unless FileOpen have given you the source code of their plugin, or equivalent detail.

Known Participant
June 18, 2016

No, It is nothing to do with FileOpen. The example above is just an example. I have to know whether Adobe provides the mechanism to decrypt the custom algorithm or not. I can just find PDCryptNewCryptDataExProc. But it can just support RC4, but custom algorithm.

Legend
June 18, 2016

If you have used FileOpen's plugin to encrypt, use the same plug-in to decrypt.

Legend
June 16, 2016

You can't implement that handler yourself. That's the whole point. what good would a security method be if you could write a replacement and avoid it?

Legend
June 15, 2016

What exception? Please get the error string and report it. I'd expect an exception if you don't do the things an AuthProc MUST do. These are not optional.

Legend
June 15, 2016

If you have the information to process these files programmatically, I would expect you to have the full details on how to code the authorization procedure (MyPDAuthProc), to work with PDCryptGetAuthDataProc, and calling PDDocAuthorize. Obviously the information you had is secret in detail, but is this the essence of the information you have?

Known Participant
June 15, 2016

But when I invoke the following codes to open the pdf document, PDDocOpen causes an exception before I can code the authorization procedure (MyPDAuthProc).

ASBool MyPDAuthProc(PDDoc pdDoc)

{

     code here

     return TRUE;

}

DURING

     PDDoc pdDoc = PDDocOpen(fileNameWrite, fileSys, MyPDAuthProc, FALSE);

HANDLER

     ASErrorCode  errorCode = ASGetExceptionErrorCode();

END_HANDLER

lrosenth
Adobe Employee
Adobe Employee
June 15, 2016

Did you install the File Open plugin that implements that custom handler?