static void Main(string[] args) { BigInteger p = new BigInteger("6277101735386680763835789423207666416083908700390324961279", 10); BigInteger a = new BigInteger("-3", 10); BigInteger b = new BigInteger("64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1", 16); byte[] xG = FromHexStringToByte("03188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012"); BigInteger n = new BigInteger("ffffffffffffffffffffffff99def836146bc9b1b4d22831", 16); DSGost DS = new DSGost(p, a, b, n, xG); BigInteger d = DS.GenPrivateKey(192); ECPoint Q = DS.GenPublicKey(d); GOST hash = new GOST(256); byte[] H = hash.GetHash(Encoding.Default.GetBytes("Message")); string sign = DS.SignGen(H, d); bool result = DS.SignVer(H, sign, Q); Console.WriteLine(result); }
public ActionResult Index(GOST34102012Models model) { BigInteger p = model.p; BigInteger a = model.a; BigInteger b = model.b; byte[] xG = model.xG; BigInteger n = model.n; DSGost DS = new DSGost(p, a, b, n, xG); BigInteger d = DS.GenPrivateKey(192, model.Seed); ECPoint Q = DS.GenPublicKey(d); Stribog hash = new Stribog(256); byte[] H = hash.GetHash(Encoding.Default.GetBytes(model.Text)); string sign = DS.SignGen(H, d); bool result = DS.SignVer(H, sign, Q); ViewBag.d = d; ViewBag.Q = Q; ViewBag.H = H; ViewBag.alpha = DS.alpha; ViewBag.e = DS.e; ViewBag.k = DS.k; ViewBag.C = DS.C; ViewBag.r = DS.r; ViewBag.s = DS.s; ViewBag.sign = sign; ViewBag.n = DS.n; ViewBag.encr_r = DS.encr_r; ViewBag.encr_s = DS.encr_s; ViewBag.encr_alpha = DS.encr_alpha; ViewBag.encr_e = DS.encr_e; ViewBag.v = DS.v; ViewBag.z1 = DS.z1; ViewBag.z2 = DS.z2; ViewBag.A = DS.A; ViewBag.B = DS.B; ViewBag.R = DS.R; ViewBag.encr_C = DS.encr_C; return View("Echo", model); }