/// <inheritdoc />
        public Task HandleMessage(IPeerMessageContext <AuthenticationClientPayload> context, AuthLogonChallengeResponse payload)
        {
            AuthLogonProofRequest proof = null;

            //TODO: Change this console logging
            if (payload.Result != AuthenticationResult.Success)
            {
                Console.WriteLine($"Failed Auth: {payload.Result}");
            }

            using (WoWSRP6ClientCryptoServiceProvider srpProvider = new WoWSRP6ClientCryptoServiceProvider(payload.Challenge.B.ToBigInteger(), payload.Challenge.N.ToBigInteger(), payload.Challenge.g.ToBigInteger()))
            {
                using (WoWSRP6PublicComponentHashServiceProvider hashingService = new WoWSRP6PublicComponentHashServiceProvider())
                {
                    //TODO: Remove hardcoded name/pass
                    //Set the session key in the store for usage
                    BigInteger unhashedKey = srpProvider.ComputeSessionKey("Glader".ToUpper(), "test", payload.Challenge.salt);

                    Console.WriteLine($"SessionKey: {unhashedKey} KeySize: {unhashedKey.ToCleanByteArray().Length}");

                    proof = new AuthLogonProofRequest(srpProvider.A.ToCleanByteArray(), hashingService.ComputeSRP6M1(srpProvider.g, srpProvider.N, "Glader".ToUpper(), payload.Challenge.salt, srpProvider.A, srpProvider.B, unhashedKey));

                    //Set the session key as a hashed session key
                    //SessionKeyStorage.SessionKey = hashingService.HashSessionKey(unhashedKey);
                }
            }

            Console.WriteLine("Sending Proof");

            return(context.PayloadSendService.SendMessage(proof));
        }
Пример #2
0
        private static void AssertBitIntEquivalence(WCell.Core.Cryptography.BigInteger WcellBigInt, FreecraftCore.Crypto.BigInteger FreecraftBigInt)
        {
            //act
            byte[] wcellbytes     = WcellBigInt.GetBytes();
            byte[] freecraftbytes = FreecraftBigInt.ToCleanByteArray();

            //assert
            Assert.AreEqual(wcellbytes.Length, freecraftbytes.Length, "BigInteger mismatched length between Wcell and FreecraftCore.");

            for (int i = 0; i < wcellbytes.Length; i++)
            {
                Assert.AreEqual(wcellbytes[i], freecraftbytes[i], $"Byte value mismatch at index: {i} Wcell: {wcellbytes[i]} Freecraft: {freecraftbytes[i]}");
            }
        }