Exemplo n.º 1
0
        public async Task OnLogonChallenge(AuthLogonChallenge challenge)
        {
            Account = GrainFactory.GetGrain <IAccount>(challenge.account);

            if (!(await Account.IsValid()))
            {
                await SendAuthError(AuthError.NoAccount);

                return;
            }


            string password = await Account.GetPassword();

            Shared.BigInteger pass = new Shared.BigInteger(password, 16);

            //test

            string passwordPlain = await Account.GetPasswordPlain();

            string SRPHash      = challenge.account.ToUpper() + ":" + passwordPlain.ToUpper();
            var    SRPHashBytes = Encoding.UTF8.GetBytes(SRPHash);
            var    SRPCreds     = BigInt.Hash(SRPHashBytes); //The bytes were g

            BigInteger x = BigInt.Hash(s, SRPCreds);

            v = g.ModPow(x, N);

            b = new Shared.BigInteger(new Random(), 160);

            Shared.BigInteger gmod = g.ModPow(b, N);

            if (gmod < 0)
            {
                gmod += N;
            }

            B = ((v * 3) + gmod) % N;

            if (B < 0)
            {
                B += N;
            }

            Shared.BigInteger unk = new Shared.BigInteger(new Random(), 128);
            //I'm sure this is used for matrix proofing (2 factor auth)

            PacketOut rtn = new PacketOut(AuthOp.AUTH_LOGON_CHALLENGE);

            rtn.Write((byte)AuthError.Success);
            rtn.Write((byte)0);  //unknown
            rtn.WriteBigInt(B, 32);
            rtn.WriteBigIntLength(g, 1);
            rtn.WriteBigIntLength(N, 32);
            rtn.WriteBigInt(s, 32);
            rtn.WriteBigInt(unk, 16);
            rtn.Write((byte)0);    //security flag
            await SendPacket(rtn); //test
        }