Planet PDF Forum Archive

Planet PDF ForumWowsers! This is page is old, head to the LIVE Planet PDF Forum. It features more than 10 conferences, covering everything from beginner to in-depth developer and pre-press discussions. If you wish to continue... one & two archive covers 1999-2011 (160,000 pages).


New Forum | Previous | Next | (P-PDF) Developers


Topic: Decryption in PDF
Conf: (P-PDF) Developers, Msg: 68806
From: shahzad19_00
Date: 7/17/2002 03:50 PM

I am interested in knowing the details of PDF encryption details. I have developed some code and managed to find the user password, owner password and flag(allow printing, allow change document etc.). I have read the PDF SPECS for PDF encryption details. But those are pretty ambiguous to understand. The main idea behind the whole discussion in the PDF encryption topic is, "you just take the owner and user password string, do operations on it as described by PDF Specs and generate three keys (owner key, user key, global key)".

Now I have done all these thing from finding keys and checking flags of the PDF file. Now the point on which I need help is that I am unable to find the exact resultant string from those keys. As PDF SPECS says that you need key and input string to get output string from RC4 Algorithm. I am using RC4 algorithm for decryption of those keys. According to the PDF Specs, if we found all the bytes present in the user password or owner password equal to padding bytes then that password doesn't exists.

What I assume is that the algorithm that I am using for RC4 decryption is not working. Can any one help me in this regards,

The code for the RC4 Algorithm that I am using is written below.

Regards,

Shozi

=============================================
=========== RC4 =============================
=============================================
byte[] state = new byte[256];
public void prepareRC4Key ( byte[] abyte0 , int i , int j ) {
int k = 0 ;
int l = 0 ;
for ( int i1 = 0 ; i1 < 256 ; i1 ++ )
state [ i1 ] = (byte) i1 ;

x = 0 ;
y = 0 ;
for ( int j1 = 0 ; j1 < 256 ; j1 ++ ) {
l = abyte0 [ k + i ] + state [ j1 ] + l &0xff ;
byte byte0 = state[j1] ;
state [ j1 ] = state [ l ] ;
state [ l ] = byte0 ;
k = ( k + 1 ) % j ;
}
}

void rc4 ( byte[] buffer_ptr , int buffer_len )
{
int xorIndex;
short counter;

for(counter = 0; counter < buffer_len; counter ++) {
x = (x + 1) % 256;
y = (state[x] + y) % 256;
byte byte0 = state[x] ;
state [ x ] = state [ y ] ;
state [ y ] = byte0 ;

xorIndex = (state[x] + state[y]) % 256;

buffer_ptr[counter] ^= state[xorIndex];
}
}


PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Back to the past, 15 years ago! Open Publish 2002

Looking back to 2002, it's amazing how much of the prediction became a reality. Take a read and see what you think!

September 14, 2017
Platinum Sponsor





Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.

Features

Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.