public void sigcheck(messC3 m, BigInteger n) { List<int> pozver = new List<int>(); for(int i=0;i<alist.Count();i++) if (alist[i].getQ() == m.getQ()) { if (rsa.verifySig(m.getQ(), m.getQu(), alist[i].getV(), n) == true) { pozver.Add(i); Console.WriteLine("VALID SIGNATURE FOR {0} !", alist[i].getA()); } else { Console.WriteLine("BAD ACCESS ATTEMPT FOR {0} !", alist[i].getA()); balist[alist[i].getA()]++; int x = balist[alist[i].getA()]; if (x > 2) Console.WriteLine("TOO MANY BAD ATTEMPTS FOR {0} ! CLIENT BLOCKED !", alist[i].getA()); } } for (int i = 0; i < pozver.Count; i++) alist.RemoveAt(pozver[i]); }
private void sendconfirmFake(cserver cs, messC3 m, BigInteger n) { m = new messC3(m.getQ(), m.getQu() + 1); cs.sigcheck(m, n); }
private void sendconfirm(cserver cs, messC3 m,BigInteger n) { cs.sigcheck(m,n); }
public void retreive(String pass, bool legal) { BigInteger gp = gengp(pass); BigInteger x= genx(); BigInteger Q= genQ(x,gp); List<messS1> rec = new List<messS1>(); int n = slist.Length; for (int i = 0; i < n; i++) { messC2 m = new messC2(name, Q); messS1 reply=sendrequest(slist[i], m); if (reply == null) { Console.WriteLine("\n{0}: Abort !\n", name); return; } else rec.Add(reply); } BigInteger Kmrec= genKrec(x,rec); BigInteger proof = rec[0].getproof(); byte[] Ukrec= rec[0].getUk(); if (verify(gp,Kmrec,proof) == true) { Console.WriteLine("\n{0}: Km retreived successfuly !\n",name); BigInteger U= decryptU(Kmrec,Ukrec); BigInteger Qu=new BigInteger(rsa.createSig(Q, U, nrsa)); messC3 mc = new messC3(Q, Qu); for (int i = 0; i < slist.Length; i++) if (legal == true) sendconfirm(slist[i], mc, nrsa); else sendconfirmFake(slist[i], mc, nrsa); } else Console.WriteLine("\n{0}: Abort !\n",name); }