diff options
author | Damien Bergamini <damien@cvs.openbsd.org> | 2007-07-18 18:10:32 +0000 |
---|---|---|
committer | Damien Bergamini <damien@cvs.openbsd.org> | 2007-07-18 18:10:32 +0000 |
commit | b0b399694977801dc175a7554f8045923e44f7eb (patch) | |
tree | 7d1f39fd88f1022730d45f888f660cd787566366 /sys/dev | |
parent | f7f63cd087c89a071fd5bbd90a28ce1cf0d1275f (diff) |
replace the ieee80211_wepkey structure with a more generic ieee80211_key
one that can be used with other ciphers than WEP.
Diffstat (limited to 'sys/dev')
-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 |
11 files changed, 69 insertions, 75 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], |