Deleted Added
full compact
ieee80211_crypto.c (138568) ieee80211_crypto.c (139504)
1/*-
2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2004 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:

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

26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001 Atsushi Onoe
3 * Copyright (c) 2002-2004 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:

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

26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_crypto.c 138568 2004-12-08 17:26:47Z sam $");
34__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_crypto.c 139504 2004-12-31 20:42:51Z sam $");
35
36/*
37 * IEEE 802.11 generic crypto support.
38 */
39#include <sys/param.h>
40#include <sys/mbuf.h>
41
42#include <sys/socket.h>

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

361 */
362static int
363_ieee80211_crypto_delkey(struct ieee80211com *ic, struct ieee80211_key *key)
364{
365 u_int16_t keyix;
366
367 KASSERT(key->wk_cipher != NULL, ("No cipher!"));
368
35
36/*
37 * IEEE 802.11 generic crypto support.
38 */
39#include <sys/param.h>
40#include <sys/mbuf.h>
41
42#include <sys/socket.h>

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

361 */
362static int
363_ieee80211_crypto_delkey(struct ieee80211com *ic, struct ieee80211_key *key)
364{
365 u_int16_t keyix;
366
367 KASSERT(key->wk_cipher != NULL, ("No cipher!"));
368
369 IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,
370 "%s: %s keyix %u flags 0x%x rsc %ju tsc %ju len %u\n",
371 __func__, key->wk_cipher->ic_name,
372 key->wk_keyix, key->wk_flags,
373 key->wk_keyrsc, key->wk_keytsc, key->wk_keylen);
374
369 keyix = key->wk_keyix;
370 if (keyix != IEEE80211_KEYIX_NONE) {
371 /*
372 * Remove hardware entry.
373 */
374 /* XXX key cache */
375 if (!dev_key_delete(ic, key)) {
376 IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,

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

431int
432ieee80211_crypto_setkey(struct ieee80211com *ic, struct ieee80211_key *key,
433 const u_int8_t macaddr[IEEE80211_ADDR_LEN])
434{
435 const struct ieee80211_cipher *cip = key->wk_cipher;
436
437 KASSERT(cip != NULL, ("No cipher!"));
438
375 keyix = key->wk_keyix;
376 if (keyix != IEEE80211_KEYIX_NONE) {
377 /*
378 * Remove hardware entry.
379 */
380 /* XXX key cache */
381 if (!dev_key_delete(ic, key)) {
382 IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,

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

437int
438ieee80211_crypto_setkey(struct ieee80211com *ic, struct ieee80211_key *key,
439 const u_int8_t macaddr[IEEE80211_ADDR_LEN])
440{
441 const struct ieee80211_cipher *cip = key->wk_cipher;
442
443 KASSERT(cip != NULL, ("No cipher!"));
444
445 IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,
446 "%s: %s keyix %u flags 0x%x mac %s rsc %ju tsc %ju len %u\n",
447 __func__, cip->ic_name, key->wk_keyix,
448 key->wk_flags, ether_sprintf(macaddr),
449 key->wk_keyrsc, key->wk_keytsc, key->wk_keylen);
450
439 /*
440 * Give cipher a chance to validate key contents.
441 * XXX should happen before modifying state.
442 */
443 if (!cip->ic_setkey(key)) {
444 IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,
445 "%s: cipher %s rejected key index %u len %u flags 0x%x\n",
446 __func__, cip->ic_name, key->wk_keyix,

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

476 * it is always key index 0. When no unicast key is
477 * set we fall back to the default transmit key.
478 */
479 wh = mtod(m, struct ieee80211_frame *);
480 if (IEEE80211_IS_MULTICAST(wh->i_addr1) ||
481 ni->ni_ucastkey.wk_cipher == &ieee80211_cipher_none) {
482 if (ic->ic_def_txkey == IEEE80211_KEYIX_NONE) {
483 IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,
451 /*
452 * Give cipher a chance to validate key contents.
453 * XXX should happen before modifying state.
454 */
455 if (!cip->ic_setkey(key)) {
456 IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,
457 "%s: cipher %s rejected key index %u len %u flags 0x%x\n",
458 __func__, cip->ic_name, key->wk_keyix,

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

488 * it is always key index 0. When no unicast key is
489 * set we fall back to the default transmit key.
490 */
491 wh = mtod(m, struct ieee80211_frame *);
492 if (IEEE80211_IS_MULTICAST(wh->i_addr1) ||
493 ni->ni_ucastkey.wk_cipher == &ieee80211_cipher_none) {
494 if (ic->ic_def_txkey == IEEE80211_KEYIX_NONE) {
495 IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,
484 "%s: No default xmit key for frame to %s\n",
485 __func__, ether_sprintf(wh->i_addr1));
496 "[%s] no default transmit key (%s) deftxkey %u\n",
497 ether_sprintf(wh->i_addr1), __func__,
498 ic->ic_def_txkey);
486 ic->ic_stats.is_tx_nodefkey++;
487 return NULL;
488 }
489 keyix = ic->ic_def_txkey;
490 k = &ic->ic_nw_keys[ic->ic_def_txkey];
491 } else {
492 keyix = 0;
493 k = &ni->ni_ucastkey;

--- 66 unchanged lines hidden ---
499 ic->ic_stats.is_tx_nodefkey++;
500 return NULL;
501 }
502 keyix = ic->ic_def_txkey;
503 k = &ic->ic_nw_keys[ic->ic_def_txkey];
504 } else {
505 keyix = 0;
506 k = &ni->ni_ucastkey;

--- 66 unchanged lines hidden ---