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 /* 39 * IEEE 802.11 NULL crypto support. 40 */ 41 #include "net80211_impl.h" 42 43 static void *none_attach(struct ieee80211com *, struct ieee80211_key *); 44 static void none_detach(struct ieee80211_key *); 45 static int none_setkey(struct ieee80211_key *); 46 static int none_encap(struct ieee80211_key *, mblk_t *, uint8_t); 47 static int none_decap(struct ieee80211_key *, mblk_t *, int); 48 static int none_enmic(struct ieee80211_key *, mblk_t *, int); 49 static int none_demic(struct ieee80211_key *, mblk_t *, int); 50 51 const struct ieee80211_cipher ieee80211_cipher_none = { 52 "NONE", 53 IEEE80211_CIPHER_NONE, 54 0, 55 0, 56 0, 57 none_attach, 58 none_detach, 59 none_setkey, 60 none_encap, 61 none_decap, 62 none_enmic, 63 none_demic, 64 }; 65 66 /* ARGSUSED */ 67 static void * 68 none_attach(struct ieee80211com *ic, struct ieee80211_key *k) 69 { 70 return (ic); /* for diagnostics+stats */ 71 } 72 73 /* ARGSUSED */ 74 static void 75 none_detach(struct ieee80211_key *k) 76 { 77 /* noop */ 78 } 79 80 /* ARGSUSED */ 81 static int 82 none_setkey(struct ieee80211_key *k) 83 { 84 return (1); 85 } 86 87 /* ARGSUSED */ 88 static int 89 none_encap(struct ieee80211_key *k, mblk_t *mp, uint8_t keyid) 90 { 91 /* 92 * The specified key is not setup; this can 93 * happen, at least, when changing keys. 94 */ 95 ieee80211_dbg(IEEE80211_MSG_CRYPTO, "none_encap: " 96 "key id %u is not set (encap)\n", keyid >> 6); 97 return (0); 98 } 99 100 /* ARGSUSED */ 101 static int 102 none_decap(struct ieee80211_key *k, mblk_t *mp, int hdrlen) 103 { 104 struct ieee80211_frame *wh = (struct ieee80211_frame *)mp->b_rptr; 105 const uint8_t *ivp = (const uint8_t *)&wh[1]; 106 107 /* 108 * The specified key is not setup; this can 109 * happen, at least, when changing keys. 110 */ 111 ieee80211_dbg(IEEE80211_MSG_CRYPTO, "none_decap" 112 "key id %u is not set (decap)\n", 113 ivp[IEEE80211_WEP_IVLEN] >> 6); 114 return (0); 115 } 116 117 /* ARGSUSED */ 118 static int 119 none_enmic(struct ieee80211_key *k, mblk_t *mp, int force) 120 { 121 return (0); 122 } 123 124 /* ARGSUSED */ 125 static int 126 none_demic(struct ieee80211_key *k, mblk_t *mp, int force) 127 { 128 return (0); 129 } 130