EldoS | Feel safer!

Software components for data protection, secure storage and transfer

OpenPGP ActiveX - Trouble getting going

Posted: 06/29/2007 19:03:11
by Brandon Davis (Basic support level)
Joined: 06/29/2007
Posts: 2

I am evaluating the ActiveX OpenPGP product for automating some PGP related tasks, and I almost have it working but I feel like I am missing something simple. After executing the EncryptFile(), I have a PGP file, but when I attempt to decrypt the file using GPG or PGP Desktop, it says the secret key is not available for the file. Its almost as though it isn't picking the key I'm telling it to, but I can't say for sure. Here is the code I am using:

m.cInputFile = 'C:\temp\TestFile.txt'
m.cOutputFile = 'C:\temp\TestFile.txt.pgp'
m.cRecipientKey = 'johndoe@example.com'

&& Load keyring
oKeyRing = CREATEOBJECT('pgpbbox.ElPGPKeyRingX')
oKeyRing.LoadFromFiles('c:\gnupg\pubring.pkr', 'c:\gnupg\secring.skr', 0)

&& Lookup Recipient
m.nRecipientKey = oKeyRing.FindPublicKeyByEmailAddress(m.cRecipientKey, 1)

&& Initialize PGP Writer
oPGP = CREATEOBJECT('pgpbbox.ElPGPWriterX')
oPGP.EncryptionType = 0
oPGP.FileName = JUSTFNAME(m.cInputFile)
oPGP.Timestamp = DATETIME()
oPGP.Armor = .F.

&& Assign Recipient Key
oPGP.EncryptingKeys = CREATEOBJECT('pgpbbox.ElPGPKeyRingX')

&& Execute Encryption
oPGP.EncryptFile(m.cInputFile, m.cOutputFile)

Any ideas?
Posted: 06/30/2007 02:34:33
by Eugene Mayevski (Team)

The problem might be related to the following:
if your key (used for encryption) has a subkey, then the data will be encyrpted using both the key and the subkey. This is ok, but fomr some reason neither GnuPG nor PGP Desktop handle this correctly.

To solve the problem you need to "disable" the subkey. This is done by setting it's Enabled property to false.
Enabled property is declared in IElPGPCustomPublicKeyX2 interface.

Sincerely yours
Eugene Mayevski
Posted: 07/05/2007 18:00:35
by Brandon Davis (Basic support level)
Joined: 06/29/2007
Posts: 2

I figured out the issue. I was not calling the SetLicenseKey. Once I did that, the process worked without issue.



Topic viewed 2128 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!