コード例 #1
0
        private void gen_key_e_sign_Click(object sender, EventArgs e)
        {
            int keysize = Convert.ToInt32(key_size_e_sign.SelectedItem.ToString());

            SK             = generator.Get_Key(keysize);
            p              = generator.P;
            PK             = generator.PUBLIC_KEY;
            G              = generator.G;
            p_e_sign.Text  = p.ToString();
            sk_e_sign.Text = SK.ToString();
            pk_e_sign.Text = PK.ToString();
            g_e_sign.Text  = G.ToString();
            e_signature    = new ElgamalSignature(PK, p, G, SK, key_sign);
        }
コード例 #2
0
        private void file_key_e_sign_Click(object sender, EventArgs e)
        {
            OpenFileDialog get_file  = new OpenFileDialog();
            string         file_name = "";

            if (get_file.ShowDialog() == DialogResult.OK)
            {
                file_name = get_file.FileName;
            }
            string[] keys = new string[4];
            try
            {
                using (StreamReader sr = new StreamReader(file_name))
                {
                    string line;
                    int    count = 0;
                    while ((line = sr.ReadLine()) != null)
                    {
                        keys[count++] = line;
                    }
                    if (keys[0].Length <= 320)
                    {
                        key_size_e_sign.Text = 1024.ToString();
                        key_sign             = 1024;
                    }
                    else
                    {
                        key_size_e_sign.Text = 2048.ToString();
                        key_sign             = 2048;
                    }
                    p  = BigInteger.Parse(keys[0]);
                    SK = BigInteger.Parse(keys[1]);
                    PK = BigInteger.Parse(keys[2]);
                    G  = BigInteger.Parse(keys[3]);
                }
                p_e_sign.Text  = p.ToString();
                sk_e_sign.Text = SK.ToString();
                pk_e_sign.Text = PK.ToString();
                g_e_sign.Text  = G.ToString();
                e_signature    = new ElgamalSignature(PK, p, G, SK, key_sign);
            }
            catch
            {
                return;
            }
        }