summaryrefslogtreecommitdiffstats
path: root/sys/net80211/ieee80211_crypto_wep.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/net80211/ieee80211_crypto_wep.c')
-rw-r--r--sys/net80211/ieee80211_crypto_wep.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/sys/net80211/ieee80211_crypto_wep.c b/sys/net80211/ieee80211_crypto_wep.c
index 2e84dd0..dbcf765 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 int wep_encap(struct ieee80211_key *, struct mbuf *, uint8_t keyid);
-static int wep_decap(struct ieee80211_key *, struct mbuf *, int hdrlen);
+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);
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,29 +119,15 @@ 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, uint8_t keyid)
+static void
+wep_setiv(struct ieee80211_key *k, uint8_t *ivp)
{
struct wep_ctx *ctx = k->wk_private;
- struct ieee80211com *ic = ctx->wc_ic;
+ struct ieee80211vap *vap = ctx->wc_vap;
uint32_t iv;
- uint8_t *ivp;
- int hdrlen;
-
- hdrlen = ieee80211_hdrspace(ic, mtod(m, void *));
+ uint8_t keyid;
- /*
- * 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;
/*
* XXX
@@ -182,6 +170,32 @@ wep_encap(struct ieee80211_key *k, struct mbuf *m, uint8_t keyid)
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.
OpenPOWER on IntegriCloud