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

Function hostap_auth_shared

freebsd/net80211/ieee80211_hostap.c:987–1164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

985}
986
987static void
988hostap_auth_shared(struct ieee80211_node *ni, struct ieee80211_frame *wh,
989 uint8_t *frm, uint8_t *efrm, int rssi, int nf,
990 uint16_t seq, uint16_t status)
991{
992 struct ieee80211vap *vap = ni->ni_vap;
993 uint8_t *challenge;
994 int allocbs, estatus;
995
996 KASSERT(vap->iv_state == IEEE80211_S_RUN, ("state %d", vap->iv_state));
997
998 /*
999 * NB: this can happen as we allow pre-shared key
1000 * authentication to be enabled w/o wep being turned
1001 * on so that configuration of these can be done
1002 * in any order. It may be better to enforce the
1003 * ordering in which case this check would just be
1004 * for sanity/consistency.
1005 */
1006 if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) {
1007 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH,
1008 ni->ni_macaddr, "shared key auth",
1009 "%s", " PRIVACY is disabled");
1010 estatus = IEEE80211_STATUS_ALG;
1011 goto bad;
1012 }
1013 /*
1014 * Pre-shared key authentication is evil; accept
1015 * it only if explicitly configured (it is supported
1016 * mainly for compatibility with clients like Mac OS X).
1017 */
1018 if (ni->ni_authmode != IEEE80211_AUTH_AUTO &&
1019 ni->ni_authmode != IEEE80211_AUTH_SHARED) {
1020 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH,
1021 ni->ni_macaddr, "shared key auth",
1022 "bad sta auth mode %u", ni->ni_authmode);
1023 vap->iv_stats.is_rx_bad_auth++; /* XXX maybe a unique error? */
1024 estatus = IEEE80211_STATUS_ALG;
1025 goto bad;
1026 }
1027
1028 challenge = NULL;
1029 if (frm + 1 < efrm) {
1030 if ((frm[1] + 2) > (efrm - frm)) {
1031 IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH,
1032 ni->ni_macaddr, "shared key auth",
1033 "ie %d/%d too long",
1034 frm[0], (frm[1] + 2) - (efrm - frm));
1035 vap->iv_stats.is_rx_bad_auth++;
1036 estatus = IEEE80211_STATUS_CHALLENGE;
1037 goto bad;
1038 }
1039 if (*frm == IEEE80211_ELEMID_CHALLENGE)
1040 challenge = frm;
1041 frm += frm[1] + 2;
1042 }
1043 switch (seq) {
1044 case IEEE80211_AUTH_SHARED_CHALLENGE:

Callers 1

hostap_recv_mgmtFunction · 0.85

Calls 7

ieee80211_dup_bssFunction · 0.85
ieee80211_ref_nodeFunction · 0.85
ieee80211_node_authorizeFunction · 0.85
ieee80211_send_errorFunction · 0.85
get_random_bytesFunction · 0.70

Tested by

no test coverage detected