summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/man/man4/ath.45
-rw-r--r--sys/dev/ic/ar5210.c8
-rw-r--r--sys/dev/ic/ar5211.c8
-rw-r--r--sys/dev/ic/ar5212.c8
-rw-r--r--sys/dev/ic/ar5xxx.h9
-rw-r--r--sys/dev/ic/ath.c38
6 files changed, 52 insertions, 24 deletions
diff --git a/share/man/man4/ath.4 b/share/man/man4/ath.4
index 3978908db74..aac58a9e327 100644
--- a/share/man/man4/ath.4
+++ b/share/man/man4/ath.4
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ath.4,v 1.17 2005/03/12 10:32:40 jmc Exp $
+.\" $OpenBSD: ath.4,v 1.18 2005/04/06 09:14:53 reyk Exp $
.\" $NetBSD: ath.4,v 1.5 2004/07/03 16:58:18 mycroft Exp $
.\"
.\" Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
@@ -396,6 +396,9 @@ as requested.
The status code is explained in the HAL include file
.Pa /sys/dev/ic/ar5xxx.h .
This should not happen.
+.It "ath%d: unable to initialize the key cache"
+The driver was unable to initialize the hardware key cache.
+This should not happen.
.It "ath%d: unable to start recv logic"
The driver was unable to restart frame reception.
This should not happen.
diff --git a/sys/dev/ic/ar5210.c b/sys/dev/ic/ar5210.c
index 85f85b673d0..23f620d6998 100644
--- a/sys/dev/ic/ar5210.c
+++ b/sys/dev/ic/ar5210.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar5210.c,v 1.16 2005/03/20 04:21:55 reyk Exp $ */
+/* $OpenBSD: ar5210.c,v 1.17 2005/04/06 09:14:53 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -1928,13 +1928,13 @@ ar5k_ar5210_setKeyCacheEntry(hal, entry, keyval, mac, xor_notused)
bzero(&key_v, sizeof(key_v));
switch (keyval->wk_len) {
- case 5:
+ case AR5K_KEYVAL_LENGTH_40:
bcopy(keyval->wk_key, &key_v[0], 4);
bcopy(keyval->wk_key + 4, &key_v[1], 1);
key_v[5] = AR5K_AR5210_KEYTABLE_TYPE_40;
break;
- case 13:
+ case AR5K_KEYVAL_LENGTH_104:
bcopy(keyval->wk_key, &key_v[0], 4);
bcopy(keyval->wk_key + 4, &key_v[1], 2);
bcopy(keyval->wk_key + 6, &key_v[2], 4);
@@ -1943,7 +1943,7 @@ ar5k_ar5210_setKeyCacheEntry(hal, entry, keyval, mac, xor_notused)
key_v[5] = AR5K_AR5210_KEYTABLE_TYPE_104;
break;
- case 16:
+ case AR5K_KEYVAL_LENGTH_128:
bcopy(keyval->wk_key, &key_v[0], 4);
bcopy(keyval->wk_key + 4, &key_v[1], 2);
bcopy(keyval->wk_key + 6, &key_v[2], 4);
diff --git a/sys/dev/ic/ar5211.c b/sys/dev/ic/ar5211.c
index ba8b4fd1291..12325475951 100644
--- a/sys/dev/ic/ar5211.c
+++ b/sys/dev/ic/ar5211.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar5211.c,v 1.7 2005/03/23 16:23:18 reyk Exp $ */
+/* $OpenBSD: ar5211.c,v 1.8 2005/04/06 09:14:53 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -1997,13 +1997,13 @@ ar5k_ar5211_setKeyCacheEntry(hal, entry, keyval, mac, xor_notused)
bzero(&key_v, sizeof(key_v));
switch (keyval->wk_len) {
- case 5:
+ case AR5K_KEYVAL_LENGTH_40:
bcopy(keyval->wk_key, &key_v[0], 4);
bcopy(keyval->wk_key + 4, &key_v[1], 1);
key_v[5] = AR5K_AR5211_KEYTABLE_TYPE_40;
break;
- case 13:
+ case AR5K_KEYVAL_LENGTH_104:
bcopy(keyval->wk_key, &key_v[0], 4);
bcopy(keyval->wk_key + 4, &key_v[1], 2);
bcopy(keyval->wk_key + 6, &key_v[2], 4);
@@ -2012,7 +2012,7 @@ ar5k_ar5211_setKeyCacheEntry(hal, entry, keyval, mac, xor_notused)
key_v[5] = AR5K_AR5211_KEYTABLE_TYPE_104;
break;
- case 16:
+ case AR5K_KEYVAL_LENGTH_128:
bcopy(keyval->wk_key, &key_v[0], 4);
bcopy(keyval->wk_key + 4, &key_v[1], 2);
bcopy(keyval->wk_key + 6, &key_v[2], 4);
diff --git a/sys/dev/ic/ar5212.c b/sys/dev/ic/ar5212.c
index e7ed9a17b2d..ec6e5bae051 100644
--- a/sys/dev/ic/ar5212.c
+++ b/sys/dev/ic/ar5212.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar5212.c,v 1.11 2005/03/23 16:23:18 reyk Exp $ */
+/* $OpenBSD: ar5212.c,v 1.12 2005/04/06 09:14:53 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -2280,13 +2280,13 @@ ar5k_ar5212_setKeyCacheEntry(hal, entry, keyval, mac, xor_notused)
bzero(&key_v, sizeof(key_v));
switch (keyval->wk_len) {
- case 5:
+ case AR5K_KEYVAL_LENGTH_40:
bcopy(keyval->wk_key, &key_v[0], 4);
bcopy(keyval->wk_key + 4, &key_v[1], 1);
key_v[5] = AR5K_AR5212_KEYTABLE_TYPE_40;
break;
- case 13:
+ case AR5K_KEYVAL_LENGTH_104:
bcopy(keyval->wk_key, &key_v[0], 4);
bcopy(keyval->wk_key + 4, &key_v[1], 2);
bcopy(keyval->wk_key + 6, &key_v[2], 4);
@@ -2295,7 +2295,7 @@ ar5k_ar5212_setKeyCacheEntry(hal, entry, keyval, mac, xor_notused)
key_v[5] = AR5K_AR5212_KEYTABLE_TYPE_104;
break;
- case 16:
+ case AR5K_KEYVAL_LENGTH_128:
bcopy(keyval->wk_key, &key_v[0], 4);
bcopy(keyval->wk_key + 4, &key_v[1], 2);
bcopy(keyval->wk_key + 6, &key_v[2], 4);
diff --git a/sys/dev/ic/ar5xxx.h b/sys/dev/ic/ar5xxx.h
index de4723bfef2..b0a3460f083 100644
--- a/sys/dev/ic/ar5xxx.h
+++ b/sys/dev/ic/ar5xxx.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar5xxx.h,v 1.15 2005/03/20 04:21:55 reyk Exp $ */
+/* $OpenBSD: ar5xxx.h,v 1.16 2005/04/06 09:14:53 reyk Exp $ */
/*
* Copyright (c) 2004, 2005 Reyk Floeter <reyk@vantronix.net>
@@ -309,11 +309,14 @@ typedef enum {
HAL_CIPHER_CKIP,
} HAL_CIPHER;
-#define AR5K_MAX_KEYS 16
+#define AR5K_KEYVAL_LENGTH_40 5
+#define AR5K_KEYVAL_LENGTH_104 13
+#define AR5K_KEYVAL_LENGTH_128 16
+#define AR5K_KEYVAL_LENGTH_MAX AR5K_KEYVAL_LENGTH_128
typedef struct {
int wk_len;
- u_int8_t wk_key[AR5K_MAX_KEYS];
+ u_int8_t wk_key[AR5K_KEYVAL_LENGTH_MAX];
} HAL_KEYVAL;
#define AR5K_ASSERT_ENTRY(_e, _s) do { \
diff --git a/sys/dev/ic/ath.c b/sys/dev/ic/ath.c
index db9ef966a3b..a2cc2fe2fe0 100644
--- a/sys/dev/ic/ath.c
+++ b/sys/dev/ic/ath.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ath.c,v 1.20 2005/04/06 00:42:59 kevlo Exp $ */
+/* $OpenBSD: ath.c,v 1.21 2005/04/06 09:14:53 reyk Exp $ */
/* $NetBSD: ath.c,v 1.37 2004/08/18 21:59:39 dyoung Exp $ */
/*-
@@ -96,7 +96,7 @@ void ath_fatal_proc(void *, int);
void ath_rxorn_proc(void *, int);
void ath_bmiss_proc(void *, int);
u_int ath_chan2flags(struct ieee80211com *, struct ieee80211_channel *);
-void ath_initkeytable(struct ath_softc *);
+int ath_initkeytable(struct ath_softc *);
void ath_mcastfilter_accum(caddr_t, u_int32_t (*)[2]);
void ath_mcastfilter_compute(struct ath_softc *, u_int32_t (*)[2]);
u_int32_t ath_calcrxfilter(struct ath_softc *);
@@ -722,8 +722,12 @@ ath_init1(struct ath_softc *sc)
* in the frame output path; there's nothing to do
* here except setup the interrupt mask.
*/
- if (ic->ic_flags & IEEE80211_F_WEPON)
- ath_initkeytable(sc);
+ if (ic->ic_flags & IEEE80211_F_WEPON) {
+ if ((error = ath_initkeytable(sc)) != 0) {
+ if_printf(ifp, "unable to initialize the key cache\n");
+ goto done;
+ }
+ }
if ((error = ath_startrecv(sc)) != 0) {
if_printf(ifp, "unable to start recv logic\n");
goto done;
@@ -1112,7 +1116,7 @@ ath_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
/*
* Fill the hardware key cache with key entries.
*/
-void
+int
ath_initkeytable(struct ath_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
@@ -1128,12 +1132,30 @@ ath_initkeytable(struct ath_softc *sc)
HAL_KEYVAL hk;
bzero(&hk, sizeof(hk));
- hk.wk_len = k->wk_len;
bcopy(k->wk_key, hk.wk_key, k->wk_len);
- /* XXX return value */
- ath_hal_keyset(ah, i, &hk);
+
+ /*
+ * Pad the key to a supported key length. It
+ * is always a good idea to use full-length
+ * keys without padded zeros but this seems
+ * to be the default behaviour used by many
+ * implementations.
+ */
+ if (k->wk_len <= AR5K_KEYVAL_LENGTH_40)
+ hk.wk_len = AR5K_KEYVAL_LENGTH_40;
+ else if (k->wk_len <= AR5K_KEYVAL_LENGTH_104)
+ 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);
+
+ if (ath_hal_keyset(ah, i, &hk) != AH_TRUE)
+ return (EINVAL);
}
}
+
+ return (0);
}
void