protected void InitalizeCrypting() { publicKeyLen_ = 0; Array.Clear(publicKey_, 0, 80); // not really needed; better for debugging tho signkey_ = null; if (!MuleApplication.Instance.Preference.IsSecureIdentEnabled) { return; } // check if keyfile is there bool bCreateNewKey = false; string filename = System.IO.Path.Combine(MuleApplication.Instance.Preference.GetMuleDirectory(Mule.Preference.DefaultDirectoryEnum.EMULE_CONFIGDIR), "crytkey.dat"); if (System.IO.File.Exists(filename)) { FileInfo info = new FileInfo(filename); if (info.Length == 0) { bCreateNewKey = true; } } else { bCreateNewKey = true; } if (bCreateNewKey) { CreateKeyPair(); } // load key try { string keyText = System.IO.File.ReadAllText(filename); byte[] key = Convert.FromBase64String(keyText); // load private key signkey_ = MpdObjectManager.CreateRSAPKCS1V15SHA1Signer(key); RSACryptoServiceProvider rsa = new RSACryptoServiceProvider((int)MuleConstants.RSAKEYSIZE); rsa.ImportCspBlob(key); byte[] tmp = rsa.ExportCspBlob(false); Array.Copy(tmp, publicKey_, tmp.Length); publicKeyLen_ = (byte)tmp.Length; } catch (Exception ex) { signkey_ = null; MpdUtilities.DebugLogError(ex); } }