Deleted Added
1/*-
2 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 68 unchanged lines hidden (view full) ---

77static int wep_encrypt(struct ieee80211_key *, struct mbuf *, int hdrlen);
78static int wep_decrypt(struct ieee80211_key *, struct mbuf *, int hdrlen);
79
80struct wep_ctx {
81 struct ieee80211com *wc_ic; /* for diagnostics */
82 u_int32_t wc_iv; /* initial vector for crypto */
83};
84
85static void *
86wep_attach(struct ieee80211com *ic, struct ieee80211_key *k)
87{
88 struct wep_ctx *ctx;
89
90 MALLOC(ctx, struct wep_ctx *, sizeof(struct wep_ctx),
91 M_DEVBUF, M_NOWAIT | M_ZERO);
92 if (ctx == NULL) {
93 ic->ic_stats.is_crypto_nomem++;
94 return NULL;
95 }
96
97 ctx->wc_ic = ic;
98 get_random_bytes(&ctx->wc_iv, sizeof(ctx->wc_iv));
99 return ctx;
100}
101
102static void
103wep_detach(struct ieee80211_key *k)
104{
105 struct wep_ctx *ctx = k->wk_private;
106
107 FREE(ctx, M_DEVBUF);
108}
109
110static int
111wep_setkey(struct ieee80211_key *k)
112{
113 return k->wk_keylen >= 40/NBBY;
114}
115

--- 360 unchanged lines hidden (view full) ---

476static int
477wep_modevent(module_t mod, int type, void *unused)
478{
479 switch (type) {
480 case MOD_LOAD:
481 ieee80211_crypto_register(&wep);
482 return 0;
483 case MOD_UNLOAD:
484 ieee80211_crypto_unregister(&wep);
485 return 0;
486 }
487 return EINVAL;
488}
489
490static moduledata_t wep_mod = {
491 "wlan_wep",
492 wep_modevent,
493 0
494};
495DECLARE_MODULE(wlan_wep, wep_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
496MODULE_VERSION(wlan_wep, 1);
497MODULE_DEPEND(wlan_wep, wlan, 1, 1, 1);