2 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * Alternatively, this software may be distributed under the terms of the
17 * GNU General Public License ("GPL") version 2 as published by the Free
18 * Software Foundation.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * $FreeBSD: src/sys/net80211/ieee80211_crypto_none.c,v 1.5 2005/06/10 16:11:24 sam Exp $
32 * $DragonFly: src/sys/netproto/802_11/wlan/ieee80211_crypto_none.c,v 1.1 2006/05/18 13:51:46 sephe Exp $
36 * IEEE 802.11 NULL crypto support.
38 #include <sys/param.h>
39 #include <sys/systm.h>
41 #include <sys/module.h>
43 #include <sys/socket.h>
46 #include <net/if_arp.h>
47 #include <net/if_media.h>
48 #include <net/ethernet.h>
50 #include <netproto/802_11/ieee80211_var.h>
52 static void *none_attach(struct ieee80211com *, struct ieee80211_key *);
53 static void none_detach(struct ieee80211_key *);
54 static int none_setkey(struct ieee80211_key *);
55 static int none_encap(struct ieee80211_key *, struct mbuf *, uint8_t);
56 static int none_decap(struct ieee80211_key *, struct mbuf *, int);
57 static int none_enmic(struct ieee80211_key *, struct mbuf *, int);
58 static int none_demic(struct ieee80211_key *, struct mbuf *, int);
60 const struct ieee80211_cipher ieee80211_cipher_none = {
62 .ic_cipher = IEEE80211_CIPHER_NONE,
66 .ic_attach = none_attach,
67 .ic_detach = none_detach,
68 .ic_setkey = none_setkey,
69 .ic_encap = none_encap,
70 .ic_decap = none_decap,
71 .ic_enmic = none_enmic,
72 .ic_demic = none_demic,
76 none_attach(struct ieee80211com *ic, struct ieee80211_key *k)
78 return ic; /* for diagnostics+stats */
82 none_detach(struct ieee80211_key *k)
88 none_setkey(struct ieee80211_key *k)
95 none_encap(struct ieee80211_key *k, struct mbuf *m, uint8_t keyid)
97 struct ieee80211com *ic = k->wk_private;
98 #ifdef IEEE80211_DEBUG
99 struct ieee80211_frame *wh = mtod(m, struct ieee80211_frame *);
103 * The specified key is not setup; this can
104 * happen, at least, when changing keys.
106 IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,
107 "[%6D] key id %u is not set (encap)\n",
108 wh->i_addr1, ":", keyid>>6);
109 ic->ic_stats.is_tx_badcipher++;
114 none_decap(struct ieee80211_key *k, struct mbuf *m, int hdrlen)
116 struct ieee80211com *ic = k->wk_private;
117 #ifdef IEEE80211_DEBUG
118 struct ieee80211_frame *wh = mtod(m, struct ieee80211_frame *);
119 const uint8_t *ivp = (const uint8_t *)&wh[1];
123 * The specified key is not setup; this can
124 * happen, at least, when changing keys.
126 /* XXX useful to know dst too */
127 IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,
128 "[%6D] key id %u is not set (decap)\n",
129 wh->i_addr2, ":", ivp[IEEE80211_WEP_IVLEN] >> 6);
130 ic->ic_stats.is_rx_badkeyid++;
135 none_enmic(struct ieee80211_key *k, struct mbuf *m, int force)
137 struct ieee80211com *ic = k->wk_private;
139 ic->ic_stats.is_tx_badcipher++;
144 none_demic(struct ieee80211_key *k, struct mbuf *m, int force)
146 struct ieee80211com *ic = k->wk_private;
148 ic->ic_stats.is_rx_badkeyid++;