EldoS | Feel safer!

Software components for data protection, secure storage and transfer

TElPGPReader Memory Usage

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#3633
Posted: 08/27/2007 12:46:13
by Matthew Dragiff (Standard support level)
Joined: 03/01/2007
Posts: 15

Hi

I'm trying to use SecureBlackBox's OpenPGP Encryption to decrypt files in a BizTalk solution and I'm running into out of memory exceptions when the file I'm trying to decrypt approaches an (encrypted) size of around 20-25 MB (decrypted ~130-180 MB). I extracted my code into a simple winforms app that simply takes a file and performs the decryption, and memory usage hits 1GB during the decryption. Is this normal?

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_PublicKeys(i));
}

SBPGPKeys.TElPGPKeyring pgpSecretKey = new SBPGPKeys.TElPGPKeyring();
for (int i = 0; i < pgpKeyRing.PublicCount; i++)
{
pgpSecretKey.AddSecretKey(pgpKeyRing.get_SecretKeys(i));
pgpSecretKey.get_SecretKeys(i).Passphrase = PassPhrase;
}

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

//_sDecryptedStream is a System.IO.MemoryStream
_pgpReader.OutputStream = _sDecryptedStream;
_pgpReader.OnCreateOutputStream += new TSBPGPCreateOutputStreamEvent(pgp_OnCreateOutputStream);
_pgpReader.KeyPassphrase = PassPhrase;
_pgpReader.DecryptAndVerify(InputStream, 0);

return _sDecryptedStream;
}

private void pgp_OnCreateOutputStream(object sender, string Filename, DateTime TimeStamp, ref Stream Stream, ref bool FreeOnExit)
{
Stream = _sDecryptedStream;
FreeOnExit = false;
}
#3635
Posted: 08/27/2007 13:27:11
by Ken Ivanov (EldoS Corp.)

Quote
Is this normal?

Actually, no. Please try to decrypt the file to System.IO.FileStream and check if decryption exposes the same memory usage values. It is also a good idea to upgrade to the latest available build update and try your code with it.
#3637
Posted: 08/27/2007 13:46:27
by Matthew Dragiff (Standard support level)
Joined: 03/01/2007
Posts: 15

I found the problem. Almost immediately after posting, actually. Changing _sDecryptedStream to a FileStream took care of the problem.

Reply

Statistics

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