EldoS | Feel safer!

Software components for data protection, secure storage and transfer

using or not using a secret key

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.
#8700
Posted: 01/23/2009 06:37:48
by Blue White (Basic support level)
Joined: 01/22/2009
Posts: 27


I am trying to encrypt a text file using the public key only without using a secret key
but i keep getting this Exception error:

EElPGPDecryptionStreamException:
No appropriate OpenPGP secret Key for decryption

the code for the keyring goes like this:

/*Encryption Code*/

SBPGPKeys.TElPGPKeyring pgpKeyRing = new SBPGPKeys.TElPGPKeyring();

pgpKeyRing.Load(pgpKeyFile, null , true);

pgpWriter.EncryptingKeys = pgpKeyRing;


/*End Code*/


//Decryption Code:

SBPGPKeys.TElPGPKeyring pgpKeyring1 = new SBPGPKeys.TElPGPKeyring();
pgpKeyring1.Load(@"C:\key.txt", null, true);
pgpReader.DecryptingKeys = pgpKeyring1;
pgpReader.OutputFile = "DecryptedFile.txt";

pgpReader.DecryptAndVerifyFile(@"C:\herewego.txt");

//End Decryption Code



So as solution, i tried to add a secret key which is just a text file i created on C:\ and i passed its path to the load parameters
but i ended up with another exception, find below the code and Exception:

// Encryption Code:

SBPGPKeys.TElPGPKeyring pgpKeyRing = new SBPGPKeys.TElPGPKeyring();

pgpKeyRing.Load(pgpKeyFile, @"C:\SecretKey.txt" , true);

pgpWriter.EncryptingKeys = pgpKeyRing;

//End Encryption Code



//Decryption Code

SBPGPKeys.TElPGPKeyring pgpKeyring1 = new SBPGPKeys.TElPGPKeyring();
pgpKeyring1.Load(@"C:\key.txt", @"C:\SecretKey.txt" , true);
pgpReader.DecryptingKeys = pgpKeyring1;

pgpReader.OutputFile = "DecryptedFile.txt";
//pgpReader.KeyPassphrase = "password";
pgpReader.DecryptAndVerifyFile(@"C:\herewego.txt");

//End of Decryption Code



Exception error:

EElPGPInvalidPacketException:
Invalid PGP packet



Question:
1. is it obligatory to use a secret key? if it's not obligatory then why my code isn't working and why i keep getting the first exception :
"No appropriate OpenPGP secret Key for decryption
"
2. is this the correct way for using a secret key? or are there any properties that are not set ?
#8701
Posted: 01/23/2009 06:54:42
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

You can use public keys only for encryption, to decrypt you need to have the corresponding secret key.
#8702
Posted: 01/23/2009 07:11:26
by Blue White (Basic support level)
Joined: 01/22/2009
Posts: 27

excuse me im new to this tool and to Encryption.


from where can i get a sample public key and secret key?

i mean there must be a relation between them so are there any generated samples ?
#8704
Posted: 01/23/2009 07:23:52
by Blue White (Basic support level)
Joined: 01/22/2009
Posts: 27

Actually they have given me the public key but i wasnt provided with the secret key
so what can i do in this case ?
#8707
Posted: 01/23/2009 07:27:04
by Eugene Mayevski (EldoS Corp.)

Sample keys are located in <SecureBlackbox>\PGPKeys folder.
As for encryption basics, I recommend that you read some book that will explain the basics. I usually recommend RSA Official Guide To Cryptography book which can be found on Amazon and which has been translated to different languages worldwide.


Sincerely yours
Eugene Mayevski
#8708
Posted: 01/23/2009 07:31:35
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

There are sample keys in PGPKeys directory. How to perform encryption and decryption you can look in our sample (PGPFilesDemo), to generate new key pair you should use PGPKeysDemo.

The main idea, is that other party gives you their public key, you encrypts the file, using this public key, and sends to the other party. And only they can decrypt that file, having the secret key.
#8711
Posted: 01/23/2009 08:34:37
by Blue White (Basic support level)
Joined: 01/22/2009
Posts: 27

Many Thanks guys it's working fine now :)
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.

Reply

Statistics

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