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