EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Simple PGP

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#4704
Posted: 01/15/2008 12:27:10
by Justin H (Basic support level)
Joined: 12/16/2007
Posts: 6

I'm trying to make a function to encrypt a file. Code Below:
Code
public void EncryptFile(string sourceFile,string destinationFile)
        {
            System.IO.FileStream inF, outF;
         System.IO.FileInfo info;

         pgpWriter.Armor = true;
         pgpWriter.ArmorHeaders.Clear();
         pgpWriter.ArmorHeaders.Add("Version: EldoS OpenPGPBlackbox (.NET edition)");
         pgpWriter.ArmorBoundary = "PGP MESSAGE";
            pgpWriter.Compress = false;
            SBPGPKeys.TElPGPKeyring pubKeyring = new SBPGPKeys.TElPGPKeyring();
            pubKeyring.AddPublicKey((SBPGPKeys.TElPGPPublicKey)keyring.get_PublicKeys(0));//0 is prudential in this keyring
            pgpWriter.EncryptingKeys = pubKeyring;
            pgpWriter.SigningKeys = keyring;         
         pgpWriter.EncryptionType = SBPGP.TSBPGPEncryptionType.etPublicKey;         
         info = new System.IO.FileInfo(sourceFile);
         pgpWriter.Filename = info.Name;
            pgpWriter.InputIsText = false;
         pgpWriter.Passphrases.Clear();
         pgpWriter.Passphrases.Add("prudential");
            pgpWriter.Protection = SBPGPConstants.TSBPGPProtectionType.ptHigh;
            pgpWriter.SignBufferingMethod = SBPGP.TSBPGPSignBufferingMethod.sbmRewind;
         pgpWriter.SymmetricKeyAlgorithm = SBPGPConstants.Unit.SB_PGP_ALGORITHM_SK_3DES;
         //pgpWriter.HashAlgorithm = SBPGPConstants.Unit.SB_PGP_ALGORITHM_MD_SHA512;
         pgpWriter.Timestamp = DateTime.Now;
            pgpWriter.UseNewFeatures = false;
         pgpWriter.UseOldPackets = false;

         inF = new System.IO.FileStream(sourceFile, System.IO.FileMode.Open);
         try
         {
            outF = new System.IO.FileStream(destinationFile, System.IO.FileMode.Create);
            try
            {
               pgpWriter.Encrypt(inF, outF, 0);               
            }
            finally
            {
               outF.Close();
            }
         }
         finally
         {
            inF.Close();
         }
        }



I know that the key is there, One key in the encrypting keys property. However when this runs it creates the file but doesn't put anything in it. I set my licence key earlier in the code but I'm obvioulsy missing something. Please let me know if anyone has any ideas, I need this ASAP :)
#4705
Posted: 01/15/2008 12:33:47
by Eugene Mayevski (EldoS Corp.)

1) check the sample applications if they work with your PGP keys.
2) ensure that you set the license key.


Sincerely yours
Eugene Mayevski
#4706
Posted: 01/15/2008 12:44:30
by Justin H (Basic support level)
Joined: 12/16/2007
Posts: 6

The same files work, I copied and pasted the majority of the code above right out of the pgp file example. I know I am setting the license key earlier in the app. Is there a way I could call something at the beginning of this function that would tell me if the license key was good or not so I can cross that one off the list of possibilities? Assuming the license key is not the issue can you think of anything else that may cause this?


Thanks,
Justin
#4707
Posted: 01/15/2008 13:13:23
by Eugene Mayevski (EldoS Corp.)

I remember similar questions several times before (and in the forum too), and the solution there was rather simple - a missing license key, not properly set input stream position etc. . But in your code everything besides the key seems to be ok.
If you can create a test case, post it together with your public keyring (no need for private keys!) to HelpDesk, I will run the code and see where the problem is.


Sincerely yours
Eugene Mayevski
#4709
Posted: 01/15/2008 14:05:35
by Justin H (Basic support level)
Joined: 12/16/2007
Posts: 6

Thanks Eugene,


I just submitted the ticket. Please feel free to email or call if you need any additional information. contact info in ticket.
#4717
Posted: 01/16/2008 15:10:55
by Eugene Mayevski (EldoS Corp.)

Wrong license key appeared to be a problem. Also, it's SBB 4, where SetLicenseKey doesn't report license key problems. In SBB 5 and 6 invalid license keys are reported immediately via exception.


Sincerely yours
Eugene Mayevski
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.

Reply

Statistics

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