diff options
-rw-r--r-- | sys/dev/ic/acx.c | 8 | ||||
-rw-r--r-- | sys/dev/ic/acx100.c | 17 | ||||
-rw-r--r-- | sys/dev/ic/acxvar.h | 4 | ||||
-rw-r--r-- | sys/dev/ic/ath.c | 15 | ||||
-rw-r--r-- | sys/dev/ic/malo.c | 22 | ||||
-rw-r--r-- | sys/dev/ic/pgt.c | 18 | ||||
-rw-r--r-- | sys/dev/pci/if_ipw.c | 10 | ||||
-rw-r--r-- | sys/dev/pci/if_iwi.c | 13 | ||||
-rw-r--r-- | sys/dev/usb/if_atu.c | 12 | ||||
-rw-r--r-- | sys/dev/usb/if_ral.c | 6 | ||||
-rw-r--r-- | sys/dev/usb/if_uath.c | 19 | ||||
-rw-r--r-- | sys/net80211/ieee80211_crypto.c | 8 | ||||
-rw-r--r-- | sys/net80211/ieee80211_crypto.h | 31 | ||||
-rw-r--r-- | sys/net80211/ieee80211_ioctl.c | 36 | ||||
-rw-r--r-- | sys/net80211/ieee80211_var.h | 25 |
15 files changed, 123 insertions, 121 deletions
diff --git a/sys/dev/ic/acx.c b/sys/dev/ic/acx.c index 0298dc3c96c..2d2dd701a46 100644 --- a/sys/dev/ic/acx.c +++ b/sys/dev/ic/acx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acx.c,v 1.74 2007/05/03 21:24:56 mglocker Exp $ */ +/* $OpenBSD: acx.c,v 1.75 2007/07/18 18:10:31 damien Exp $ */ /* * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org> @@ -497,13 +497,13 @@ acx_set_crypt_keys(struct acx_softc *sc) int i, error, got_wk = 0; for (i = 0; i < IEEE80211_WEP_NKID; ++i) { - struct ieee80211_wepkey *wk = &ic->ic_nw_keys[i]; + struct ieee80211_key *k = &ic->ic_nw_keys[i]; - if (wk->wk_len == 0) + if (k->k_len == 0) continue; if (sc->chip_hw_crypt) { - error = sc->chip_set_wepkey(sc, wk, i); + error = sc->chip_set_wepkey(sc, k, i); if (error) return (error); got_wk = 1; diff --git a/sys/dev/ic/acx100.c b/sys/dev/ic/acx100.c index 6a00bcd65d0..8115121b521 100644 --- a/sys/dev/ic/acx100.c +++ b/sys/dev/ic/acx100.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acx100.c,v 1.18 2007/02/28 09:26:26 claudio Exp $ */ +/* $OpenBSD: acx100.c,v 1.19 2007/07/18 18:10:31 damien Exp $ */ /* * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org> @@ -112,8 +112,7 @@ int acx100_set_txpower(struct acx_softc *); void acx100_set_fw_txdesc_rate(struct acx_softc *, struct acx_txbuf *, int); void acx100_set_bss_join_param(struct acx_softc *, void *, int); -int acx100_set_wepkey(struct acx_softc *, struct ieee80211_wepkey *, - int); +int acx100_set_wepkey(struct acx_softc *, struct ieee80211_key *, int); void acx100_proc_wep_rxbuf(struct acx_softc *, struct mbuf *, int *); /* @@ -686,24 +685,24 @@ acx100_set_bss_join_param(struct acx_softc *sc, void *param, int dtim_intvl) } int -acx100_set_wepkey(struct acx_softc *sc, struct ieee80211_wepkey *wk, int wk_idx) +acx100_set_wepkey(struct acx_softc *sc, struct ieee80211_key *k, int k_idx) { struct acx100_conf_wepkey conf_wk; struct ifnet *ifp = &sc->sc_ic.ic_if; - if (wk->wk_len > ACX100_WEPKEY_LEN) { + if (k->k_len > ACX100_WEPKEY_LEN) { printf("%s: %dth WEP key size beyond %d\n", ifp->if_xname, wk_idx, ACX100_WEPKEY_LEN); return EINVAL; } conf_wk.action = ACX100_WEPKEY_ACT_ADD; - conf_wk.key_len = wk->wk_len; - conf_wk.key_idx = wk_idx; - bcopy(wk->wk_key, conf_wk.key, wk->wk_len); + conf_wk.key_len = k->k_len; + conf_wk.key_idx = k_idx; + bcopy(k->k_key, conf_wk.key, k->k_len); if (acx_set_conf(sc, ACX_CONF_WEPKEY, &conf_wk, sizeof(conf_wk)) != 0) { printf("%s: %s set %dth WEP key failed\n", - ifp->if_xname, __func__, wk_idx); + ifp->if_xname, __func__, k_idx); return ENXIO; } return 0; diff --git a/sys/dev/ic/acxvar.h b/sys/dev/ic/acxvar.h index 7d422528494..2692dfdfec6 100644 --- a/sys/dev/ic/acxvar.h +++ b/sys/dev/ic/acxvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: acxvar.h,v 1.17 2007/04/11 20:31:38 claudio Exp $ */ +/* $OpenBSD: acxvar.h,v 1.18 2007/07/18 18:10:31 damien Exp $ */ /* * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org> @@ -423,7 +423,7 @@ struct acx_softc { int (*chip_set_wepkey) (struct acx_softc *, - struct ieee80211_wepkey *, int); + struct ieee80211_key *, int); int (*chip_read_config) (struct acx_softc *, struct acx_config *); diff --git a/sys/dev/ic/ath.c b/sys/dev/ic/ath.c index 5afad58bf7c..0936ffc6a1e 100644 --- a/sys/dev/ic/ath.c +++ b/sys/dev/ic/ath.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ath.c,v 1.65 2007/06/16 13:17:05 damien Exp $ */ +/* $OpenBSD: ath.c,v 1.66 2007/07/18 18:10:31 damien Exp $ */ /* $NetBSD: ath.c,v 1.37 2004/08/18 21:59:39 dyoung Exp $ */ /*- @@ -1146,15 +1146,13 @@ ath_initkeytable(struct ath_softc *sc) /* XXX maybe should reset all keys when !WEPON */ for (i = 0; i < IEEE80211_WEP_NKID; i++) { - struct ieee80211_wepkey *k = &ic->ic_nw_keys[i]; - if (k->wk_len == 0) + struct ieee80211_key *k = &ic->ic_nw_keys[i]; + if (k->k_len == 0) ath_hal_reset_key(ah, i); else { HAL_KEYVAL hk; bzero(&hk, sizeof(hk)); - bcopy(k->wk_key, hk.wk_key, k->wk_len); - /* * Pad the key to a supported key length. It * is always a good idea to use full-length @@ -1162,14 +1160,13 @@ ath_initkeytable(struct ath_softc *sc) * to be the default behaviour used by many * implementations. */ - if (k->wk_len <= AR5K_KEYVAL_LENGTH_40) + if (k->k_cipher == IEEE80211_CIPHER_WEP40) hk.wk_len = AR5K_KEYVAL_LENGTH_40; - else if (k->wk_len <= AR5K_KEYVAL_LENGTH_104) + else if (k->k_cipher == IEEE80211_CIPHER_WEP104) hk.wk_len = AR5K_KEYVAL_LENGTH_104; - else if (k->wk_len <= AR5K_KEYVAL_LENGTH_128) - hk.wk_len = AR5K_KEYVAL_LENGTH_128; else return (EINVAL); + bcopy(k->k_key, hk.wk_key, hk.wk_len); if (ath_hal_set_key(ah, i, &hk) != AH_TRUE) return (EINVAL); diff --git a/sys/dev/ic/malo.c b/sys/dev/ic/malo.c index 6f34de7deb8..bd1562df756 100644 --- a/sys/dev/ic/malo.c +++ b/sys/dev/ic/malo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malo.c,v 1.71 2007/05/29 18:03:25 claudio Exp $ */ +/* $OpenBSD: malo.c,v 1.72 2007/07/18 18:10:31 damien Exp $ */ /* * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org> @@ -295,8 +295,8 @@ static char * static char * malo_cmd_string_result(uint16_t result); int malo_cmd_get_spec(struct malo_softc *sc); -int malo_cmd_set_wepkey(struct malo_softc *sc, struct ieee80211_wepkey *wk, - uint16_t wk_i); +int malo_cmd_set_wepkey(struct malo_softc *sc, struct ieee80211_key *k, + uint16_t k_index); int malo_cmd_set_prescan(struct malo_softc *sc); int malo_cmd_set_postscan(struct malo_softc *sc, uint8_t *macaddr, uint8_t ibsson); @@ -1946,12 +1946,12 @@ malo_set_wepkey(struct malo_softc *sc) int i; for (i = 0; i < IEEE80211_WEP_NKID; i++) { - struct ieee80211_wepkey *wk = &ic->ic_nw_keys[i]; + struct ieee80211_key *k = &ic->ic_nw_keys[i]; - if (wk->wk_len == 0) + if (k->k_len == 0) continue; - if (malo_cmd_set_wepkey(sc, wk, i)) + if (malo_cmd_set_wepkey(sc, k, i)) return (ENXIO); } @@ -2123,8 +2123,8 @@ malo_cmd_get_spec(struct malo_softc *sc) } int -malo_cmd_set_wepkey(struct malo_softc *sc, struct ieee80211_wepkey *wk, - uint16_t wk_index) +malo_cmd_set_wepkey(struct malo_softc *sc, struct ieee80211_key *k, + uint16_t k_index) { struct malo_cmdheader *hdr = sc->sc_cmd_mem; struct malo_cmd_wepkey *body; @@ -2138,9 +2138,9 @@ malo_cmd_set_wepkey(struct malo_softc *sc, struct ieee80211_wepkey *wk, bzero(body, sizeof(*body)); body->action = htole16(1); body->flags = 0; - body->index = wk_index; - body->len = wk->wk_len; - memcpy(body->value, wk->wk_key, wk->wk_len); + body->index = k_index; + body->len = k->k_len; + memcpy(body->value, k->k_key, k->k_len); bus_dmamap_sync(sc->sc_dmat, sc->sc_cmd_dmam, 0, PAGE_SIZE, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); diff --git a/sys/dev/ic/pgt.c b/sys/dev/ic/pgt.c index f10e1c6640a..67ca0e2d5bd 100644 --- a/sys/dev/ic/pgt.c +++ b/sys/dev/ic/pgt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pgt.c,v 1.42 2007/05/22 04:29:16 ray Exp $ */ +/* $OpenBSD: pgt.c,v 1.43 2007/07/18 18:10:31 damien Exp $ */ /* * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org> @@ -2775,32 +2775,32 @@ badopmode: keyobj.pok_length = min(sizeof(keyobj.pok_key), IEEE80211_KEYBUF_SIZE); keyobj.pok_length = min(keyobj.pok_length, - ic->ic_nw_keys[0].wk_len); - bcopy(ic->ic_nw_keys[0].wk_key, keyobj.pok_key, + ic->ic_nw_keys[0].k_len); + bcopy(ic->ic_nw_keys[0].k_key, keyobj.pok_key, keyobj.pok_length); SETOID(PGT_OID_DEFAULT_KEY0, &keyobj, sizeof(keyobj)); /* key 2 */ keyobj.pok_length = min(sizeof(keyobj.pok_key), IEEE80211_KEYBUF_SIZE); keyobj.pok_length = min(keyobj.pok_length, - ic->ic_nw_keys[1].wk_len); - bcopy(ic->ic_nw_keys[1].wk_key, keyobj.pok_key, + ic->ic_nw_keys[1].k_len); + bcopy(ic->ic_nw_keys[1].k_key, keyobj.pok_key, keyobj.pok_length); SETOID(PGT_OID_DEFAULT_KEY1, &keyobj, sizeof(keyobj)); /* key 3 */ keyobj.pok_length = min(sizeof(keyobj.pok_key), IEEE80211_KEYBUF_SIZE); keyobj.pok_length = min(keyobj.pok_length, - ic->ic_nw_keys[2].wk_len); - bcopy(ic->ic_nw_keys[2].wk_key, keyobj.pok_key, + ic->ic_nw_keys[2].k_len); + bcopy(ic->ic_nw_keys[2].k_key, keyobj.pok_key, keyobj.pok_length); SETOID(PGT_OID_DEFAULT_KEY2, &keyobj, sizeof(keyobj)); /* key 4 */ keyobj.pok_length = min(sizeof(keyobj.pok_key), IEEE80211_KEYBUF_SIZE); keyobj.pok_length = min(keyobj.pok_length, - ic->ic_nw_keys[3].wk_len); - bcopy(ic->ic_nw_keys[3].wk_key, keyobj.pok_key, + ic->ic_nw_keys[3].k_len); + bcopy(ic->ic_nw_keys[3].k_key, keyobj.pok_key, keyobj.pok_length); SETOID(PGT_OID_DEFAULT_KEY3, &keyobj, sizeof(keyobj)); diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c index 9e3a738784c..d2ae155d691 100644 --- a/sys/dev/pci/if_ipw.c +++ b/sys/dev/pci/if_ipw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ipw.c,v 1.66 2007/01/03 18:19:06 claudio Exp $ */ +/* $OpenBSD: if_ipw.c,v 1.67 2007/07/18 18:10:31 damien Exp $ */ /*- * Copyright (c) 2004-2006 @@ -1682,7 +1682,7 @@ ipw_config(struct ipw_softc *sc) struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &ic->ic_if; struct ipw_security security; - struct ieee80211_wepkey *k; + struct ieee80211_key *k; struct ipw_wep_key wepkey; struct ipw_scan_options options; struct ipw_configuration config; @@ -1821,13 +1821,13 @@ ipw_config(struct ipw_softc *sc) if (ic->ic_flags & IEEE80211_F_WEPON) { k = ic->ic_nw_keys; for (i = 0; i < IEEE80211_WEP_NKID; i++, k++) { - if (k->wk_len == 0) + if (k->k_len == 0) continue; wepkey.idx = i; - wepkey.len = k->wk_len; + wepkey.len = k->k_len; bzero(wepkey.key, sizeof wepkey.key); - bcopy(k->wk_key, wepkey.key, k->wk_len); + bcopy(k->k_key, wepkey.key, k->k_len); DPRINTF(("Setting wep key index %u len %u\n", wepkey.idx, wepkey.len)); error = ipw_cmd(sc, IPW_CMD_SET_WEP_KEY, &wepkey, diff --git a/sys/dev/pci/if_iwi.c b/sys/dev/pci/if_iwi.c index e057ac71b43..88f5b97cb4e 100644 --- a/sys/dev/pci/if_iwi.c +++ b/sys/dev/pci/if_iwi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwi.c,v 1.82 2007/07/06 18:03:42 damien Exp $ */ +/* $OpenBSD: if_iwi.c,v 1.83 2007/07/18 18:10:31 damien Exp $ */ /*- * Copyright (c) 2004-2006 @@ -1358,8 +1358,9 @@ iwi_tx_start(struct ifnet *ifp, struct mbuf *m0, struct ieee80211_node *ni) if (desc->wh.i_fc[1] & IEEE80211_FC1_WEP) { desc->wep_txkey = ic->ic_wep_txkey | - (ic->ic_nw_keys[ic->ic_wep_txkey].wk_len <= 5) ? - IWI_DATA_KEY_WEP40 : IWI_DATA_KEY_WEP104; + ((ic->ic_nw_keys[ic->ic_wep_txkey].k_cipher == + IEEE80211_CIPHER_WEP40) ? IWI_DATA_KEY_WEP40 : + IWI_DATA_KEY_WEP104); } else { desc->flags |= IWI_DATA_FLAG_NO_WEP; desc->wep_txkey = 0; @@ -1803,7 +1804,7 @@ iwi_config(struct iwi_softc *sc) struct iwi_configuration config; struct iwi_rateset rs; struct iwi_txpower power; - struct ieee80211_wepkey *k; + struct ieee80211_key *k; struct iwi_wep_key wepkey; uint32_t data; int error, nchan, i; @@ -1934,9 +1935,9 @@ iwi_config(struct iwi_softc *sc) for (i = 0; i < IEEE80211_WEP_NKID; i++, k++) { wepkey.cmd = IWI_WEP_KEY_CMD_SETKEY; wepkey.idx = i; - wepkey.len = k->wk_len; + wepkey.len = k->k_len; bzero(wepkey.key, sizeof wepkey.key); - bcopy(k->wk_key, wepkey.key, k->wk_len); + bcopy(k->k_key, wepkey.key, k->k_len); DPRINTF(("Setting wep key index %u len %u\n", wepkey.idx, wepkey.len)); error = iwi_cmd(sc, IWI_CMD_SET_WEP_KEY, &wepkey, diff --git a/sys/dev/usb/if_atu.c b/sys/dev/usb/if_atu.c index c2569ee4606..9cc51335637 100644 --- a/sys/dev/usb/if_atu.c +++ b/sys/dev/usb/if_atu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_atu.c,v 1.85 2007/06/14 10:11:15 mbalmer Exp $ */ +/* $OpenBSD: if_atu.c,v 1.86 2007/07/18 18:10:31 damien Exp $ */ /* * Copyright (c) 2003, 2004 * Daan Vreeken <Danovitsch@Vitsch.net>. All rights reserved. @@ -689,11 +689,11 @@ atu_initial_config(struct atu_softc *sc) cmd.PrivacyInvoked = (ic->ic_flags & IEEE80211_F_WEPON) ? 1 : 0; cmd.ExcludeUnencrypted = 0; - switch (ic->ic_nw_keys[ic->ic_wep_txkey].wk_len) { - case 5: + switch (ic->ic_nw_keys[ic->ic_wep_txkey].k_cipher) { + case IEEE80211_CIPHER_WEP40: cmd.EncryptionType = ATU_WEP_40BITS; break; - case 13: + case IEEE80211_CIPHER_WEP104: cmd.EncryptionType = ATU_WEP_104BITS; break; default: @@ -703,8 +703,8 @@ atu_initial_config(struct atu_softc *sc) cmd.WEP_DefaultKeyID = ic->ic_wep_txkey; for (i = 0; i < IEEE80211_WEP_NKID; i++) { - memcpy(cmd.WEP_DefaultKey[i], ic->ic_nw_keys[i].wk_key, - ic->ic_nw_keys[i].wk_len); + memcpy(cmd.WEP_DefaultKey[i], ic->ic_nw_keys[i].k_key, + ic->ic_nw_keys[i].k_len); } /* Setting the SSID here doesn't seem to do anything */ diff --git a/sys/dev/usb/if_ral.c b/sys/dev/usb/if_ral.c index 5132575bcf1..400c9a72c49 100644 --- a/sys/dev/usb/if_ral.c +++ b/sys/dev/usb/if_ral.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ral.c,v 1.99 2007/06/14 10:11:15 mbalmer Exp $ */ +/* $OpenBSD: if_ral.c,v 1.100 2007/07/18 18:10:31 damien Exp $ */ /*- * Copyright (c) 2005, 2006 @@ -1979,9 +1979,9 @@ ural_init(struct ifnet *ifp) * Copy WEP keys into adapter's memory (SEC_CSR0 to SEC_CSR31). */ for (i = 0; i < IEEE80211_WEP_NKID; i++) { - struct ieee80211_wepkey *wk = &ic->ic_nw_keys[i]; + struct ieee80211_key *k = &ic->ic_nw_keys[i]; ural_write_multi(sc, RAL_SEC_CSR0 + i * IEEE80211_KEYBUF_SIZE, - wk->wk_key, IEEE80211_KEYBUF_SIZE); + k->k_key, IEEE80211_KEYBUF_SIZE); } /* diff --git a/sys/dev/usb/if_uath.c b/sys/dev/usb/if_uath.c index f85dda16c6a..eedd8755a08 100644 --- a/sys/dev/usb/if_uath.c +++ b/sys/dev/usb/if_uath.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_uath.c,v 1.26 2007/06/14 10:11:15 mbalmer Exp $ */ +/* $OpenBSD: if_uath.c,v 1.27 2007/07/18 18:10:31 damien Exp $ */ /*- * Copyright (c) 2006 @@ -174,8 +174,7 @@ int uath_reset(struct uath_softc *); int uath_reset_tx_queues(struct uath_softc *); int uath_wme_init(struct uath_softc *); int uath_set_chan(struct uath_softc *, struct ieee80211_channel *); -int uath_set_key(struct uath_softc *, const struct ieee80211_wepkey *, - int); +int uath_set_key(struct uath_softc *, const struct ieee80211_key *, int); int uath_set_keys(struct uath_softc *); int uath_set_rates(struct uath_softc *, const struct ieee80211_rateset *); int uath_set_rxfilter(struct uath_softc *, uint32_t, uint32_t); @@ -1751,8 +1750,7 @@ uath_set_chan(struct uath_softc *sc, struct ieee80211_channel *c) } int -uath_set_key(struct uath_softc *sc, const struct ieee80211_wepkey *wk, - int index) +uath_set_key(struct uath_softc *sc, const struct ieee80211_key *k, int index) { struct uath_cmd_crypto crypto; int i; @@ -1771,10 +1769,10 @@ uath_set_key(struct uath_softc *sc, const struct ieee80211_wepkey *wk, * Each byte of the key must be XOR'ed with 10101010 before being * transmitted to the firmware. */ - for (i = 0; i < wk->wk_len; i++) - crypto.key[i] = wk->wk_key[i] ^ 0xaa; + for (i = 0; i < k->k_len; i++) + crypto.key[i] = k->k_key[i] ^ 0xaa; - DPRINTF(("setting crypto key index=%d len=%d\n", index, wk->wk_len)); + DPRINTF(("setting crypto key index=%d len=%d\n", index, k->k_len)); return uath_cmd_write(sc, UATH_CMD_CRYPTO, &crypto, sizeof crypto, 0); } @@ -1785,10 +1783,9 @@ uath_set_keys(struct uath_softc *sc) int i, error; for (i = 0; i < IEEE80211_WEP_NKID; i++) { - const struct ieee80211_wepkey *wk = &ic->ic_nw_keys[i]; + const struct ieee80211_key *k = &ic->ic_nw_keys[i]; - if (wk->wk_len > 0 && - (error = uath_set_key(sc, wk, i)) != 0) + if (k->k_len > 0 && (error = uath_set_key(sc, k, i)) != 0) return error; } return uath_set_key(sc, &ic->ic_nw_keys[ic->ic_wep_txkey], diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c index 0cfa8bb2a09..a89b4c68393 100644 --- a/sys/net80211/ieee80211_crypto.c +++ b/sys/net80211/ieee80211_crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_crypto.c,v 1.16 2007/07/14 20:00:33 damien Exp $ */ +/* $OpenBSD: ieee80211_crypto.c,v 1.17 2007/07/18 18:10:31 damien Exp $ */ /* $NetBSD: ieee80211_crypto.c,v 1.5 2003/12/14 09:56:53 dyoung Exp $ */ /*- @@ -218,9 +218,9 @@ ieee80211_wep_crypt(struct ifnet *ifp, struct mbuf *m0, int txflag) */ bzero(&keybuf, sizeof(keybuf)); memcpy(keybuf, ivp, IEEE80211_WEP_IVLEN); - memcpy(keybuf + IEEE80211_WEP_IVLEN, ic->ic_nw_keys[kid].wk_key, - ic->ic_nw_keys[kid].wk_len); - len = klen_round(IEEE80211_WEP_IVLEN + ic->ic_nw_keys[kid].wk_len); + memcpy(keybuf + IEEE80211_WEP_IVLEN, ic->ic_nw_keys[kid].k_key, + ic->ic_nw_keys[kid].k_len); + len = klen_round(IEEE80211_WEP_IVLEN + ic->ic_nw_keys[kid].k_len); arc4_setkey(ctx, keybuf, len); /* encrypt with calculating CRC */ diff --git a/sys/net80211/ieee80211_crypto.h b/sys/net80211/ieee80211_crypto.h index 828b2654c2c..3f8f63a4865 100644 --- a/sys/net80211/ieee80211_crypto.h +++ b/sys/net80211/ieee80211_crypto.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_crypto.h,v 1.2 2007/06/06 19:31:07 damien Exp $ */ +/* $OpenBSD: ieee80211_crypto.h,v 1.3 2007/07/18 18:10:31 damien Exp $ */ /* $NetBSD: ieee80211_crypto.h,v 1.2 2003/09/14 01:14:55 dyoung Exp $ */ /*- @@ -36,11 +36,34 @@ /* * 802.11 protocol crypto-related definitions. */ + +/* + * 802.11i ciphers. + */ +enum ieee80211_cipher { + IEEE80211_CIPHER_NONE = 0x00000000, + IEEE80211_CIPHER_USEGROUP = 0x00000001, + IEEE80211_CIPHER_WEP40 = 0x00000002, + IEEE80211_CIPHER_TKIP = 0x00000004, + IEEE80211_CIPHER_CCMP = 0x00000008, + IEEE80211_CIPHER_WEP104 = 0x00000010 +}; + +/* + * 802.11i Authentication and Key Management. + */ +enum ieee80211_akm { + IEEE80211_AKM_NONE = 0x00000000, + IEEE80211_AKM_IEEE8021X = 0x00000001, + IEEE80211_AKM_PSK = 0x00000002 +}; + #define IEEE80211_KEYBUF_SIZE 16 -struct ieee80211_wepkey { - int wk_len; - u_int8_t wk_key[IEEE80211_KEYBUF_SIZE]; +struct ieee80211_key { + enum ieee80211_cipher k_cipher; + int k_len; + u_int8_t k_key[IEEE80211_KEYBUF_SIZE]; }; extern void ieee80211_crypto_attach(struct ifnet *); diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c index b19c3a5a69e..eb885de759a 100644 --- a/sys/net80211/ieee80211_ioctl.c +++ b/sys/net80211/ieee80211_ioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_ioctl.c,v 1.18 2007/06/16 13:17:05 damien Exp $ */ +/* $OpenBSD: ieee80211_ioctl.c,v 1.19 2007/07/18 18:10:31 damien Exp $ */ /* $NetBSD: ieee80211_ioctl.c,v 1.15 2004/05/06 02:58:16 dyoung Exp $ */ /*- @@ -144,7 +144,7 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) struct ieee80211chanreq *chanreq; struct ieee80211_channel *chan; struct ieee80211_txpower *txpower; - struct ieee80211_wepkey keys[IEEE80211_WEP_NKID]; + struct ieee80211_key keys[IEEE80211_WEP_NKID]; static const u_int8_t empty_macaddr[IEEE80211_ADDR_LEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -203,27 +203,27 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) /* check and copy keys */ memset(keys, 0, sizeof(keys)); for (i = 0; i < IEEE80211_WEP_NKID; i++) { - keys[i].wk_len = nwkey->i_key[i].i_keylen; + keys[i].k_len = nwkey->i_key[i].i_keylen; /* * Limit the maximal allowed key size to * IEEE80211_KEYBUF_SIZE bytes. */ - if (keys[i].wk_len > sizeof(keys[i].wk_key)) { + if (keys[i].k_len > sizeof(keys[i].k_key)) { error = EINVAL; break; } - if (keys[i].wk_len <= 0) + if (keys[i].k_len <= 0) continue; if ((error = copyin(nwkey->i_key[i].i_keydat, - keys[i].wk_key, keys[i].wk_len)) != 0) + keys[i].k_key, keys[i].k_len)) != 0) break; } if (error) break; i = nwkey->i_defkid - 1; if (i < 0 || i >= IEEE80211_WEP_NKID || - keys[i].wk_len == 0 || - (keys[i].wk_len == -1 && ic->ic_nw_keys[i].wk_len == 0)) { + keys[i].k_len == 0 || + (keys[i].k_len == -1 && ic->ic_nw_keys[i].k_len == 0)) { if (nwkey->i_wepon != IEEE80211_NWKEY_OPEN) { error = EINVAL; break; @@ -236,11 +236,17 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) else ic->ic_flags |= IEEE80211_F_WEPON; for (i = 0; i < IEEE80211_WEP_NKID; i++) { - if (keys[i].wk_len < 0) + struct ieee80211_key *k = &ic->ic_nw_keys[i]; + if (keys[i].k_len < 0) continue; - ic->ic_nw_keys[i].wk_len = keys[i].wk_len; - memcpy(ic->ic_nw_keys[i].wk_key, keys[i].wk_key, - sizeof(keys[i].wk_key)); + if (keys[i].k_len == 0) + k->k_cipher = IEEE80211_CIPHER_NONE; + else if (keys[i].k_len <= 5) + k->k_cipher = IEEE80211_CIPHER_WEP40; + else + k->k_cipher = IEEE80211_CIPHER_WEP104; + k->k_len = keys[i].k_len; + memcpy(k->k_key, keys[i].k_key, sizeof(keys[i].k_key)); } error = ENETRESET; break; @@ -257,10 +263,10 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) /* do not show any keys to non-root user */ if ((error = suser(curproc, 0)) != 0) break; - nwkey->i_key[i].i_keylen = ic->ic_nw_keys[i].wk_len; - if ((error = copyout(ic->ic_nw_keys[i].wk_key, + nwkey->i_key[i].i_keylen = ic->ic_nw_keys[i].k_len; + if ((error = copyout(ic->ic_nw_keys[i].k_key, nwkey->i_key[i].i_keydat, - ic->ic_nw_keys[i].wk_len)) != 0) + ic->ic_nw_keys[i].k_len)) != 0) break; } break; diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index 0894f3e3a68..d7c1b61c3b3 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_var.h,v 1.29 2007/07/05 20:19:21 damien Exp $ */ +/* $OpenBSD: ieee80211_var.h,v 1.30 2007/07/18 18:10:31 damien Exp $ */ /* $NetBSD: ieee80211_var.h,v 1.7 2004/05/06 03:07:10 dyoung Exp $ */ /*- @@ -89,27 +89,6 @@ enum ieee80211_protmode { }; /* - * 802.11i ciphers. - */ -enum ieee80211_cipher { - IEEE80211_CIPHER_NONE = 0x00000000, - IEEE80211_CIPHER_USEGROUP = 0x00000001, - IEEE80211_CIPHER_WEP40 = 0x00000002, - IEEE80211_CIPHER_TKIP = 0x00000004, - IEEE80211_CIPHER_CCMP = 0x00000008, - IEEE80211_CIPHER_WEP104 = 0x00000010 -}; - -/* - * 802.11i Authentication and Key Management. - */ -enum ieee80211_akm { - IEEE80211_AKM_NONE = 0x00000000, - IEEE80211_AKM_IEEE8021X = 0x00000001, - IEEE80211_AKM_PSK = 0x00000002 -}; - -/* * Channels are specified by frequency and attributes. */ struct ieee80211_channel { @@ -243,7 +222,7 @@ struct ieee80211com { u_int8_t ic_des_essid[IEEE80211_NWID_LEN]; struct ieee80211_channel *ic_des_chan; /* desired channel */ u_int8_t ic_des_bssid[IEEE80211_ADDR_LEN]; - struct ieee80211_wepkey ic_nw_keys[IEEE80211_WEP_NKID]; + struct ieee80211_key ic_nw_keys[IEEE80211_WEP_NKID]; int ic_wep_txkey; /* default tx key index */ void *ic_wep_ctx; /* wep crypt context */ u_int32_t ic_iv; /* initial vector for wep */ |