| 985 | } |
| 986 | |
| 987 | static void |
| 988 | hostap_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: |
no test coverage detected