Home | History | Annotate | Line # | Download | only in net80211
ieee80211_crypto_none.c revision 1.3.6.2
      1  1.3.6.2  skrll /*-
      2  1.3.6.2  skrll  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
      3  1.3.6.2  skrll  * All rights reserved.
      4  1.3.6.2  skrll  *
      5  1.3.6.2  skrll  * Redistribution and use in source and binary forms, with or without
      6  1.3.6.2  skrll  * modification, are permitted provided that the following conditions
      7  1.3.6.2  skrll  * are met:
      8  1.3.6.2  skrll  * 1. Redistributions of source code must retain the above copyright
      9  1.3.6.2  skrll  *    notice, this list of conditions and the following disclaimer.
     10  1.3.6.2  skrll  * 2. Redistributions in binary form must reproduce the above copyright
     11  1.3.6.2  skrll  *    notice, this list of conditions and the following disclaimer in the
     12  1.3.6.2  skrll  *    documentation and/or other materials provided with the distribution.
     13  1.3.6.2  skrll  * 3. The name of the author may not be used to endorse or promote products
     14  1.3.6.2  skrll  *    derived from this software without specific prior written permission.
     15  1.3.6.2  skrll  *
     16  1.3.6.2  skrll  * Alternatively, this software may be distributed under the terms of the
     17  1.3.6.2  skrll  * GNU General Public License ("GPL") version 2 as published by the Free
     18  1.3.6.2  skrll  * Software Foundation.
     19  1.3.6.2  skrll  *
     20  1.3.6.2  skrll  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  1.3.6.2  skrll  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  1.3.6.2  skrll  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  1.3.6.2  skrll  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  1.3.6.2  skrll  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  1.3.6.2  skrll  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  1.3.6.2  skrll  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  1.3.6.2  skrll  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  1.3.6.2  skrll  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  1.3.6.2  skrll  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  1.3.6.2  skrll  */
     31  1.3.6.2  skrll 
     32  1.3.6.2  skrll #include <sys/cdefs.h>
     33  1.3.6.2  skrll #ifdef __FreeBSD__
     34  1.3.6.2  skrll __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_crypto_none.c,v 1.5 2005/06/10 16:11:24 sam Exp $");
     35  1.3.6.2  skrll #endif
     36  1.3.6.2  skrll #ifdef __NetBSD__
     37  1.3.6.2  skrll __KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto_none.c,v 1.3.6.2 2005/11/10 14:10:51 skrll Exp $");
     38  1.3.6.2  skrll #endif
     39  1.3.6.2  skrll 
     40  1.3.6.2  skrll /*
     41  1.3.6.2  skrll  * IEEE 802.11 NULL crypto support.
     42  1.3.6.2  skrll  */
     43  1.3.6.2  skrll #include <sys/param.h>
     44  1.3.6.2  skrll #include <sys/systm.h>
     45  1.3.6.2  skrll #include <sys/mbuf.h>
     46  1.3.6.2  skrll 
     47  1.3.6.2  skrll #include <sys/socket.h>
     48  1.3.6.2  skrll 
     49  1.3.6.2  skrll #include <net/if.h>
     50  1.3.6.2  skrll #include <net/if_media.h>
     51  1.3.6.2  skrll 
     52  1.3.6.2  skrll #include <net80211/ieee80211_var.h>
     53  1.3.6.2  skrll 
     54  1.3.6.2  skrll static	void *none_attach(struct ieee80211com *, struct ieee80211_key *);
     55  1.3.6.2  skrll static	void none_detach(struct ieee80211_key *);
     56  1.3.6.2  skrll static	int none_setkey(struct ieee80211_key *);
     57  1.3.6.2  skrll static	int none_encap(struct ieee80211_key *, struct mbuf *, u_int8_t);
     58  1.3.6.2  skrll static	int none_decap(struct ieee80211_key *, struct mbuf *, int);
     59  1.3.6.2  skrll static	int none_enmic(struct ieee80211_key *, struct mbuf *, int);
     60  1.3.6.2  skrll static	int none_demic(struct ieee80211_key *, struct mbuf *, int);
     61  1.3.6.2  skrll 
     62  1.3.6.2  skrll const struct ieee80211_cipher ieee80211_cipher_none = {
     63  1.3.6.2  skrll 	.ic_name	= "NONE",
     64  1.3.6.2  skrll 	.ic_cipher	= IEEE80211_CIPHER_NONE,
     65  1.3.6.2  skrll 	.ic_header	= 0,
     66  1.3.6.2  skrll 	.ic_trailer	= 0,
     67  1.3.6.2  skrll 	.ic_miclen	= 0,
     68  1.3.6.2  skrll 	.ic_attach	= none_attach,
     69  1.3.6.2  skrll 	.ic_detach	= none_detach,
     70  1.3.6.2  skrll 	.ic_setkey	= none_setkey,
     71  1.3.6.2  skrll 	.ic_encap	= none_encap,
     72  1.3.6.2  skrll 	.ic_decap	= none_decap,
     73  1.3.6.2  skrll 	.ic_enmic	= none_enmic,
     74  1.3.6.2  skrll 	.ic_demic	= none_demic,
     75  1.3.6.2  skrll };
     76  1.3.6.2  skrll 
     77  1.3.6.2  skrll static void *
     78  1.3.6.2  skrll none_attach(struct ieee80211com *ic, struct ieee80211_key *k)
     79  1.3.6.2  skrll {
     80  1.3.6.2  skrll 	return ic;		/* for diagnostics+stats */
     81  1.3.6.2  skrll }
     82  1.3.6.2  skrll 
     83  1.3.6.2  skrll static void
     84  1.3.6.2  skrll none_detach(struct ieee80211_key *k)
     85  1.3.6.2  skrll {
     86  1.3.6.2  skrll 	(void) k;
     87  1.3.6.2  skrll }
     88  1.3.6.2  skrll 
     89  1.3.6.2  skrll static int
     90  1.3.6.2  skrll none_setkey(struct ieee80211_key *k)
     91  1.3.6.2  skrll {
     92  1.3.6.2  skrll 	(void) k;
     93  1.3.6.2  skrll 	return 1;
     94  1.3.6.2  skrll }
     95  1.3.6.2  skrll 
     96  1.3.6.2  skrll static int
     97  1.3.6.2  skrll none_encap(struct ieee80211_key *k, struct mbuf *m, u_int8_t keyid)
     98  1.3.6.2  skrll {
     99  1.3.6.2  skrll 	struct ieee80211com *ic = k->wk_private;
    100  1.3.6.2  skrll #ifdef IEEE80211_DEBUG
    101  1.3.6.2  skrll 	struct ieee80211_frame *wh = mtod(m, struct ieee80211_frame *);
    102  1.3.6.2  skrll #endif
    103  1.3.6.2  skrll 
    104  1.3.6.2  skrll 	/*
    105  1.3.6.2  skrll 	 * The specified key is not setup; this can
    106  1.3.6.2  skrll 	 * happen, at least, when changing keys.
    107  1.3.6.2  skrll 	 */
    108  1.3.6.2  skrll 	IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,
    109  1.3.6.2  skrll 		"[%s] key id %u is not set (encap)\n",
    110  1.3.6.2  skrll 		ether_sprintf(wh->i_addr1), keyid>>6);
    111  1.3.6.2  skrll 	ic->ic_stats.is_tx_badcipher++;
    112  1.3.6.2  skrll 	return 0;
    113  1.3.6.2  skrll }
    114  1.3.6.2  skrll 
    115  1.3.6.2  skrll static int
    116  1.3.6.2  skrll none_decap(struct ieee80211_key *k, struct mbuf *m, int hdrlen)
    117  1.3.6.2  skrll {
    118  1.3.6.2  skrll 	struct ieee80211com *ic = k->wk_private;
    119  1.3.6.2  skrll #ifdef IEEE80211_DEBUG
    120  1.3.6.2  skrll 	struct ieee80211_frame *wh = mtod(m, struct ieee80211_frame *);
    121  1.3.6.2  skrll 	const u_int8_t *ivp = (const u_int8_t *)&wh[1];
    122  1.3.6.2  skrll #endif
    123  1.3.6.2  skrll 
    124  1.3.6.2  skrll 	/*
    125  1.3.6.2  skrll 	 * The specified key is not setup; this can
    126  1.3.6.2  skrll 	 * happen, at least, when changing keys.
    127  1.3.6.2  skrll 	 */
    128  1.3.6.2  skrll 	/* XXX useful to know dst too */
    129  1.3.6.2  skrll 	IEEE80211_DPRINTF(ic, IEEE80211_MSG_CRYPTO,
    130  1.3.6.2  skrll 		"[%s] key id %u is not set (decap)\n",
    131  1.3.6.2  skrll 		ether_sprintf(wh->i_addr2), ivp[IEEE80211_WEP_IVLEN] >> 6);
    132  1.3.6.2  skrll 	ic->ic_stats.is_rx_badkeyid++;
    133  1.3.6.2  skrll 	return 0;
    134  1.3.6.2  skrll }
    135  1.3.6.2  skrll 
    136  1.3.6.2  skrll static int
    137  1.3.6.2  skrll none_enmic(struct ieee80211_key *k, struct mbuf *m, int force)
    138  1.3.6.2  skrll {
    139  1.3.6.2  skrll 	struct ieee80211com *ic = k->wk_private;
    140  1.3.6.2  skrll 
    141  1.3.6.2  skrll 	ic->ic_stats.is_tx_badcipher++;
    142  1.3.6.2  skrll 	return 0;
    143  1.3.6.2  skrll }
    144  1.3.6.2  skrll 
    145  1.3.6.2  skrll static int
    146  1.3.6.2  skrll none_demic(struct ieee80211_key *k, struct mbuf *m, int force)
    147  1.3.6.2  skrll {
    148  1.3.6.2  skrll 	struct ieee80211com *ic = k->wk_private;
    149  1.3.6.2  skrll 
    150  1.3.6.2  skrll 	ic->ic_stats.is_rx_badkeyid++;
    151  1.3.6.2  skrll 	return 0;
    152  1.3.6.2  skrll }
    153