EldoS | Feel safer!

Software components for data protection, secure storage and transfer

PGPReader doesn't appear to create output file

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
Posted: 11/06/2007 16:37:51
by Grady Patterson (Standard support level)
Joined: 11/06/2007
Posts: 2

When attempting to decrypt a file encrypted using PGP 8, I get no error, but no clear file is created.
If I decrypt the same file using the PGPFile demo, it decrypts successfully, so I'm sure I'm just missing some step in the process...

My code as it currently exists:

     SBPGP.TElPGPReader pgpDecrypter = new SBPGP.TElPGPReader();
     pgpDecrypter.OnCreateOutputStream += new TSBPGPCreateOutputStreamEvent(pgpDecrypter_OnCreateOutputStream);
     pgpDecrypter.OnKeyPassphrase += new SBPGPStreams.TSBPGPKeyPassphraseEvent(pgpDecrypter_OnKeyPassphrase);
     pgpDecrypter.DecryptingKeys = keyring;
     pgpDecrypter.VerifyingKeys = keyring;
     pgpDecrypter.Passphrase = MTI_Passphrase;

     pgpDecrypter.OutputFile = sDecryptedOutputFile;
     FileStream streamToDecrypt = new FileStream(sFileToDecrypt, FileMode.Open);
     pgpDecrypter.DecryptAndVerify(streamToDecrypt, 0);

I have attempted using the OnKeyPassphrase event to set the passphrase property, using code almost directly copied from the sample, with no change.
I also used the OnCreateOutputStream to check what filename I should expect to be created - although it does not match what I have set to the OutputFile property, neither file is created, either in the specified location or in the current directory...

What am I missing?
Posted: 11/07/2007 02:58:20
by Ken Ivanov (EldoS Corp.)

1. You cannot mix DecryptAndVerify() method with OutputFile property. Please consider using either DecryptAndVerifyFile() together with OutputFile property (to make TElPGPReader work with files) or DecryptAndVerify() together with OutputStream one (to make it work with streams). You can also use OnRequestOutputFile/OnCreateOutputStream events instead of setting OutputFile/OutputStream property to provide the exact output location once it has been requested.

2. If OnCreateOutputStream/OnRequestOutputFile is used, the output location has to be returned from the handler of this event. I.e. you should create an output stream inside the OnCreateOutputStream event handler and return it to the Stream parameter of the handler, or assign the destination path to the Path parameter of OnRequestOutputFile event handler.
Posted: 11/08/2007 17:01:57
by Grady Patterson (Standard support level)
Joined: 11/06/2007
Posts: 2

Thanks! switching to DecryptAndVerifyFile() works fine (and was a bit faster to recode for than using the OnCreateOutputStream Event).
The incompatibility between OutputFile and DecryptAndVerify() does not appear clearly in the documentation - might be worth adding a line to the description of the function stating that a bit more clearly...

Thanks again,
Posted: 11/09/2007 02:16:56
by Ken Ivanov (EldoS Corp.)

Thank you for the advice -- we will explain this in more details in the documentation.



Topic viewed 2188 times

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


Back to top

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

Got it!