Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > PDF

Notices

Reply
 
Thread Tools Search this Thread
Old 02-05-2009, 02:05 AM   #1
Jim Lester
Evangelist
Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.
 
Jim Lester's Avatar
 
Posts: 416
Karma: 14682
Join Date: May 2008
Location: SF Bay Area
Device: Nook HD, Nook for Windows 8
Determining if a PDF File is encrypted - the hard way

Because daesdaemar asked me to....

At the simplest level a PDF file is a collection of numbered objects. The objects themselves will tend to be streams of data ( such as the text run, graphics, or fonts) or dictionaries (structures which contained formatted data that describe the document).

If you look at PDF file you'll tend to see a lot of the following:
1 0 obj ...object data...
2 0 obj ...object data...
3 0 obj ...object data...

The objects themselves are organized by a cross reference table which lists the offsets for the document, and also has a trailer dictionary which list the object numbers important objects. One of those objects is the encryption dictionary, which must exist if the document is encrypted.

So, opening the PDF file in a good text editor (on the Mac I really like BareBones' TextWrangler) search for the string "/Encrypt" which if the file is encrypted should take you to the trailer dictionary which will look something like

Code:
<</Size 1910/Root 1426 0 R/Encrypt 1908 0 R/Info 1421 0 R/ID[<5081abdd2bdafc8f4748b307de4c8eff><29c91bdce6e8e5478905ab5d6890c7eb>]>>
If all you want to know is if the PDF file is encrypted, you can stop here - it is encrypted. If you want to know more about how it is encrypted you'll need to find the "Encryption Dictionary", so you'll want to note the object number from the trailer dictionary (1908 in the case above), and search for that object by starting at the beginning of the file and looking for "<object number> 0 obj" (ie "1908 0 obj")

Code:
1908 0 obj<</Filter/EBX_HANDLER/V 1/EBX_TITLE(Book Title)/>>
endobj
Of the most interest in the encryption dictionary will be the /Filter value, which will tell you which security handler was used to encrypt the file. Common values are:
  • Standard - Password Security
  • EBX_HANDLER - Adobe Content Server (aka SecurePDF - most eBooks)
  • PubSec - Certificate Security

For more information about the PDF File format get the PDF File Reference from http://www.adobe.com/devnet/pdf

You can look at section 3.5 in particular which contains the information about Encryption in PDFs

Last edited by Jim Lester; 02-05-2009 at 02:18 AM.
Jim Lester is offline   Reply With Quote
Old 08-28-2009, 06:25 PM   #2
caterpillar
Junior Member
caterpillar began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Aug 2009
Device: none
Sorry for wrong thread!
caterpillar is offline   Reply With Quote
Old 07-05-2010, 12:10 AM   #3
CeramicWeasel
Junior Member
CeramicWeasel began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Jul 2010
Device: none
Apologies for resurrecting this old topic, but i've found it extremely useful for some software development I've been doing and I had a question if anyone is able to answer it.

Is there a way to tell if a PDF document has been given an owner password but not a user password? I don't care what the passwords are, or about the content of the PDF, but I do need to know what *type* of password protections are on it.

It seems that encrypted PDFs get both an /O and /U entry in the /Filter section regardless of the type of password in use.
CeramicWeasel is offline   Reply With Quote
Old 07-05-2010, 06:10 AM   #4
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,147
Karma: 4792399
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Maybe pdftk or pdfinfo can help.
Jellby is online now   Reply With Quote
Old 07-12-2010, 04:20 PM   #5
Jim Lester
Evangelist
Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.
 
Jim Lester's Avatar
 
Posts: 416
Karma: 14682
Join Date: May 2008
Location: SF Bay Area
Device: Nook HD, Nook for Windows 8
Quote:
Originally Posted by CeramicWeasel View Post
Is there a way to tell if a PDF document has been given an owner password but not a user password? I don't care what the passwords are, or about the content of the PDF, but I do need to know what *type* of password protections are on it.

It seems that encrypted PDFs get both an /O and /U entry in the /Filter section regardless of the type of password in use.
If there is no user (/U) password the pad string is used in it's entirety. So if you generate the /U value using just the pad string (see algorithms 3.2 and 3.4 in the PDF spec), and it is the same as the /U value in the encrypt dict, then there is no user password.

Note that the algorithms will be slightly different for AES256 encrypted documents (came along with Acrobat 9).
Jim Lester is offline   Reply With Quote
Old 07-12-2010, 05:37 PM   #6
joblack
Wizard
joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.
 
Posts: 1,266
Karma: 1418786
Join Date: Jul 2006
Location: Somewhere on earth
Device: Kindle Paperwhite, Kindle DX, JBC, Onyx M92
Quote:
Originally Posted by Jim Lester View Post
If there is no user (/U) password the pad string is used in it's entirety. So if you generate the /U value using just the pad string (see algorithms 3.2 and 3.4 in the PDF spec), and it is the same as the /U value in the encrypt dict, then there is no user password.

Note that the algorithms will be slightly different for AES256 encrypted documents (came along with Acrobat 9).
The ineptpdf scripts can also decrypt password protected pdfs - no biggy
joblack is online now   Reply With Quote
Old 07-16-2010, 11:37 AM   #7
Jim Lester
Evangelist
Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.Jim Lester is less competitive than you.
 
Jim Lester's Avatar
 
Posts: 416
Karma: 14682
Join Date: May 2008
Location: SF Bay Area
Device: Nook HD, Nook for Windows 8
Quote:
Originally Posted by joblack View Post
The ineptpdf scripts can also decrypt password protected pdfs - no biggy
Yes but that doesn't help much unless Ceramic Weasel is is programming in python.
Jim Lester is offline   Reply With Quote
Old 07-19-2010, 07:22 AM   #8
joblack
Wizard
joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.joblack ought to be getting tired of karma fortunes by now.
 
Posts: 1,266
Karma: 1418786
Join Date: Jul 2006
Location: Somewhere on earth
Device: Kindle Paperwhite, Kindle DX, JBC, Onyx M92
Quote:
Originally Posted by Jim Lester View Post
Yes but that doesn't help much unless Ceramic Weasel is is programming in python.
Even if he programs in another programming language he can transfer the knowledge and routines from the Python scripts. He doesn't have to re-invent the wheel ^^.
joblack is online now   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What were the formulas for determining TOC lunixer Calibre 2 08-16-2010 11:14 AM
PDB file cannot be encrypted - but why? permutations Other formats 7 08-17-2009 10:14 AM
Hanlin V3 firmware V1.27 released - adds encrypted PDF support T-bag HanLin eBook 20 09-18-2008 06:02 AM
Encrypted PDF Converter? NatCh Sony Reader 11 04-30-2008 10:20 PM
Encrypted File System on a USB Thumbdrive Colin Dunstan Lounge 0 11-13-2004 07:08 AM


All times are GMT -4. The time now is 10:38 AM.


MobileRead.com is a privately owned, operated and funded community.