1*3147Sxc151355 /*
2*3147Sxc151355 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3*3147Sxc151355 * Use is subject to license terms.
4*3147Sxc151355 */
5*3147Sxc151355
6*3147Sxc151355 /*
7*3147Sxc151355 * Copyright (c) 2001 Atsushi Onoe
8*3147Sxc151355 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
9*3147Sxc151355 * All rights reserved.
10*3147Sxc151355 *
11*3147Sxc151355 * Redistribution and use in source and binary forms, with or without
12*3147Sxc151355 * modification, are permitted provided that the following conditions
13*3147Sxc151355 * are met:
14*3147Sxc151355 * 1. Redistributions of source code must retain the above copyright
15*3147Sxc151355 * notice, this list of conditions and the following disclaimer.
16*3147Sxc151355 * 2. Redistributions in binary form must reproduce the above copyright
17*3147Sxc151355 * notice, this list of conditions and the following disclaimer in the
18*3147Sxc151355 * documentation and/or other materials provided with the distribution.
19*3147Sxc151355 * 3. The name of the author may not be used to endorse or promote products
20*3147Sxc151355 * derived from this software without specific prior written permission.
21*3147Sxc151355 *
22*3147Sxc151355 * Alternatively, this software may be distributed under the terms of the
23*3147Sxc151355 * GNU General Public License ("GPL") version 2 as published by the Free
24*3147Sxc151355 * Software Foundation.
25*3147Sxc151355 *
26*3147Sxc151355 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27*3147Sxc151355 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28*3147Sxc151355 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29*3147Sxc151355 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30*3147Sxc151355 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31*3147Sxc151355 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32*3147Sxc151355 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33*3147Sxc151355 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34*3147Sxc151355 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35*3147Sxc151355 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36*3147Sxc151355 */
37*3147Sxc151355
38*3147Sxc151355 #pragma ident "%Z%%M% %I% %E% SMI"
39*3147Sxc151355
40*3147Sxc151355 /*
41*3147Sxc151355 * IEEE 802.11 NULL crypto support.
42*3147Sxc151355 */
43*3147Sxc151355 #include "net80211_impl.h"
44*3147Sxc151355
45*3147Sxc151355 static void *none_attach(struct ieee80211com *, struct ieee80211_key *);
46*3147Sxc151355 static void none_detach(struct ieee80211_key *);
47*3147Sxc151355 static int none_setkey(struct ieee80211_key *);
48*3147Sxc151355 static int none_encap(struct ieee80211_key *, mblk_t *, uint8_t);
49*3147Sxc151355 static int none_decap(struct ieee80211_key *, mblk_t *, int);
50*3147Sxc151355 static int none_enmic(struct ieee80211_key *, mblk_t *, int);
51*3147Sxc151355 static int none_demic(struct ieee80211_key *, mblk_t *, int);
52*3147Sxc151355
53*3147Sxc151355 const struct ieee80211_cipher ieee80211_cipher_none = {
54*3147Sxc151355 "NONE",
55*3147Sxc151355 IEEE80211_CIPHER_NONE,
56*3147Sxc151355 0,
57*3147Sxc151355 0,
58*3147Sxc151355 0,
59*3147Sxc151355 none_attach,
60*3147Sxc151355 none_detach,
61*3147Sxc151355 none_setkey,
62*3147Sxc151355 none_encap,
63*3147Sxc151355 none_decap,
64*3147Sxc151355 none_enmic,
65*3147Sxc151355 none_demic,
66*3147Sxc151355 };
67*3147Sxc151355
68*3147Sxc151355 /* ARGSUSED */
69*3147Sxc151355 static void *
none_attach(struct ieee80211com * ic,struct ieee80211_key * k)70*3147Sxc151355 none_attach(struct ieee80211com *ic, struct ieee80211_key *k)
71*3147Sxc151355 {
72*3147Sxc151355 return (ic); /* for diagnostics+stats */
73*3147Sxc151355 }
74*3147Sxc151355
75*3147Sxc151355 /* ARGSUSED */
76*3147Sxc151355 static void
none_detach(struct ieee80211_key * k)77*3147Sxc151355 none_detach(struct ieee80211_key *k)
78*3147Sxc151355 {
79*3147Sxc151355 /* noop */
80*3147Sxc151355 }
81*3147Sxc151355
82*3147Sxc151355 /* ARGSUSED */
83*3147Sxc151355 static int
none_setkey(struct ieee80211_key * k)84*3147Sxc151355 none_setkey(struct ieee80211_key *k)
85*3147Sxc151355 {
86*3147Sxc151355 return (1);
87*3147Sxc151355 }
88*3147Sxc151355
89*3147Sxc151355 /* ARGSUSED */
90*3147Sxc151355 static int
none_encap(struct ieee80211_key * k,mblk_t * mp,uint8_t keyid)91*3147Sxc151355 none_encap(struct ieee80211_key *k, mblk_t *mp, uint8_t keyid)
92*3147Sxc151355 {
93*3147Sxc151355 /*
94*3147Sxc151355 * The specified key is not setup; this can
95*3147Sxc151355 * happen, at least, when changing keys.
96*3147Sxc151355 */
97*3147Sxc151355 ieee80211_dbg(IEEE80211_MSG_CRYPTO, "none_encap: "
98*3147Sxc151355 "key id %u is not set (encap)\n", keyid >> 6);
99*3147Sxc151355 return (0);
100*3147Sxc151355 }
101*3147Sxc151355
102*3147Sxc151355 /* ARGSUSED */
103*3147Sxc151355 static int
none_decap(struct ieee80211_key * k,mblk_t * mp,int hdrlen)104*3147Sxc151355 none_decap(struct ieee80211_key *k, mblk_t *mp, int hdrlen)
105*3147Sxc151355 {
106*3147Sxc151355 struct ieee80211_frame *wh = (struct ieee80211_frame *)mp->b_rptr;
107*3147Sxc151355 const uint8_t *ivp = (const uint8_t *)&wh[1];
108*3147Sxc151355
109*3147Sxc151355 /*
110*3147Sxc151355 * The specified key is not setup; this can
111*3147Sxc151355 * happen, at least, when changing keys.
112*3147Sxc151355 */
113*3147Sxc151355 ieee80211_dbg(IEEE80211_MSG_CRYPTO, "none_decap"
114*3147Sxc151355 "key id %u is not set (decap)\n",
115*3147Sxc151355 ivp[IEEE80211_WEP_IVLEN] >> 6);
116*3147Sxc151355 return (0);
117*3147Sxc151355 }
118*3147Sxc151355
119*3147Sxc151355 /* ARGSUSED */
120*3147Sxc151355 static int
none_enmic(struct ieee80211_key * k,mblk_t * mp,int force)121*3147Sxc151355 none_enmic(struct ieee80211_key *k, mblk_t *mp, int force)
122*3147Sxc151355 {
123*3147Sxc151355 return (0);
124*3147Sxc151355 }
125*3147Sxc151355
126*3147Sxc151355 /* ARGSUSED */
127*3147Sxc151355 static int
none_demic(struct ieee80211_key * k,mblk_t * mp,int force)128*3147Sxc151355 none_demic(struct ieee80211_key *k, mblk_t *mp, int force)
129*3147Sxc151355 {
130*3147Sxc151355 return (0);
131*3147Sxc151355 }
132