EldoS | Feel safer!

Software components for data protection, secure storage and transfer

PGPBlackBox

Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.
#6861
Posted: 07/07/2008 12:09:55
by Lino Coelho (Standard support level)
Joined: 07/07/2008
Posts: 5

Hi,

I'm trying to PGP encrypt a text file with the public key but when we send the file to our third party vendor they are unable to decrypt the file.

What can I do to make this work? How do I find out what settings to use so that they are able to decrypt the file (Armored, symmetric key algorithm etc...)?

Below is the method that I created in C#:

public void EncryptFile(string inFile, string outFile, string pgpKeyFile)
{
if (!File.Exists(inFile))
throw new FileNotFoundException("File not found.", inFile);

if (!File.Exists(pgpKeyFile))
throw new FileNotFoundException("File not found.", pgpKeyFile);

using (SBPGPKeys.TElPGPKeyring pgpKeyRing = new SBPGPKeys.TElPGPKeyring())
{
pgpKeyRing.Load(pgpKeyFile, null, true);

if (pgpKeyRing.PublicCount == 0)
throw new Exception("PgpKeyRing does not contain public key. Cannot encrypt file.");

using (SBPGP.TElPGPWriter pgpWriter = new SBPGP.TElPGPWriter())
{
FileStream inputFile = null;
FileStream outputFile = null;

pgpWriter.Armor = false;
pgpWriter.ArmorHeaders.Clear();
//pgpWriter.ArmorHeaders.Add("Version: EldoS PGPBlackbox (.NET edition)");
//pgpWriter.ArmorBoundary = "PGP MESSAGE";
pgpWriter.Compress = true;
pgpWriter.EncryptingKeys = pgpKeyRing;
pgpWriter.EncryptionType = SBPGP.TSBPGPEncryptionType.etPublicKey;
pgpWriter.Filename = inFile;
pgpWriter.InputIsText = true;
pgpWriter.Protection = SBPGPConstants.TSBPGPProtectionType.ptLow;
pgpWriter.SignBufferingMethod = SBPGP.TSBPGPSignBufferingMethod.sbmRewind;
pgpWriter.SymmetricKeyAlgorithm = SBPGPConstants.Unit.SB_PGP_ALGORITHM_SK_CAST5;
pgpWriter.Timestamp = DateTime.Now;
pgpWriter.UseOldPackets = false;

try
{
inputFile = new FileStream(inFile, FileMode.Open);
outputFile = new FileStream(outFile, FileMode.Create);
pgpWriter.Encrypt(inputFile, outputFile, 0);
}
catch
{
throw;
}
finally
{
if (inputFile != null)
inputFile.Close();

if (outputFile != null)
outputFile.Close();
}
}
}
}


Let me know.
#6863
Posted: 07/07/2008 12:37:42
by Lino Coelho (Standard support level)
Joined: 07/07/2008
Posts: 5

If I change the Armor property to false the encryption text starts to look similar to what is encrypted when using PGP desktop. But the third party vendor still can't decrypt the file. They can only decrypt the file that is encrypted with PGP desktop.

Please help.

Let me know.

LC
#6864
Posted: 07/07/2008 13:41:48
by Ken Ivanov (EldoS Corp.)

First of all, please try the following combination of settings:

1) Encryption algorithm: CAST5,
2) Protection level: normal,
3) Use old packets: true,
4) Use new features: false,
5) Armor: try both true and false.

This combination is understood by most of the existing applications. Once your partner gets the file decrypted correctly, you can play with settings to find out the exact property that is not understood by your partner's software.
#6872
Posted: 07/08/2008 08:32:00
by Lino Coelho (Standard support level)
Joined: 07/07/2008
Posts: 5

Hi,

I tried the above and the provider is still unable to decrypt the file.

Can I send you the public key and sample file that is encrypted using PGP desktop? Shouldn't the encrypted results from both (PGPBlackBox and PGP Desktop) match?

Let me know.

LC
#6873
Posted: 07/08/2008 08:56:02
by Ken Ivanov (EldoS Corp.)

Is you partner able to decrypt files produced by the sample PGPFiles application?

Quote
Can I send you the public key and sample file that is encrypted using PGP desktop?

Please try to use PGPFiles sample first.

Quote
Shouldn't the encrypted results from both (PGPBlackBox and PGP Desktop) match?

No. New session key is used each time the message is encrypted, so the results *will* differ.
#6877
Posted: 07/08/2008 10:58:02
by Lino Coelho (Standard support level)
Joined: 07/07/2008
Posts: 5

Hi,

I tweaked the settings again and it is working now with the suggestions that you had made previously.

Thanks for your help.

LC
#6878
Posted: 07/08/2008 11:00:36
by Lino Coelho (Standard support level)
Joined: 07/07/2008
Posts: 5

HI,

How do I stop gettings email messages from other questions other then mine?

LC
#6881
Posted: 07/08/2008 11:33:40
by Ken Ivanov (EldoS Corp.)

Great, thank you for letting us know.

Quote
How do I stop gettings email messages from other questions other then mine?


Use the Subscription link at the bottom of the page.
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

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