/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2008 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.
*/
/*
* IEEE 802.11 WEP crypto support.
*/
#include <sys/byteorder.h>
#include "net80211_impl.h"
static void wep_detach(struct ieee80211_key *);
static int wep_setkey(struct ieee80211_key *);
"WEP",
0,
};
struct wep_ctx {
};
/* Table of CRCs of all 8-bit messages */
/* ARGSUSED */
static void *
{
return (NULL);
sizeof (uint32_t));
return (ctx);
}
static void
{
}
static int
{
/*
* WEP key length is standardized to 40-bit. Many
* implementations support 104-bit WEP kwys.
*/
}
/*
* Add privacy headers appropriate for the specified key.
*/
static int
{
int hdrlen;
return (0);
/*
* IV must not duplicate during the lifetime of the key.
* But no mechanism to renew keys is defined in IEEE 802.11
* WEP. And IV may be duplicated between other stations
* because of the session key itself is shared.
* So we use pseudo random IV for now, though it is not the
* right way.
*/
/*
* (B, 255, N) with 3 <= B < 8
*/
if (3 <= B && B < 16)
}
/* Key ID and pad */
if ((k->wk_flags & IEEE80211_KEY_SWCRYPT) &&
return (0);
return (1);
}
/*
* Validate and strip privacy headers (and trailer) for a
* received frame. If necessary, decrypt the frame using
* the specified key.
*/
static int
{
/*
* Check if the device handled the decrypt in hardware.
* If so we just strip the header; otherwise we need to
* handle the decrypt in software.
*/
if ((k->wk_flags & IEEE80211_KEY_SWCRYPT) &&
ieee80211_err("WEP ICV mismatch on decrypt\n");
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
{
return (1);
}
static int
{
int rv;
/* ctx->wc_ic->isc_stats.is_crypto_wep++; */
if (rv != CRYPTO_SUCCESS)
return (0);
/* calculate CRC over unencrypted data */
-1U, crc_table);
/* encrypt data */
/* tack on ICV */
return (1);
}
static int
{
int rv;
/* ctx->wc_ic->isc_stats.is_crypto_wep++; */
if (rv != CRYPTO_SUCCESS)
return (0);
/* decrypt data */
/* calculate CRC over unencrypted data */
-1U, crc_table);
/* decrypt ICV and compare to CRC */
}
/*
* rc_init() - To init the key, for multiply encryption/decryption
* Using the Kernel encryption framework
*/
int
{
int rv;
/* keys are measured in bits, not bytes, so multiply by 8 */
mech.cm_param_len = 0;
if (rv != CRYPTO_SUCCESS)
return (rv);
}
/*
* rc4_crypt
*
* Use the Kernel encryption framework to provide the
* crypto operations for the indicated data.
*/
int
{
if (rv != CRYPTO_SUCCESS)
return (rv);
}
/*
* rc4_final
*
* Use the Kernel encryption framework to provide the
* crypto operations for the indicated data.
*/
int
{
if (rv != CRYPTO_SUCCESS)
return (rv);
}