public static OutgoingAuthenticationPacket BuildAuthenticationLogOnChallengeSuccess(BigInteger srpPublicB, BigInteger srpGenerator, BigInteger srpModulus,
            BigInteger srpSalt, ExtraSecurityFlags extraFlags = ExtraSecurityFlags.None, bool immediateDisconnect = false)
        {
            Contract.Requires(srpPublicB != null);
            Contract.Requires(srpPublicB.ByteLength == WowAuthenticationParameters.KeySize);
            Contract.Requires(srpGenerator != null);
            Contract.Requires(srpGenerator.ByteLength == WowAuthenticationParameters.GeneratorSize);
            Contract.Requires(srpModulus != null);
            Contract.Requires(srpModulus.ByteLength == WowAuthenticationParameters.KeySize);
            Contract.Requires(srpSalt != null);
            Contract.Requires(srpSalt.ByteLength == WowAuthenticationParameters.KeySize);
            Contract.Ensures(Contract.Result<OutgoingAuthenticationPacket>() != null);

            var packet = new OutgoingAuthenticationPacket(GruntOpCode.AuthenticationLogOnChallenge);

            packet.Write(immediateDisconnect);
            packet.Write((byte)AuthenticationResult.Success);
            packet.Write(srpPublicB, WowAuthenticationParameters.KeySize);
            packet.Write(srpGenerator, WowAuthenticationParameters.GeneratorSize, true);
            packet.Write(srpModulus, WowAuthenticationParameters.KeySize, true);
            packet.Write(srpSalt, WowAuthenticationParameters.KeySize);
            packet.Write(new byte[Password.MD5Length]); // HMAC seed for client file verification.
            packet.Write((byte)extraFlags);

            if (extraFlags.HasFlag(ExtraSecurityFlags.Pin))
            {
                packet.Write(0); // Factor for determining PIN order.
                packet.Write(new byte[Password.MD5Length]);
            }

            if (extraFlags.HasFlag(ExtraSecurityFlags.Matrix))
            {
                packet.Write((byte)0); // Matrix height.
                packet.Write((byte)0); // Matrix width.
                packet.Write((byte)0); // Minimum digits.
                packet.Write((byte)0); // Maximum digits.
                packet.Write((long)0); // MD5 seed.

                // Let S = MD5(seed, sessionKey). Client uses S for the seed to a HMAC SHA-1 and an ARC4. It
                // then captures key presses, and for every press, processes the entered value with the ARC4.
                // The HMAC SHA-1 is then updated with the resulting value.
            }

            if (extraFlags.HasFlag(ExtraSecurityFlags.Token))
                packet.Write((byte)0); // Not sure what this is...

            return packet;
        }
Esempio n. 2
0
        public static OutgoingAuthenticationPacket BuildAuthenticationLogOnChallengeSuccess(BigInteger srpPublicB, BigInteger srpGenerator, BigInteger srpModulus,
                                                                                            BigInteger srpSalt, ExtraSecurityFlags extraFlags = ExtraSecurityFlags.None, bool immediateDisconnect = false)
        {
            Contract.Requires(srpPublicB != null);
            Contract.Requires(srpPublicB.ByteLength == WowAuthenticationParameters.KeySize);
            Contract.Requires(srpGenerator != null);
            Contract.Requires(srpGenerator.ByteLength == WowAuthenticationParameters.GeneratorSize);
            Contract.Requires(srpModulus != null);
            Contract.Requires(srpModulus.ByteLength == WowAuthenticationParameters.KeySize);
            Contract.Requires(srpSalt != null);
            Contract.Requires(srpSalt.ByteLength == WowAuthenticationParameters.KeySize);
            Contract.Ensures(Contract.Result <OutgoingAuthenticationPacket>() != null);

            var packet = new OutgoingAuthenticationPacket(GruntOpCode.AuthenticationLogOnChallenge);

            packet.Write(immediateDisconnect);
            packet.Write((byte)AuthenticationResult.Success);
            packet.Write(srpPublicB, WowAuthenticationParameters.KeySize);
            packet.Write(srpGenerator, WowAuthenticationParameters.GeneratorSize, true);
            packet.Write(srpModulus, WowAuthenticationParameters.KeySize, true);
            packet.Write(srpSalt, WowAuthenticationParameters.KeySize);
            packet.Write(new byte[Password.MD5Length]); // HMAC seed for client file verification.
            packet.Write((byte)extraFlags);

            if (extraFlags.HasFlag(ExtraSecurityFlags.Pin))
            {
                packet.Write(0); // Factor for determining PIN order.
                packet.Write(new byte[Password.MD5Length]);
            }

            if (extraFlags.HasFlag(ExtraSecurityFlags.Matrix))
            {
                packet.Write((byte)0); // Matrix height.
                packet.Write((byte)0); // Matrix width.
                packet.Write((byte)0); // Minimum digits.
                packet.Write((byte)0); // Maximum digits.
                packet.Write((long)0); // MD5 seed.

                // Let S = MD5(seed, sessionKey). Client uses S for the seed to a HMAC SHA-1 and an ARC4. It
                // then captures key presses, and for every press, processes the entered value with the ARC4.
                // The HMAC SHA-1 is then updated with the resulting value.
            }

            if (extraFlags.HasFlag(ExtraSecurityFlags.Token))
            {
                packet.Write((byte)0); // Not sure what this is...
            }
            return(packet);
        }