ieee80211_crypto.c (11d38a5764295585a2472d5e861fa8abe1a11eb2) ieee80211_crypto.c (ee9d294b3669bc8cbe3d782967bb547c73429f2f)
1/*-
2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 619 unchanged lines hidden (view full) ---

628 return NULL;
629 }
630
631 return (cip->ic_decap(k, m, hdrlen) ? k : NULL);
632#undef IEEE80211_WEP_MINLEN
633#undef IEEE80211_WEP_HDRLEN
634}
635
1/*-
2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 619 unchanged lines hidden (view full) ---

628 return NULL;
629 }
630
631 return (cip->ic_decap(k, m, hdrlen) ? k : NULL);
632#undef IEEE80211_WEP_MINLEN
633#undef IEEE80211_WEP_HDRLEN
634}
635
636
637/*
638 * Check and remove any MIC.
639 */
640int
641ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k,
642 struct mbuf *m, int force)
643{
644 const struct ieee80211_cipher *cip;
645 const struct ieee80211_rx_stats *rxs;
646 struct ieee80211_frame *wh;
647
648 rxs = ieee80211_get_rx_params_ptr(m);
649 wh = mtod(m, struct ieee80211_frame *);
650
651 /*
652 * Handle demic / mic errors from hardware-decrypted offload devices.
653 */
654 if ((rxs != NULL) && (rxs->c_pktflags & IEEE80211_RX_F_DECRYPTED)) {
655 if (rxs->c_pktflags & IEEE80211_RX_F_FAIL_MIC) {
656 /*
657 * Hardware has said MIC failed. We don't care about
658 * whether it was stripped or not.
659 *
660 * Eventually - teach the demic methods in crypto
661 * modules to handle a NULL key and not to dereference
662 * it.
663 */
664 ieee80211_notify_michael_failure(vap, wh, -1);
665 return (0);
666 }
667
668 if (rxs->c_pktflags & IEEE80211_RX_F_MMIC_STRIP) {
669 /*
670 * Hardware has decrypted and not indicated a
671 * MIC failure and has stripped the MIC.
672 * We may not have a key, so for now just
673 * return OK.
674 */
675 return (1);
676 }
677 }
678
679 /*
680 * If we don't have a key at this point then we don't
681 * have to demic anything.
682 */
683 if (k == NULL)
684 return (1);
685
686 cip = k->wk_cipher;
687 return (cip->ic_miclen > 0 ? cip->ic_demic(k, m, force) : 1);
688}
689
690
636static void
637load_ucastkey(void *arg, struct ieee80211_node *ni)
638{
639 struct ieee80211vap *vap = ni->ni_vap;
640 struct ieee80211_key *k;
641
642 if (vap->iv_state != IEEE80211_S_RUN)
643 return;

--- 34 unchanged lines hidden ---
691static void
692load_ucastkey(void *arg, struct ieee80211_node *ni)
693{
694 struct ieee80211vap *vap = ni->ni_vap;
695 struct ieee80211_key *k;
696
697 if (vap->iv_state != IEEE80211_S_RUN)
698 return;

--- 34 unchanged lines hidden ---