ieee80211_crypto.c (283614) | ieee80211_crypto.c (288523) |
---|---|
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: --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 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: --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_crypto.c 283614 2015-05-27 14:05:46Z glebius $"); | 28__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_crypto.c 288523 2015-10-02 21:25:48Z adrian $"); |
29 30/* 31 * IEEE 802.11 generic crypto support. 32 */ 33#include "opt_wlan.h" 34 35#include <sys/param.h> 36#include <sys/kernel.h> --- 479 unchanged lines hidden (view full) --- 516 __func__, cip->ic_name, key->wk_keyix, 517 key->wk_keylen, key->wk_flags); 518 vap->iv_stats.is_crypto_setkey_cipher++; 519 return 0; 520 } 521 return dev_key_set(vap, key); 522} 523 | 29 30/* 31 * IEEE 802.11 generic crypto support. 32 */ 33#include "opt_wlan.h" 34 35#include <sys/param.h> 36#include <sys/kernel.h> --- 479 unchanged lines hidden (view full) --- 516 __func__, cip->ic_name, key->wk_keyix, 517 key->wk_keylen, key->wk_flags); 518 vap->iv_stats.is_crypto_setkey_cipher++; 519 return 0; 520 } 521 return dev_key_set(vap, key); 522} 523 |
524uint8_t 525ieee80211_crypto_get_keyid(struct ieee80211vap *vap, struct ieee80211_key *k) 526{ 527 if (k >= &vap->iv_nw_keys[0] && 528 k < &vap->iv_nw_keys[IEEE80211_WEP_NKID]) 529 return (k - vap->iv_nw_keys); 530 else 531 return (0); 532} 533 |
|
524/* 525 * Add privacy headers appropriate for the specified key. 526 */ 527struct ieee80211_key * 528ieee80211_crypto_encap(struct ieee80211_node *ni, struct mbuf *m) 529{ 530 struct ieee80211vap *vap = ni->ni_vap; 531 struct ieee80211_key *k; 532 struct ieee80211_frame *wh; 533 const struct ieee80211_cipher *cip; | 534/* 535 * Add privacy headers appropriate for the specified key. 536 */ 537struct ieee80211_key * 538ieee80211_crypto_encap(struct ieee80211_node *ni, struct mbuf *m) 539{ 540 struct ieee80211vap *vap = ni->ni_vap; 541 struct ieee80211_key *k; 542 struct ieee80211_frame *wh; 543 const struct ieee80211_cipher *cip; |
534 uint8_t keyid; | |
535 536 /* 537 * Multicast traffic always uses the multicast key. 538 * Otherwise if a unicast key is set we use that and 539 * it is always key index 0. When no unicast key is 540 * set we fall back to the default transmit key. 541 */ 542 wh = mtod(m, struct ieee80211_frame *); 543 if (IEEE80211_IS_MULTICAST(wh->i_addr1) || 544 IEEE80211_KEY_UNDEFINED(&ni->ni_ucastkey)) { 545 if (vap->iv_def_txkey == IEEE80211_KEYIX_NONE) { 546 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, 547 wh->i_addr1, 548 "no default transmit key (%s) deftxkey %u", 549 __func__, vap->iv_def_txkey); 550 vap->iv_stats.is_tx_nodefkey++; 551 return NULL; 552 } | 544 545 /* 546 * Multicast traffic always uses the multicast key. 547 * Otherwise if a unicast key is set we use that and 548 * it is always key index 0. When no unicast key is 549 * set we fall back to the default transmit key. 550 */ 551 wh = mtod(m, struct ieee80211_frame *); 552 if (IEEE80211_IS_MULTICAST(wh->i_addr1) || 553 IEEE80211_KEY_UNDEFINED(&ni->ni_ucastkey)) { 554 if (vap->iv_def_txkey == IEEE80211_KEYIX_NONE) { 555 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, 556 wh->i_addr1, 557 "no default transmit key (%s) deftxkey %u", 558 __func__, vap->iv_def_txkey); 559 vap->iv_stats.is_tx_nodefkey++; 560 return NULL; 561 } |
553 keyid = vap->iv_def_txkey; | |
554 k = &vap->iv_nw_keys[vap->iv_def_txkey]; | 562 k = &vap->iv_nw_keys[vap->iv_def_txkey]; |
555 } else { 556 keyid = 0; | 563 } else |
557 k = &ni->ni_ucastkey; | 564 k = &ni->ni_ucastkey; |
558 } | 565 |
559 cip = k->wk_cipher; | 566 cip = k->wk_cipher; |
560 return (cip->ic_encap(k, m, keyid<<6) ? k : NULL); | 567 return (cip->ic_encap(k, m) ? k : NULL); |
561} 562 563/* 564 * Validate and strip privacy headers (and trailer) for a 565 * received frame that has the WEP/Privacy bit set. 566 */ 567struct ieee80211_key * 568ieee80211_crypto_decap(struct ieee80211_node *ni, struct mbuf *m, int hdrlen) --- 93 unchanged lines hidden --- | 568} 569 570/* 571 * Validate and strip privacy headers (and trailer) for a 572 * received frame that has the WEP/Privacy bit set. 573 */ 574struct ieee80211_key * 575ieee80211_crypto_decap(struct ieee80211_node *ni, struct mbuf *m, int hdrlen) --- 93 unchanged lines hidden --- |