示例#1
0
 private void btnVerify_Click(object sender, EventArgs e)
 {
     BInteger p = new BInteger("6277101735386680763835789423207666416083908700390324961279", 10);
     BInteger a = new BInteger("-3", 10);
     BInteger b = new BInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16);
     byte[] xG = FromHexStringToByte("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012");
     BInteger n = new BInteger("ffffffffffffffffffffffff99def836146bc9b1b4d22831", 16);
     DSGost DS = new DSGost(p, a, b, n, xG);
     GOST hash = new GOST(256);
     long start = DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
     byte[] H = hash.GetHash(System.Text.Encoding.Default.GetBytes(textBoxText.Text));
     bool result = DS.SingVer(H, textBox2Hash.Text, Q);
     long finish = DateTime.Now.Second * 1000 + DateTime.Now.Millisecond;
     long time = finish - start;
     if (result)
     {
         labelIsCorrect.ForeColor = Color.Green;
         labelIsCorrect.Text = "Correct";
     }
     else
     {
         labelIsCorrect.ForeColor = Color.Red;
         labelIsCorrect.Text = "Wrong";
     }
 }
示例#2
0
 private void btnSign_Click(object sender, EventArgs e)
 {
     BInteger p = new BInteger("6277101735386680763835789423207666416083908700390324961279", 10);
     BInteger a = new BInteger("-3", 10);
     BInteger b = new BInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16);
     byte[] xG = FromHexStringToByte("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012");
     BInteger n = new BInteger("ffffffffffffffffffffffff99def836146bc9b1b4d22831", 16);
     DSGost DS = new DSGost(p, a, b, n, xG);
     d = DS.GenPrivateKey(192);
     Q = DS.GenPublicKey(d);
     GOST hash = new GOST(256);
     byte[] H = hash.GetHash(System.Text.Encoding.Default.GetBytes(textBoxText.Text));
     string sign = DS.SingGen(H, d);
     textBox2Hash.Text = sign;
     bool result = DS.SingVer(H, sign, Q);
 }