EldoS | Feel safer!

Software components for data protection, secure storage and transfer

PGP Decryption

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
Posted: 11/24/2008 10:39:41
by Alex Nail (Basic support level)
Joined: 08/27/2008
Posts: 16

In an attempt to decrypt a non-armored pgp file, I received the following error message..."format not supported". I am able to decrypt the file with the given example project, what am I missing?


using (inF = new System.IO.FileStream(sourceFile, FileMode.Open))

keyring.Load(publicKeyPath, secretKeyPath, true);

string secretPassPhrase = GetConfigurationSetting("secretPassPhrase", "", "OpenPGP");
pgpReader.DecryptingKeys = keyring;// Key ring used as Decrypting Key on Decrypt.
pgpReader.KeyPassphrase = secretPassPhrase;

pgpReader.OnCreateOutputStream += new TSBPGPCreateOutputStreamEvent(pgpReader_OnCreateOutputStream);
pgpReader.DecryptAndVerify(inF, 0);

Posted: 11/24/2008 10:59:00
by Eugene Mayevski (EldoS Corp.)

And how does your code in pgpReader_OnCreateOutputStream() look like?

Sincerely yours
Eugene Mayevski
Posted: 11/24/2008 11:00:15
by Eugene Mayevski (EldoS Corp.)

... however this should not matter. The error message that you quoted can't be found in our code. Please provide the complete error message and if this is an exception, check where it comes from and what it's type is.

Sincerely yours
Eugene Mayevski
Posted: 11/24/2008 11:18:57
by Alex Nail (Basic support level)
Joined: 08/27/2008
Posts: 16

Here's the full stack trace...

at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, AccessControlActions control, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode)
at FTPConsole.PgpDecrypt.pgpReader_OnCreateOutputStream(Object Sender, String filename, DateTime TimeStamp, Stream& Stream, Boolean& FreeOnExit) in C:\Documents and Settings\anail\My Documents\Visual Studio 2008\Projects\FTPConsole\FTPConsole\PGPDecrypt.cs:line 72
at SBPGP.TElPGPReader.UnenvelopingStreamInfo(Object Sender)
at SBPGPStreams.TElPGPUnenvelopingStream.OnEntityHeaderProcessed(Object Sender)
at SBPGPEntities.TElPGPLiteral.LoadHeader()
at SBPGPEntities.TElPGPStreamingEntity.LoadBodyChunk(Byte[] Buffer, Boolean ALastChunk)
at SBPGPEntities.TElPGPEntity.DataAvailable()
at SBPGPEntities.TElPGPStreamingEntity.DataAvailable()
at SBPGPEntities.TElPGPStreamProcessor.DataAvailable()
at SBPGPStreams.TElPGPUnenvelopingStream.DataAvailable()
at SBPGP.TElPGPProcessingUnit.Write(Byte[] Buffer, Int32 Offset, Int32 Count)
at SBPGP.TElPGPReader.Synchronize()
at SBPGP.TElPGPReader.DecryptAndVerify(Stream ASourceStream, Int64 Count)
at FTPConsole.PgpDecrypt.PgpDecryptProcess(String sourceFile, String destFileName, String tempDir, String secretUserName, String archiveDir, String client, String trackingID) in C:\Documents and Settings\anail\My Documents\Visual Studio 2008\Projects\FTPConsole\FTPConsole\PGPDecrypt.cs:line 48
Posted: 11/24/2008 11:33:06
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

So problem really is in OnCreateOutputStream. It seems, that you are creating output stream with FileName, given in parameters, but this isn't really a valid filename (empty string, string with invalid characters, or so on). Please put breakpoint in event handler to see what is given in this parameter.
Posted: 11/24/2008 11:58:37
by Alex Nail (Basic support level)
Joined: 08/27/2008
Posts: 16

Agghhh, you are correct, it was within the OnCreateOutputStream. I was relying on the client's filename, not realizing this particular client put the entire path, not just the filename, explains why others were working.

I'm now using my own unique file name to pass as the parameters and the file decrypts as designed.

Thank you,
Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.



Topic viewed 1786 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!