PDFdev is a service provided by PDFzone.com | http://www.pdfzone.com _____________________________________________________________
I'm not really accustomed to working with 'low-order' or 'high-order' bytes .... what does this mean and what would I need to change in my example? Thanks (again), Gordon -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Mark Storer Sent: Friday, October 17, 2003 4:10 PM To: '[EMAIL PROTECTED]' Subject: RE: [PDFdev] Encryption (again) PDFdev is a service provided by PDFzone.com | http://www.pdfzone.com _____________________________________________________________ Think I got it. Here's the 'gotcha' portion of the 3.1 algorithm: 2. Treating the object number and generation number as binary integers, extend the original n-byte encryption key to n + 5 bytes by appending the low-order 3 bytes of the object number and the low-order 2 bytes of the generation number in that order, low-order byte first. (n is 5 unless the value of V in the encryption dictionary is greater than 1, in which case n is the value of Length divided by 8.) "Low-order byte first". You're writing it high-order byte first. Amazing what a fresh pair of eyeballs will get you. --Mark Storer Software Engineer Cardiff Software #include <disclaimer> typdef std::disclaimer<Cardiff> Discard; > -----Original Message----- > From: Gordon Campbell [mailto:[EMAIL PROTECTED] > Sent: Friday, October 17, 2003 2:42 PM > To: [EMAIL PROTECTED] > Subject: RE: [PDFdev] Encryption (again) > > > > PDFdev is a service provided by PDFzone.com | http://www.pdfzone.com > _____________________________________________________________ > > I've included my code with comments ... note this is written > in Progress (a > 4-GL) and it's bit/byte manipulation tools are weak. > > - assumg vrc4-orig memory allocation size is 5 bytes (first 5 bytes of > original key) > - assume L_KeyPtr memory allocation size is 10 bytes > - assume Object Number is 20 > - assume Generation Number is 0 > > Anyway .... > > /* Take first 5-bytes of original Rc4-Key ... */ > DO L_Loop = 1 TO GET-SIZE(vrc4-orig): > PUT-BYTE(L_KeyPtr,L_Loop) = GET-BYTE(vrc4-orig,l_Loop). > END. > > /* and then add the object number plus the generation number */ > PUT-BYTE( L_KeyPtr, 6) = 0. > PUT-BYTE( L_KeyPtr, 7) = 0. > PUT-BYTE( L_KeyPtr, 8) = ASC(CHR(14)). > PUT-BYTE( L_KeyPtr, 9) = 0. > PUT-BYTE( L_KeyPtr, 10) = 0. > > /* Now run the md5 hash against that 10 byte key - orig + obj + gen */ > L_Key = EncryptString(L_KeyPtr). > > /* Now take the first 10 bytes of the resulting md5 hash as > the new key */ > SET-SIZE(L_NewKey) = 0. > SET-SIZE(L_NewKey) = 10. > L_Byte = 1. > DO vmd5-loop = 1 TO 20 BY 2: > /* Since Progress returns a -1 when assigning ASC(CHR(0)) we need to > manually assign the null byte */ > IF SUBSTR(L_Key,vmd5-loop,2) = "00" THEN > PUT-BYTE(L_NewKey,L_Byte) = 0. > ELSE DO: > FIND FIRST HexArray WHERE HexArray.Hex-Val = > SUBSTR(L_Key,vmd5-loop,2). > PUT-BYTE(L_NewKey,L_Byte) = ASC(CHR(HexArray.chr-val)). > END. > > L_Byte = L_Byte + 1. > END. > > /* Now run ARC4 encryption with the 10 byte key */ > L_Encrypted = EnDeCrypt(L_Content, L_NewKey). > > > TIA, > Gordon > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Mark Storer > Sent: Friday, October 17, 2003 3:14 PM > To: '[EMAIL PROTECTED]' > Subject: RE: [PDFdev] Encryption (again) > > > > PDFdev is a service provided by PDFzone.com | http://www.pdfzone.com > _____________________________________________________________ > > > Step 2: > The 5 byte key from algorithm 3.2 has the three byte object > number "00 00 > 14" and gen number "00 00" appended to it. Run this through MD5 > > Step 3: > Only use the first five bytes of the MD5 hash from step 2. > > > Can you pst your code? I did, and someone else managed to point out a > rather subtle difference that I had overlooked a couple dozen times. > > > --Mark Storer > Software Engineer > Cardiff Software > #include <disclaimer> > typdef std::disclaimer<Cardiff> Discard; > > > > -----Original Message----- > > From: Gordon Campbell [mailto:[EMAIL PROTECTED] > > Sent: Thursday, October 16, 2003 2:56 PM > > To: [EMAIL PROTECTED] > > Subject: RE: [PDFdev] Encryption (again) > > > > > > > > PDFdev is a service provided by PDFzone.com | http://www.pdfzone.com > > _____________________________________________________________ > > > > I've done some more checking and if I remove everything from > > my page I don't > > get an error. But as soon as I add "BT ET" into my page I > > get the errors > > described. From this, I'm guessing that I'm probably (must > > be) generating > > the original key incorrectly .... but then, my passwords are working > > correctly. So that just leaves me with the definition of how > > to encrypt > > string data. > > > > Step 1: > > ------- > > Obtain Object Number (20) and Generation Number (0) > > > > Step 2: > > ------- > > Convert Obj/Gen to "00 00 00 00 14" and extend to original > > n-byte key (I'm > > assuming that this original key is determined in Algorithm > > 3.2 Step 7 -- can > > someone verify this) > > > > Step 3: > > ------- > > Run rc4 passing in "BT ET" as the text and the key from > Step 2 (above) > > > > > > Does this look correct? > > > > TIA, > > Gordon > > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] Behalf Of Mark Storer > > Sent: Thursday, October 16, 2003 10:29 AM > > To: '[EMAIL PROTECTED]' > > Subject: RE: [PDFdev] Encryption (again) > > > > > > > > PDFdev is a service provided by PDFzone.com | http://www.pdfzone.com > > _____________________________________________________________ > > > > The "in document" part of that message leads me to believe > that it's a > > structural problem with the document itself rather than > > something wrong with > > the page contents. > > > > When Acrobat runs into a structural problem it often won't > > open the doc (but > > not always). When there's something wrong with the page, the > > document will > > be openend, but the page will be blank. Which are you getting? > > > > If you hold down the 'control' key while clicking the okay > > button on that > > error message, you'll get another, more meaningful error > > message. This > > message is the string associated with the exception that was > > thrown. It may > > or may not be helpful to you. > > > > --Mark Storer > > Software Engineer > > Cardiff Software > > #include <disclaimer> > > typdef std::disclaimer<Cardiff> Discard; > > > > > > > -----Original Message----- > > > From: Gordon Campbell [mailto:[EMAIL PROTECTED] > > > Sent: Thursday, October 16, 2003 7:37 AM > > > To: [EMAIL PROTECTED] > > > Subject: [PDFdev] Encryption (again) > > > > > > > > > > > > PDFdev is a service provided by PDFzone.com | > http://www.pdfzone.com > > > _____________________________________________________________ > > > > > > Hello, > > > > > > I've gotten to the point in my project where I can verify > > > that I am creating > > > correct User and Master passwords ... and these are accepted > > > by Reader. > > > > > > But, I'm getting the error message 'unrecognized token' plus > > > a bunch of > > > binary data 'in document'. > > > > > > So I'm assuming that I'm not converting my text stream > > > correctly. I'll > > > outline what I'm doing and hopefully someone can point me > > in the right > > > direction. > > > > > > Assume the following: > > > Using Rev 2 of Standard Security Handler (40 Byte encryption) > > > Object ID = 20 > > > Generation Number = 0 > > > Original Key = 8E 8F 68 E7 C7 > > > My 10 digit encryption key would be: 8E 8F 68 E7 C7 00 00 14 00 00 > > > My page stream is: > > > > > > "BT" + CHR(13) > > > + "/F1 10 Tf" + CHR(13) > > > + "1 0 0 1 10 742 Tm" + CHR(13) > > > + "10 TL" + CHR(13) > > > + "(Hello World!) Tj" + CHR(13) > > > + "ET" + CHR(13) > > > > > > Questions: > > > - Is my 10 digit key correct? > > > - Should I be encrypted the entire string or each line > individually? > > > - Should I be encrypting CHR(13)? > > > - other than Page Streams what other items would I need to > > > encrypt? Assume > > > no images or embedded fonts etc ... a very basic PDF document. > > > > > > If you need more info, please let me know. I'm really > > > pulling my hair out > > > here. > > > > > > Thanks, > > > Gordon > > > > > > > > > > > > To change your subscription: > > > http://www.pdfzone.com/discussions/lists-pdfdev.html > > > > > > > To change your subscription: > > http://www.pdfzone.com/discussions/lists-pdfdev.html > > > > > > > > > > To change your subscription: > > http://www.pdfzone.com/discussions/lists-pdfdev.html > > > > To change your subscription: > http://www.pdfzone.com/discussions/lists-pdfdev.html > > > > > To change your subscription: > http://www.pdfzone.com/discussions/lists-pdfdev.html > To change your subscription: http://www.pdfzone.com/discussions/lists-pdfdev.html To change your subscription: http://www.pdfzone.com/discussions/lists-pdfdev.html
