summaryrefslogtreecommitdiff
path: root/sys/net80211
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2004-06-28 19:29:41 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2004-06-28 19:29:41 +0000
commit73600bd52f726888381b776729d109b6c0890ac6 (patch)
tree411dd75f68c7c0bd7a2b503a947f28c21a5f86c8 /sys/net80211
parent575f07f1c83c88eceab3cfe3320a1a04ea957dee (diff)
Don't restrict WEP keys to exactly 40 or 108 bits.
Diffstat (limited to 'sys/net80211')
-rw-r--r--sys/net80211/ieee80211_crypto.c12
-rw-r--r--sys/net80211/ieee80211_ioctl.c12
2 files changed, 11 insertions, 13 deletions
diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c
index 6f79d9d5fb1..5c217985662 100644
--- a/sys/net80211/ieee80211_crypto.c
+++ b/sys/net80211/ieee80211_crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_crypto.c,v 1.2 2004/06/27 04:14:23 millert Exp $ */
+/* $OpenBSD: ieee80211_crypto.c,v 1.3 2004/06/28 19:29:40 millert Exp $ */
/* $NetBSD: ieee80211_crypto.c,v 1.5 2003/12/14 09:56:53 dyoung Exp $ */
/*-
@@ -130,6 +130,9 @@ ieee80211_crypto_detach(struct ifnet *ifp)
}
}
+/* Round up to a multiple of IEEE80211_WEP_KEYLEN + IEEE80211_WEP_IVLEN */
+#define klen_round(x) (((x) + (IEEE80211_WEP_KEYLEN + IEEE80211_WEP_IVLEN - 1)) & ~(IEEE80211_WEP_KEYLEN + IEEE80211_WEP_IVLEN - 1))
+
struct mbuf *
ieee80211_wep_crypt(struct ifnet *ifp, struct mbuf *m0, int txflag)
{
@@ -216,10 +219,9 @@ ieee80211_wep_crypt(struct ifnet *ifp, struct mbuf *m0, int txflag)
moff += IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN;
}
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);
- arc4_setkey(ctx, keybuf,
- IEEE80211_WEP_IVLEN + 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].wk_key, len);
+ arc4_setkey(ctx, keybuf, len);
/* encrypt with calculating CRC */
crc = ~0;
diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c
index b93647e45a6..e3d6574f671 100644
--- a/sys/net80211/ieee80211_ioctl.c
+++ b/sys/net80211/ieee80211_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_ioctl.c,v 1.2 2004/06/28 02:51:18 millert Exp $ */
+/* $OpenBSD: ieee80211_ioctl.c,v 1.3 2004/06/28 19:29:40 millert Exp $ */
/* $NetBSD: ieee80211_ioctl.c,v 1.15 2004/05/06 02:58:16 dyoung Exp $ */
/*-
@@ -271,10 +271,10 @@ ieee80211_cfgget(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
case WI_RID_DEFLT_CRYPT_KEYS:
keys = (struct wi_ltv_keys *)&wreq;
+ memset(keys, 0, sizeof(*keys));
/* do not show keys to non-root user */
error = suser(curproc, 0);
if (error) {
- memset(keys, 0, sizeof(*keys));
error = 0;
break;
}
@@ -722,9 +722,7 @@ ieee80211_cfgset(struct ifnet *ifp, u_long cmd, caddr_t data)
keys = (struct wi_ltv_keys *)&wreq;
for (i = 0; i < IEEE80211_WEP_NKID; i++) {
len = letoh16(keys->wi_keys[i].wi_keylen);
- if (len != 0 && len < IEEE80211_WEP_KEYLEN)
- return EINVAL;
- if (len > sizeof(ic->ic_nw_keys[i].wk_key))
+ if (len < 0 || len > sizeof(ic->ic_nw_keys[i].wk_key))
return EINVAL;
}
memset(ic->ic_nw_keys, 0, sizeof(ic->ic_nw_keys));
@@ -1182,9 +1180,7 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
memset(keys, 0, sizeof(keys));
for (i = 0; i < IEEE80211_WEP_NKID; i++) {
keys[i].wk_len = nwkey->i_key[i].i_keylen;
- if ((keys[i].wk_len > 0 &&
- keys[i].wk_len < IEEE80211_WEP_KEYLEN) ||
- keys[i].wk_len > sizeof(keys[i].wk_key)) {
+ if (keys[i].wk_len > sizeof(keys[i].wk_key)) {
error = EINVAL;
break;
}