net80211_crypto_tkip.c revision a399b7655a1d835aa8606c2b29e4e777baac8635
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* IEEE 802.11i TKIP crypto support.
*/
#include <sys/byteorder.h>
#include "net80211_impl.h"
static void tkip_detach(struct ieee80211_key *);
static int tkip_setkey(struct ieee80211_key *);
const struct ieee80211_cipher tkip = {
"TKIP",
};
struct tkip_ctx {
int tx_phase1_done;
int rx_phase1_done;
};
/* ARGSUSED */
static void *
{
return (NULL);
return (ctx);
}
static void
tkip_detach(struct ieee80211_key *k)
{
}
static int
tkip_setkey(struct ieee80211_key *k)
{
return (0);
return (1);
}
/*
* Add privacy headers appropriate for the specified key.
*/
static int
{
int hdrlen;
/*
* Handle TKIP counter measures requirement.
*/
return (0);
/*
* Copy down 802.11 header and add the IV, KeyID, and ExtIV.
*/
/*
* NB: software TKIP is not supported.
*/
if (k->wk_flags & IEEE80211_KEY_SWCRYPT)
return (0);
else
k->wk_keytsc++; /* wrap at 48 bits */
return (1);
}
{
}
/*
* Validate and strip privacy headers (and trailer) for a
* received frame. If necessary, decrypt the frame using
* the specified key.
*/
static int
{
struct ieee80211_frame tmp;
/*
* Header should have extended IV and sequence number;
* verify the former and validate the latter.
*/
/*
* No extended IV; discard frame.
*/
return (0);
}
/*
* Handle TKIP counter measures requirement.
*/
return (0);
/* NB: assume IEEEE80211_WEP_MINLEN covers the extended IV */
return (0);
/*
* NB: We can't update the rsc in the key until MIC is verified.
*
* We assume we are not preempted between doing the check above
* and updating wk_keyrsc when stripping the MIC in tkip_demic.
* Otherwise we might process another packet and discard it as
* a replay.
*/
/*
* NB: software TKIP is not supported.
*/
if (k->wk_flags & IEEE80211_KEY_SWCRYPT)
return (0);
/*
* Copy up 802.11 header and strip crypto bits.
*/
return (1);
}
/*
* Add MIC to the frame as needed.
*/
/* ARGSUSED */
static int
{
return (1);
}
/*
* Verify and strip MIC from the frame.
*/
/* ARGSUSED */
static int
{
/*
* NB: software TKIP is not supported.
*/
if (k->wk_flags & IEEE80211_KEY_SWMIC)
return (0);
/*
* Strip MIC from the tail.
*/
/*
* Ok to update rsc now that MIC has been verified.
*/
return (1);
}