aboutsummaryrefslogtreecommitdiff
path: root/sys/net80211/ieee80211_crypto_wep.c
diff options
context:
space:
mode:
authorAdrian Chadd <adrian@FreeBSD.org>2015-10-03 00:50:13 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2015-10-03 00:50:13 +0000
commitc0cb93498d6b692947dbdc96a05a7b3014981f6d (patch)
treeb30b44f1253fc7f6f757a78b3eb32d055cfa6cc7 /sys/net80211/ieee80211_crypto_wep.c
parent483755be00ab05d61cc59a0d77cfcfb8bd68e117 (diff)
downloadsrc-c0cb93498d6b692947dbdc96a05a7b3014981f6d.tar.gz
src-c0cb93498d6b692947dbdc96a05a7b3014981f6d.zip
net80211: add new method for ieee80211_cipher (ic_setiv).
This can be used to update IV state for the caller without adding information to the mbuf. Some hardware (eg rum) apparently requires bits of this. Submitted by: <s3erios@gmail.com> Differential Revision: https://reviews.freebsd.org/D3638
Notes
Notes: svn path=/head/; revision=288526
Diffstat (limited to 'sys/net80211/ieee80211_crypto_wep.c')
-rw-r--r--sys/net80211/ieee80211_crypto_wep.c52
1 files changed, 31 insertions, 21 deletions
diff --git a/sys/net80211/ieee80211_crypto_wep.c b/sys/net80211/ieee80211_crypto_wep.c
index b99af5dd1ddc..dbcf765de608 100644
--- a/sys/net80211/ieee80211_crypto_wep.c
+++ b/sys/net80211/ieee80211_crypto_wep.c
@@ -50,8 +50,9 @@ __FBSDID("$FreeBSD$");
static void *wep_attach(struct ieee80211vap *, struct ieee80211_key *);
static void wep_detach(struct ieee80211_key *);
static int wep_setkey(struct ieee80211_key *);
+static void wep_setiv(struct ieee80211_key *, uint8_t *);
static int wep_encap(struct ieee80211_key *, struct mbuf *);
-static int wep_decap(struct ieee80211_key *, struct mbuf *, int hdrlen);
+static int wep_decap(struct ieee80211_key *, struct mbuf *, int);
static int wep_enmic(struct ieee80211_key *, struct mbuf *, int);
static int wep_demic(struct ieee80211_key *, struct mbuf *, int);
@@ -64,6 +65,7 @@ static const struct ieee80211_cipher wep = {
.ic_attach = wep_attach,
.ic_detach = wep_detach,
.ic_setkey = wep_setkey,
+ .ic_setiv = wep_setiv,
.ic_encap = wep_encap,
.ic_decap = wep_decap,
.ic_enmic = wep_enmic,
@@ -117,31 +119,13 @@ wep_setkey(struct ieee80211_key *k)
return k->wk_keylen >= 40/NBBY;
}
-/*
- * Add privacy headers appropriate for the specified key.
- */
-static int
-wep_encap(struct ieee80211_key *k, struct mbuf *m)
+static void
+wep_setiv(struct ieee80211_key *k, uint8_t *ivp)
{
struct wep_ctx *ctx = k->wk_private;
struct ieee80211vap *vap = ctx->wc_vap;
- struct ieee80211com *ic = ctx->wc_ic;
uint32_t iv;
- uint8_t *ivp;
uint8_t keyid;
- int hdrlen;
-
- hdrlen = ieee80211_hdrspace(ic, mtod(m, void *));
-
- /*
- * Copy down 802.11 header and add the IV + KeyID.
- */
- M_PREPEND(m, wep.ic_header, M_NOWAIT);
- if (m == NULL)
- return 0;
- ivp = mtod(m, uint8_t *);
- ovbcopy(ivp + wep.ic_header, ivp, hdrlen);
- ivp += hdrlen;
keyid = ieee80211_crypto_get_keyid(vap, k) << 6;
@@ -186,6 +170,32 @@ wep_encap(struct ieee80211_key *k, struct mbuf *m)
ivp[0] = iv >> 16;
#endif
ivp[3] = keyid;
+}
+
+/*
+ * Add privacy headers appropriate for the specified key.
+ */
+static int
+wep_encap(struct ieee80211_key *k, struct mbuf *m)
+{
+ struct wep_ctx *ctx = k->wk_private;
+ struct ieee80211com *ic = ctx->wc_ic;
+ uint8_t *ivp;
+ int hdrlen;
+
+ hdrlen = ieee80211_hdrspace(ic, mtod(m, void *));
+
+ /*
+ * Copy down 802.11 header and add the IV + KeyID.
+ */
+ M_PREPEND(m, wep.ic_header, M_NOWAIT);
+ if (m == NULL)
+ return 0;
+ ivp = mtod(m, uint8_t *);
+ ovbcopy(ivp + wep.ic_header, ivp, hdrlen);
+ ivp += hdrlen;
+
+ wep_setiv(k, ivp);
/*
* Finally, do software encrypt if needed.