Encryption/Security Seems To Not Work

If you are a C/C++/C# developer and have any questions about using our products from your application here is the place to post them.
Post Reply
Jim Vollmer
Posts: 13
Joined: Tue Feb 22 2005
Location: California

Encryption/Security Seems To Not Work

Post by Jim Vollmer »

I am using the evaluation copy of PDF Converter version 2.50. (Professional I hope!)
I am using the DLL interface in C++ MSVC 6.0.

During setup fot he print job I do the following calls (pseudo code):

EnablePrinter(hPDF, "Evaluation Version Developer" ,
"07EFCDAB0100010058EC6E6E6.............");

SetFileNameOptions( hPDF, NoPrompt + ... + EncryptDocument);

SetOwnerPassword(hPDF,"password");
SetUserPassword(hPDF,"user password");
SetPermissions(hPDF,-64 + (16 + 4));

Please note: SetOwnerPassword, SetUserPassword, and SetPermissions all do not have any return value.

Result:
A PDF file is being generated.
The PDF file displays appropriately in Adobe Reader 7.0.
But when I examine the Security Tab, it saids no security is present.

I would expect the following:
1) Security to be present.
2) 40 bit encryption (EncryptDocument)
3) A master password ("password")
4) A user password ("user password");
5) Permission to print
6) Permission to copy to clipboard
7) No permission to modify
8) No permission to annotate

What am I doing wrong?

Thank you
Jim Vollmer
Posts: 13
Joined: Tue Feb 22 2005
Location: California

Post by Jim Vollmer »

I am continuing to explore:

I am using the sequence
EnablePrinter (successful)
SetLicenseKeyA (successful)
EncryptPDFDocument128 (fails)

Calling GetLastErrorMsg after EncryptPDFDocument 128 returns "Operation completed Successfully".

It feels like this is not the Professional Evaluation ...

How can I determine if this is the Professional Evaluation version?
Jim Vollmer
Posts: 13
Joined: Tue Feb 22 2005
Location: California

Post by Jim Vollmer »

I uninstalled all Amyuni.
I edited the registry to remove all remaining instances of "Amyuni".
>> Please note: there were still a number of instances after uninstall! <<
I downloaded the latest distribution, which is now 2.50a.
I installed selecting evaluation + developer + professional.

I then modified my company and license strings and rebuilt my module.

I now have: EnablePrinter(hPrinter, "Evaluation Version Developer Pro",
"07EFCDAB010001001A62D63A7A374ADFC98E5C771E417CBCF622CE145
AA431E6CCCF852963C57AE96ECB09167E3050FEC9FA4879FFEB40E4087C
394B8B5FB0A19A8C3A1F5877ECDC2876FA965C7E3593F42639234E76372
F9D0BCC451E3EC35A34CD77B5A61C16FEE831CFF46D3AEDE4CCCC58AE
BAFF2A");

Now Encryption and the security work inline.

But SetLicenseKeyA fails, it used to work.

Why would SetLicenseKeyA now fail?

Thank you
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

SetLicenseKeyA is supposed to work with version 2.50a, please check that it is properly declared.

Hope this helps.
Jim Vollmer
Posts: 13
Joined: Tue Feb 22 2005
Location: California

Post by Jim Vollmer »

Dear Joan,

Thank you for your reply.

Of course I am using the correct declaration for SetLicenseKeyA,
I am including your .h file for all declarations.

This function was issuing a successful return code before I uninstalled 2.50
and installed 2.50a. The only difference is the company and license key
values. But these same values are used by EnablePrinter.

So why is it failing?
How do I get a usable error code?

Thank you
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hi Jim,

The PDF Convert basically has to methods to encrypt a PDF document.

One - when the document is being generated
Two - take an existing PDF document and encrypt it.

Below are (pseudo code) snippets of each process.
1-
OwnerPassword = "owner"
UserPassword = "user"
Permissions = -64 + 4
SetFileNameOptions
EnablePrinter
Print_Something()

2-
SetLicenseKey
Open a document
Encrypt
Save

Can you elaborate on what method you are using?
Jim Vollmer
Posts: 13
Joined: Tue Feb 22 2005
Location: California

Post by Jim Vollmer »

Dear Jose,

I was initially attempting to enable encrypt while creating the PDF file.
That was failing because I was not using a professional installation.

Reacing a dead end, I attempted to encrypt the PDF file (after the fact) using SetLicenseKeyA then EncryptPDFDocument128.
When I did this (2.50 no pro) SetLicenseKeyA returned a success value and EncryptPDFDocument128 probably did not work.

I then uninstalled 2.50, downloaded 2.50a eval and installed 2.50a as pro. I updated the "company" and "license" strings in my code.
When I attempted to repeat my last test SetLicenseKeyA failed. (unexpected)

To recover I went back to what I wanted to do in the first place, encrypt while creating the PDF file.
I tested this and was successful. (expected)

I then went back to try and get the encrypt PDF file to work immediately after creating the PDF file.
I called EnablePrinter (successful - this means that the license strings are corrrect), SetLicenseKeyA (failed) and EncryptPDFDocument128 (did not call because SetLicenseKeyA failed).

This does not make sense to me, I would have expected SetLicenseKeyA to be successful.

[Perhaps a pet peive of mine is that when failure is 0, instead of a usable errorcode]

Thank you
Jim Vollmer
Posts: 13
Joined: Tue Feb 22 2005
Location: California

Post by Jim Vollmer »

Dear Jose,

I was rereading your response.
You gave the sequence:
SetLicenseKey
Open a document
Encrypt
Save

How do I do "Open a document" and "Save" using the DLL interface?

The functions EncryptPDFDocument and EncryptPDFDocument128
are passed a filename, I would assume that the called function would open read encrypt write close the file.

Thank you
Jim Vollmer
Posts: 13
Joined: Tue Feb 22 2005
Location: California

Post by Jim Vollmer »

Dear Jose,

Thank you for the sample code.

I have read the PDF documentation and examined CDINTF250.H indepth looking for anything that appears to resemble these routines,
but I have been unsuccessful.

I wonder whether the suggested use of these undocumented functions, instead of EncryptPDFDocument and EncryptPDFDocument128,
implies that the documented functions do not work.

Can you tell us what other undocumented gems (necessary for normal use) are hidden there?

Thank you
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hi Jim,

Oops, I shouldn't have posted undocumented functions ( although these are useable)

Actually, the EncyptPDFDocument and EncryptPDFDocument128 functions do function correctly.

Below is a code snippet.
SetLicenseKeyA(m_szCode, m_szCompany);
// users are only allowed to print
EncryptPDFDocument( "c:\\temp\\fivepage.pdf", "ownerpass", "userpass", -64 + 4 );

If you are having trouble using the EncyptPDFDocument and EncryptPDFDocument128 functions, please send a email to support@amyuni.com and I'll take a look at your source code.

Thanks
Post Reply