예제 #1
0
        public void GeneratePairwiseTransientKey_WithValidInput_ShouldGenerateCorrectKey()
        {
            // NB! The current version of the test relies on old TKIP
            // test vectors
            // TODO: Find WPA2 test vectors

            // Arrange and Act
            byte[] ptk = WPA2CryptographyTools.GeneratePairwiseTransientKey(
                _pairwiseMasterKey, _AA, _SA, _sNonce, _aNonce);
            bool ptkIsCorrect = HelperMethods.CompareBuffers(
                ptk, _pairwiseTransientKey, 48) == 0;

            // Assert
            Assert.IsTrue(ptkIsCorrect);
        }
예제 #2
0
        private void HandleDataFrame(DataFrame dataFrame)
        {
            GetDestinationAndSource(
                dataFrame, out AccessPoint accessPoint, out Station station);
            int handshakeNum =
                FrameParser.TryToParse4WayHandshake(dataFrame, out EAPOLKeyFormat keyFormat);

            switch (handshakeNum)
            {
            case 1:
                System.Console.WriteLine("Setting ANonce");

                station.ANonce = keyFormat.KeyNonce;
                break;

            case 2:
                System.Console.WriteLine("Setting SNonce");

                station.SNonce = keyFormat.KeyNonce;
                if ((station.ANonce != null) && (accessPoint.PairwiseMasterKey != null))
                {
                    byte[] ptk = WPA2CryptographyTools.GeneratePairwiseTransientKey(
                        accessPoint.PairwiseMasterKey,
                        dataFrame.DestinationAddress.GetAddressBytes(),
                        dataFrame.SourceAddress.GetAddressBytes(),
                        station.ANonce,
                        station.SNonce);

                    System.Console.WriteLine("Setting ptk");
                    station.PairwiseTransientKey = ptk;
                }
                break;

            case 3:
                System.Console.WriteLine("4whs case 3");
                break;

            case 4:
                System.Console.WriteLine("4whs case 4");
                break;

            default:
                break;
            }
        }