예제 #1
0
        public void Save()
        {
            Random      rand   = new Random();
            double      d      = rand.NextDouble();
            MFKeyConfig keyCfg = new MFKeyConfig();
            KeyPair     keys   = keyCfg.CreateKeyPair();

            MFConfigHelper cfgHelper = new MFConfigHelper(m_dev);

            m_cfg.Enabled = 1;
            m_cfg.Seed    = (UInt64)((double)UInt64.MaxValue * d);

            unsafe
            {
                fixed(byte *key = m_cfg.PrivateSslKey.SectorKey)
                {
                    for (int i = 0; i < keys.PrivateKey.Length && i < MFKeyConfig.PrivateKeySize; i++)
                    {
                        key[i++] = keys.PrivateKey[i];
                    }
                }
            }

            cfgHelper.WriteConfig(c_CfgName, m_cfg, true);

            cfgHelper.Dispose();
        }
예제 #2
0
        public void Save()
        {
            Random      rand    = new Random();
            double      d       = rand.NextDouble();
            MFKeyConfig keyCfg  = new MFKeyConfig();
            KeyPair     keys    = keyCfg.CreateKeyPair();

            MFConfigHelper cfgHelper = new MFConfigHelper(m_dev);

            m_cfg.Enabled = 1;
            m_cfg.Seed = (UInt64)((double)UInt64.MaxValue * d);

            unsafe
            {
                fixed (byte* key = m_cfg.PrivateSslKey.SectorKey)
                {
                    for (int i = 0; i < keys.PrivateKey.Length && i < MFKeyConfig.PrivateKeySize; i++)
                    {
                        key[i++] = keys.PrivateKey[i];
                    }
                }
            }

            cfgHelper.WriteConfig(c_CfgName, m_cfg, true);

            cfgHelper.Dispose();
        }
예제 #3
0
        static internal string ShowCreateKeyPairFileDialog()
        {
            string fileName = "";

            SaveFileDialog sfd = new SaveFileDialog();
            sfd.DefaultExt = "*.key";
            sfd.CheckPathExists = true;
            sfd.Filter = Properties.Resources.FileDialogFilterKeys;
            sfd.FilterIndex = 0;
            sfd.AddExtension = true;
            sfd.OverwritePrompt = true;
            sfd.Title = Properties.Resources.SaveKeyTitle;

            if (DialogResult.OK == sfd.ShowDialog())
            {
                fileName = sfd.FileName;

                MFKeyConfig keyTool = new MFKeyConfig();

                KeyPair keyPair = keyTool.CreateKeyPair();
                keyTool.SaveKeyPair(keyPair, fileName);
            }

            return fileName;
        }
            public override void OnAction(IMFDeployForm form, MFDevice device)
            {
                System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
                sfd.DefaultExt = "*.key";
                sfd.CheckPathExists = true;
                sfd.Filter = "Key File (*.key)|*.key|All Files (*.*)|*.*";
                sfd.FilterIndex = 0;
                sfd.AddExtension = true;
                sfd.OverwritePrompt = true;
                sfd.Title = "Create Empty Key";

                if (System.Windows.Forms.DialogResult.OK == sfd.ShowDialog())
                {
                    MFKeyConfig cfg = new MFKeyConfig();
                    KeyPair emptyKey = cfg.CreateEmptyKeyPair();
                    cfg.SaveKeyPair(emptyKey, sfd.FileName);
                }
            }