使用预共享密钥连接到WPA2私有

时间:2014-03-12 01:50:16

标签: android networking wpa

我在连接到仅使用AES时遇到问题。 我可以使用WPA2(TKIP)而不是(CCMP)成功连接。如果我在最后注释掉两条TKIP线,我就不能连接了。我想知道CCMP是否在Android中实现了?

private WifiConfiguration getWifiConfiguration(ScanResult result, String password) {
  WifiConfiguration config = new WifiConfiguration();

  config.allowedAuthAlgorithms.clear();
  config.allowedGroupCiphers.clear();
  config.allowedKeyManagement.clear();
  config.allowedPairwiseCiphers.clear();
  config.allowedProtocols.clear();

  config.SSID = "\"" + result.SSID + "\"";
  config.BSSID = result.BSSID;
  config.preSharedKey = "\"" + password + "\"";
  config.status = WifiConfiguration.Status.ENABLED;
  config.hiddenSSID = false;

  config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
  config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
  config.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
  config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
  config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
  return config;
}

1 个答案:

答案 0 :(得分:1)

好的,我不能完全支持AES。需要支持CCMP和TKIP才能使AES工作。