net80211_crypto.h revision 239e91abc172c1397b1e94869c5d0e8ab67bfc22
/*
* 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"
#ifndef _SYS_NET80211_CRYPTO_H
#define _SYS_NET80211_CRYPTO_H
#include <sys/net80211_proto.h>
/*
* 802.11 protocol crypto-related definitions.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* NB: these values are ordered carefully; there are lots of
* of implications in any reordering.
*/
#define IEEE80211_CIPHER_WEP 0
#define IEEE80211_CIPHER_TKIP 1
#define IEEE80211_CIPHER_AES_OCB 2
#define IEEE80211_CIPHER_AES_CCM 3
#define IEEE80211_CIPHER_CKIP 4
/*
* Maxmium length of key in bytes
* WEP key length present in the 802.11 standard is 40-bit.
* Many implementations also support 104-bit WEP keys.
*/
#define IEEE80211_KEYBUF_SIZE 16
/* Key Flags */
#define IEEE80211_KEY_GROUP /* key used for WPA group operation */ \
0x04
#define IEEE80211_KEY_COMMON /* common flags passed in by apps */ \
/* WEP */
/*
* 802.11i defines an extended IV for use with non-WEP ciphers.
* When the EXTIV bit is set in the key id byte an additional
* 4 bytes immediately follow the IV for TKIP. For CCMP the
* EXTIV bit is likewise set but the 8 bytes represent the
* CCMP header rather than IV+extended-IV.
*/
#define IEEE80211_WEP_EXTIV 0x20
#define IEEE80211_WEP_HDRLEN \
#define IEEE80211_WEP_MINLEN \
(sizeof (struct ieee80211_frame) + \
/* Maximum number of keys */
#define IEEE80211_KEY_MAX IEEE80211_WEP_NKID
struct ieee80211com;
struct ieee80211_node;
struct ieee80211_key;
/*
* Template for a supported cipher. Ciphers register with the
* crypto code.
*
* ic_attach - Initialize cipher. The return value is set to wk_private
* ic_detach - Destruct a cipher.
* ic_setkey - Validate key contents
* ic_encap - Encrypt the 802.11 MAC payload
* ic_decap - Decrypt the 802.11 MAC payload
* ic_enmic - Add MIC
* ic_demic - Check and remove MIC
*/
struct ieee80211_cipher {
const char *ic_name; /* printable name */
void *(*ic_attach)(struct ieee80211com *,
struct ieee80211_key *);
void (*ic_detach)(struct ieee80211_key *);
};
extern const struct ieee80211_cipher ieee80211_cipher_none;
struct ieee80211_key {
const struct ieee80211_cipher *wk_cipher;
void *wk_private; /* private cipher state */
};
/*
* Crypto state kept in each ieee80211com.
*/
struct ieee80211_crypto_state {
int (*cs_key_alloc)(struct ieee80211com *,
const struct ieee80211_key *,
ieee80211_keyix *, ieee80211_keyix *);
int (*cs_key_delete)(struct ieee80211com *,
const struct ieee80211_key *);
int (*cs_key_set)(struct ieee80211com *,
const struct ieee80211_key *,
void (*cs_key_update_begin)(struct ieee80211com *);
void (*cs_key_update_end)(struct ieee80211com *);
};
/*
* Key update synchronization methods.
*/
#define KEY_UPDATE_BEGIN(ic) \
#define KEY_UPDATE_END(ic) \
#define KEY_UNDEFINED(k) \
((k).wk_cipher == &ieee80211_cipher_none)
#define DEV_KEY_DELETE(ic, k) \
#define DEV_KEY_SET(ic, k, m) \
#define CIPHER_DETACH(k) \
#define CIPHER_ATTACH(k) \
1)
1)
const struct ieee80211_cipher *);
const struct ieee80211_cipher *);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_NET80211_CRYPTO_H */