/// <summary> /// Checks if a password is valid for a cipher type. /// </summary> public static bool IsValid(string password, Dot11CipherAlgorithm cipherAlgorithm) { switch (cipherAlgorithm) { case Dot11CipherAlgorithm.None: return(true); case Dot11CipherAlgorithm.WEP: // WEP key is 10, 26 or 40 hex digits long. if (string.IsNullOrEmpty(password)) { return(false); } int len = password.Length; bool correctLength = len == 10 || len == 26 || len == 40; bool onlyHex = new Regex("^[0-9A-F]+$").IsMatch(password); return(correctLength && onlyHex); case Dot11CipherAlgorithm.CCMP: // WPA2-PSK 8 to 63 ASCII characters case Dot11CipherAlgorithm.TKIP: // WPA-PSK 8 to 63 ASCII characters if (string.IsNullOrEmpty(password)) { return(false); } return(8 <= password.Length && password.Length <= 63); default: return(true); } }
/// <summary> /// Generates the EAP user XML /// </summary> internal static string Generate(Dot11CipherAlgorithm cipher, string username, string password, string domain) { #warning Robin: Probably not properly implemented, only supports WPA- and WPA-2 Enterprise with PEAP-MSCHAPv2 string profile; switch (cipher) { case Dot11CipherAlgorithm.CCMP: // WPA-2 case Dot11CipherAlgorithm.TKIP: // WPA string template = GetTemplate("PEAP-MS-CHAPv2"); profile = string.Format( template, EncodeForXML(username, true), EncodeForXML(password, true), EncodeForXML(domain, true)); break; default: throw new NotImplementedException("Profile for selected cipher algorithm is not implemented"); } return(profile); }
/// <summary> /// Generates the EAP user XML /// </summary> public static string Generate(Dot11CipherAlgorithm cipher, string username, string password, string domain) { #warning Robin: Probably not properly implemented, only supports WPA- and WPA-2 Enterprise with PEAP-MSCHAPv2 string profile = string.Empty; string template = string.Empty; switch (cipher) { case Dot11CipherAlgorithm.CCMP: // WPA-2 case Dot11CipherAlgorithm.TKIP: // WPA template = GetTemplate("PEAP-MS-CHAPv2"); profile = string.Format(template, username, FixPass(password), domain); break; default: throw new NotImplementedException("Profile for selected cipher algorithm is not implemented"); } return profile; }
public static string ToString(Dot11CipherAlgorithm algorithm) { switch (algorithm) { case Dot11CipherAlgorithm.None: return("无"); case Dot11CipherAlgorithm.Wep40: return("WEP (40 位密钥)"); case Dot11CipherAlgorithm.Tkip: return("TKIP"); case Dot11CipherAlgorithm.Ccmp: return("AES-CCMP"); case Dot11CipherAlgorithm.Wep104: return("WEP (104 位密钥)"); case Dot11CipherAlgorithm.WpaUseGroup: return("WPA/RSN (使用组密钥)"); case Dot11CipherAlgorithm.Wep: return("WEP"); default: return(algorithm < 0 ? "IHV" : "未知的 DOT11_CIPHER_ALGORITHM"); } }
/// <summary> /// Generates the EAP user XML /// </summary> internal static string Generate(Dot11CipherAlgorithm cipher, string username, string password, string domain) { #warning Robin: Probably not properly implemented, only supports WPA- and WPA-2 Enterprise with PEAP-MSCHAPv2 string profile = string.Empty; string template = string.Empty; switch (cipher) { // WPA and WPA2(Wi-Fi Protected Access) - is an updated wireless device certification program case Dot11CipherAlgorithm.CCMP: // WPA-2 case Dot11CipherAlgorithm.TKIP: // WPA template = GetTemplate("PEAP-MS-CHAPv2"); profile = string.Format(template, username, FixPass(password), domain); break; default: throw new NotImplementedException("Profile for selected cipher algorithm is not implemented"); } return(profile); }
/// <summary> /// Checks if a password is valid for a cipher type. /// </summary> public static bool IsValid(string password, Dot11CipherAlgorithm cipherAlgorithm) { switch (cipherAlgorithm) { case Dot11CipherAlgorithm.None: return true; case Dot11CipherAlgorithm.WEP: // WEP key is 10, 26 or 40 hex digits long. if (string.IsNullOrEmpty(password)) return false; int len = password.Length; bool correctLength = len == 10 || len == 26 || len == 40; bool onlyHex = new Regex("^[0-9A-F]+$").IsMatch(password); return correctLength && onlyHex; case Dot11CipherAlgorithm.CCMP: // WPA2-PSK 8 to 63 ASCII characters case Dot11CipherAlgorithm.TKIP: // WPA-PSK 8 to 63 ASCII characters if (string.IsNullOrEmpty(password)) return false; return 8 <= password.Length && password.Length <= 63; default: return true; } }