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