ieee80211_crypto_none.c revision 178354
11558Srgrimes/*- 21558Srgrimes * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting 31558Srgrimes * All rights reserved. 41558Srgrimes * 51558Srgrimes * Redistribution and use in source and binary forms, with or without 61558Srgrimes * modification, are permitted provided that the following conditions 71558Srgrimes * are met: 81558Srgrimes * 1. Redistributions of source code must retain the above copyright 91558Srgrimes * notice, this list of conditions and the following disclaimer. 101558Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111558Srgrimes * notice, this list of conditions and the following disclaimer in the 121558Srgrimes * documentation and/or other materials provided with the distribution. 131558Srgrimes * 141558Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 151558Srgrimes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 161558Srgrimes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 171558Srgrimes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 181558Srgrimes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 191558Srgrimes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 201558Srgrimes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 211558Srgrimes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 221558Srgrimes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 231558Srgrimes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 241558Srgrimes */ 251558Srgrimes 261558Srgrimes#include <sys/cdefs.h> 271558Srgrimes__FBSDID("$FreeBSD: head/sys/net80211/ieee80211_crypto_none.c 178354 2008-04-20 20:35:46Z sam $"); 281558Srgrimes 291558Srgrimes/* 301558Srgrimes * IEEE 802.11 NULL crypto support. 311558Srgrimes */ 321558Srgrimes#include "opt_wlan.h" 331558Srgrimes 341558Srgrimes#include <sys/param.h> 3536997Scharnier#include <sys/kernel.h> 361558Srgrimes#include <sys/systm.h> 371558Srgrimes#include <sys/mbuf.h> 381558Srgrimes#include <sys/module.h> 391558Srgrimes 401558Srgrimes#include <sys/socket.h> 4136997Scharnier 4223672Speter#include <net/if.h> 4336997Scharnier#include <net/if_media.h> 4436997Scharnier#include <net/ethernet.h> 4547446Sjmz 461558Srgrimes#include <net80211/ieee80211_var.h> 471558Srgrimes 481558Srgrimesstatic void *none_attach(struct ieee80211vap *, struct ieee80211_key *); 491558Srgrimesstatic void none_detach(struct ieee80211_key *); 501558Srgrimesstatic int none_setkey(struct ieee80211_key *); 511558Srgrimesstatic int none_encap(struct ieee80211_key *, struct mbuf *, uint8_t); 521558Srgrimesstatic int none_decap(struct ieee80211_key *, struct mbuf *, int); 531558Srgrimesstatic int none_enmic(struct ieee80211_key *, struct mbuf *, int); 541558Srgrimesstatic int none_demic(struct ieee80211_key *, struct mbuf *, int); 551558Srgrimes 5623672Speterconst struct ieee80211_cipher ieee80211_cipher_none = { 571558Srgrimes .ic_name = "NONE", 581558Srgrimes .ic_cipher = IEEE80211_CIPHER_NONE, 591558Srgrimes .ic_header = 0, 601558Srgrimes .ic_trailer = 0, 611558Srgrimes .ic_miclen = 0, 621558Srgrimes .ic_attach = none_attach, 6323672Speter .ic_detach = none_detach, 641558Srgrimes .ic_setkey = none_setkey, 651558Srgrimes .ic_encap = none_encap, 661558Srgrimes .ic_decap = none_decap, 671558Srgrimes .ic_enmic = none_enmic, 681558Srgrimes .ic_demic = none_demic, 691558Srgrimes}; 701558Srgrimes 711558Srgrimesstatic void * 721558Srgrimesnone_attach(struct ieee80211vap *vap, struct ieee80211_key *k) 731558Srgrimes{ 741558Srgrimes return vap; /* for diagnostics+stats */ 751558Srgrimes} 761558Srgrimes 771558Srgrimesstatic void 781558Srgrimesnone_detach(struct ieee80211_key *k) 791558Srgrimes{ 801558Srgrimes (void) k; 811558Srgrimes} 8212377Sjoerg 831558Srgrimesstatic int 841558Srgrimesnone_setkey(struct ieee80211_key *k) 8525288Swollman{ 861558Srgrimes (void) k; 871558Srgrimes return 1; 881558Srgrimes} 891558Srgrimes 9023672Speterstatic int 9123672Speternone_encap(struct ieee80211_key *k, struct mbuf *m, uint8_t keyid) 9223672Speter{ 931558Srgrimes struct ieee80211vap *vap = k->wk_private; 941558Srgrimes#ifdef IEEE80211_DEBUG 951558Srgrimes struct ieee80211_frame *wh = mtod(m, struct ieee80211_frame *); 961558Srgrimes#endif 9723672Speter 981558Srgrimes /* 991558Srgrimes * The specified key is not setup; this can 1008871Srgrimes * happen, at least, when changing keys. 1011558Srgrimes */ 1021558Srgrimes IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, wh->i_addr1, 1031558Srgrimes "key id %u is not set (encap)", keyid>>6); 10423672Speter vap->iv_stats.is_tx_badcipher++; 1051558Srgrimes return 0; 1061558Srgrimes} 1071558Srgrimes 1081558Srgrimesstatic int 1091558Srgrimesnone_decap(struct ieee80211_key *k, struct mbuf *m, int hdrlen) 1101558Srgrimes{ 1111558Srgrimes struct ieee80211vap *vap = k->wk_private; 11221409Simp#ifdef IEEE80211_DEBUG 11321409Simp struct ieee80211_frame *wh = mtod(m, struct ieee80211_frame *); 1141558Srgrimes const uint8_t *ivp = (const uint8_t *)&wh[1]; 1151558Srgrimes#endif 1161558Srgrimes 1171558Srgrimes /* 1181558Srgrimes * The specified key is not setup; this can 1191558Srgrimes * happen, at least, when changing keys. 12023672Speter */ 12123672Speter /* XXX useful to know dst too */ 1221558Srgrimes IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, wh->i_addr2, 12323672Speter "key id %u is not set (decap)", ivp[IEEE80211_WEP_IVLEN] >> 6); 12425288Swollman vap->iv_stats.is_rx_badkeyid++; 12525288Swollman return 0; 12625288Swollman} 12725288Swollman 12825288Swollmanstatic int 12925288Swollmannone_enmic(struct ieee80211_key *k, struct mbuf *m, int force) 13025288Swollman{ 13123672Speter struct ieee80211vap *vap = k->wk_private; 13223672Speter 13323672Speter vap->iv_stats.is_tx_badcipher++; 13423672Speter return 0; 13523672Speter} 1361558Srgrimes 1371558Srgrimesstatic int 13823672Speternone_demic(struct ieee80211_key *k, struct mbuf *m, int force) 13923672Speter{ 1401558Srgrimes struct ieee80211vap *vap = k->wk_private; 1411558Srgrimes 14223672Speter vap->iv_stats.is_rx_badkeyid++; 14323672Speter return 0; 14423672Speter} 1451558Srgrimes