MCPcopy Create free account
hub / github.com/F-Stack/f-stack / wpa_cipher

Function wpa_cipher

freebsd/net80211/ieee80211_hostap.c:1171–1203  ·  view source on GitHub ↗

* Convert a WPA cipher selector OUI to an internal * cipher algorithm. Where appropriate we also * record any key length. */

Source from the content-addressed store, hash-verified

1169 * record any key length.
1170 */
1171static int
1172wpa_cipher(const uint8_t *sel, uint8_t *keylen, uint8_t *cipher)
1173{
1174#define WPA_SEL(x) (((x)<<24)|WPA_OUI)
1175 uint32_t w = le32dec(sel);
1176
1177 switch (w) {
1178 case WPA_SEL(WPA_CSE_NULL):
1179 *cipher = IEEE80211_CIPHER_NONE;
1180 break;
1181 case WPA_SEL(WPA_CSE_WEP40):
1182 if (keylen)
1183 *keylen = 40 / NBBY;
1184 *cipher = IEEE80211_CIPHER_WEP;
1185 break;
1186 case WPA_SEL(WPA_CSE_WEP104):
1187 if (keylen)
1188 *keylen = 104 / NBBY;
1189 *cipher = IEEE80211_CIPHER_WEP;
1190 break;
1191 case WPA_SEL(WPA_CSE_TKIP):
1192 *cipher = IEEE80211_CIPHER_TKIP;
1193 break;
1194 case WPA_SEL(WPA_CSE_CCMP):
1195 *cipher = IEEE80211_CIPHER_AES_CCM;
1196 break;
1197 default:
1198 return (EINVAL);
1199 }
1200
1201 return (0);
1202#undef WPA_SEL
1203}
1204
1205/*
1206 * Convert a WPA key management/authentication algorithm

Callers 1

ieee80211_parse_wpaFunction · 0.70

Calls 1

le32decFunction · 0.85

Tested by

no test coverage detected