/// <summary> /// Adds a Pairwise Master Key (PMK) to the access point with the specified BSSID. /// In WPA2, the PMK is derived from the access point BSSID and password and used to /// create other keys used in encryption. /// </summary> /// <param name="bssid">The BSSID of the access point.</param> /// <param name="ssid">The SSID of the access point.</param> /// <param name="password">The password of the access point.</param> public void AddPassword(PhysicalAddress bssid, string ssid, string password) { byte[] pmk = WPA2CryptographyTools.GeneratePairwiseMasterKey(password, ssid); if (AccessPoints.ContainsKey(bssid) == false) { AccessPoints[bssid] = new AccessPoint(bssid); } AccessPoints[bssid].PairwiseMasterKey = pmk; }
public void GeneratePairwiseMasterKey_WithValidInput_ShouldGenerateCorrectKey() { // Arrange and Act byte[] pmk = WPA2CryptographyTools.GeneratePairwiseMasterKey(_passphrase, _ssid); bool pmkIsCorrect = HelperMethods.CompareBuffers(pmk, _pmk1, _pmk1.Length) == 0; // Assert Assert.IsTrue(pmkIsCorrect); }