1 /* $OpenBSD: ieee80211_crypto.h,v 1.6 2007/08/01 15:40:40 damien Exp $ */ 2 /* $NetBSD: ieee80211_crypto.h,v 1.2 2003/09/14 01:14:55 dyoung Exp $ */ 3 4 /*- 5 * Copyright (c) 2001 Atsushi Onoe 6 * Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 * $FreeBSD: src/sys/net80211/ieee80211_crypto.h,v 1.2 2003/06/27 05:13:52 sam Exp $ 32 */ 33 #ifndef _NET80211_IEEE80211_CRYPTO_H_ 34 #define _NET80211_IEEE80211_CRYPTO_H_ 35 36 /* 37 * 802.11 protocol crypto-related definitions. 38 */ 39 40 /* 41 * 802.11i ciphers. 42 */ 43 enum ieee80211_cipher { 44 IEEE80211_CIPHER_NONE = 0x00000000, 45 IEEE80211_CIPHER_USEGROUP = 0x00000001, 46 IEEE80211_CIPHER_WEP40 = 0x00000002, 47 IEEE80211_CIPHER_TKIP = 0x00000004, 48 IEEE80211_CIPHER_CCMP = 0x00000008, 49 IEEE80211_CIPHER_WEP104 = 0x00000010 50 }; 51 52 /* 53 * 802.11i Authentication and Key Management. 54 */ 55 enum ieee80211_akm { 56 IEEE80211_AKM_NONE = 0x00000000, 57 IEEE80211_AKM_IEEE8021X = 0x00000001, 58 IEEE80211_AKM_PSK = 0x00000002 59 }; 60 61 #define IEEE80211_KEYBUF_SIZE 16 62 63 struct ieee80211_key { 64 u_int8_t k_id; /* identifier (0-3) */ 65 enum ieee80211_cipher k_cipher; 66 u_int k_flags; 67 #define IEEE80211_KEY_GROUP 0x00000001 /* group key */ 68 #define IEEE80211_KEY_TX 0x00000002 /* Tx+Rx */ 69 70 u_int64_t k_rsc; 71 u_int64_t k_tsc; 72 int k_len; 73 u_int8_t k_key[IEEE80211_KEYBUF_SIZE]; 74 }; 75 76 /* forward references */ 77 struct ieee80211com; 78 struct ieee80211_node; 79 80 extern void ieee80211_crypto_attach(struct ifnet *); 81 extern void ieee80211_crypto_detach(struct ifnet *); 82 extern struct mbuf *ieee80211_encrypt(struct ieee80211com *, struct mbuf *, 83 struct ieee80211_node *); 84 extern struct mbuf *ieee80211_decrypt(struct ieee80211com *, struct mbuf *, 85 struct ieee80211_node *); 86 extern struct mbuf *ieee80211_wep_crypt(struct ifnet *, struct mbuf *, int); 87 extern void ieee80211_derive_ptk(const u_int8_t *, size_t, const u_int8_t *, 88 const u_int8_t *, const u_int8_t *, const u_int8_t *, u_int8_t *, 89 size_t); 90 extern int ieee80211_cipher_keylen(enum ieee80211_cipher); 91 92 #endif /* _NET80211_IEEE80211_CRYPTO_H_ */