EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Unexpected End of Data Exception

Posted: 08/28/2007 07:48:59
by Matthew Dragiff (Standard support level)
Joined: 03/01/2007
Posts: 15


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

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++)

SBPGPKeys.TElPGPKeyring pgpSecretKey = new SBPGPKeys.TElPGPKeyring()­;
for (int i = 0; i < pgpKeyRing.PublicCount; 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;
Posted: 08/29/2007 02:17:08
by Eugene Mayevski (Team)

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



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