EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Unexpected End of Data Exception

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#3640
Posted: 08/28/2007 07:48:59
by Matthew Dragiff (Standard support level)
Joined: 03/01/2007
Posts: 15

Hi

I posted this source code yesterday in regard to another question, but I've just been made aware of another issue in the same code. We receive encrypted files via FTP and this code is called to decrypt them. We are intermittently receiving the Unexpected End of Data Exception on files that we are subsequently able to decrypt by re-processing them.

I did not find any documentation on this Excpetion message anywhere on the site- what are the potential causes of it, and what should I look for to avoid it?

I'm using version 5.0.0.107

Here are the guts of my Decryption code:

public System.IO.Stream Decrypt()
{
SBPGPKeys.TElPGPKeyring pgpKeyRing = new SBPGPKeys.TElPGPKeyring()­;

//These are stream objects that are members of the class this
//method resides in. InputStream is a System.IO.FileStream in
//this case.
InputStream.Seek(0, SeekOrigin.Begin);
PublicKey.Seek(0, SeekOrigin.Begin);
PrivateKey.Seek(0, SeekOrigin.Begin);

pgpKeyRing.Load(PublicKey­, PrivateKey, true);
SBPGPKeys.TElPGPKeyring pgpPublicKey = new SBPGPKeys.TElPGPKeyring()­;
for (int i = 0; i < pgpKeyRing.PublicCount; i++)
{
pgpPublicKey.AddPublicKey­(pgpKeyRing.get_PublicKey­s(i));
}

SBPGPKeys.TElPGPKeyring pgpSecretKey = new SBPGPKeys.TElPGPKeyring()­;
for (int i = 0; i < pgpKeyRing.PublicCount; i++)
{
pgpSecretKey.AddSecretKey­(pgpKeyRing.get_SecretKey­s(i));
pgpSecretKey.get_SecretKe­ys(i).Passphrase = PassPhrase;
}

_pgpReader.DecryptingKeys­ = pgpSecretKey;
_pgpReader.VerifyingKeys = pgpPublicKey;

//_sDecryptedStream is a System.IO.MemoryStream
_pgpReader.OutputStream = _sDecryptedStream;
_pgpReader.OnCreateOutput­Stream += new TSBPGPCreateOutputStreamE­vent(pgp_OnCreateOutputSt­ream);
_pgpReader.KeyPassphrase = PassPhrase;
_pgpReader.DecryptAndVeri­fy(InputStream, 0);

return _sDecryptedStream;
}

private void pgp_OnCreateOutputStream(­object sender, string Filename, DateTime TimeStamp, ref Stream Stream, ref bool FreeOnExit)
{
Stream = _sDecryptedStream;
FreeOnExit = false;
}
#3648
Posted: 08/29/2007 02:17:08
by Eugene Mayevski (EldoS Corp.)

1) You don't need to use oth OutputStream property and OnCreateOutputStream event at the same time. Use either of them but not both.
2) Does the problem happen when you use the sample application to decrypt your data with your keys?


Sincerely yours
Eugene Mayevski

Reply

Statistics

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