Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Original code based on Host AP (software wireless LAN access point) driver |
| 3 | * for Intersil Prism2/2.5/3. |
| 4 | * |
| 5 | * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen |
Jouni Malinen | 85d32e7 | 2007-03-24 17:15:30 -0700 | [diff] [blame] | 6 | * <j@w1.fi> |
| 7 | * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi> |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 8 | * |
| 9 | * Adaption to a generic IEEE 802.11 stack by James Ketrenos |
| 10 | * <jketreno@linux.intel.com> |
| 11 | * |
| 12 | * Copyright (c) 2004, Intel Corporation |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License version 2 as |
| 16 | * published by the Free Software Foundation. See README and COPYING for |
| 17 | * more details. |
| 18 | */ |
| 19 | |
| 20 | /* |
| 21 | * This file defines the interface to the ieee80211 crypto module. |
| 22 | */ |
| 23 | #ifndef IEEE80211_CRYPT_H |
| 24 | #define IEEE80211_CRYPT_H |
| 25 | |
Arnaldo Carvalho de Melo | 14c8502 | 2005-12-27 02:43:12 -0200 | [diff] [blame] | 26 | #include <linux/types.h> |
| 27 | #include <linux/list.h> |
Adrian Bunk | 5fad5a2 | 2006-01-14 03:09:34 +0100 | [diff] [blame] | 28 | #include <net/ieee80211.h> |
Arnaldo Carvalho de Melo | 14c8502 | 2005-12-27 02:43:12 -0200 | [diff] [blame] | 29 | #include <asm/atomic.h> |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 30 | |
James Ketrenos | 6eb6edf | 2005-09-22 10:34:15 +0000 | [diff] [blame] | 31 | enum { |
James Ketrenos | ff0037b | 2005-10-03 10:23:42 -0500 | [diff] [blame] | 32 | IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0), |
James Ketrenos | 6eb6edf | 2005-09-22 10:34:15 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
Arnaldo Carvalho de Melo | 14c8502 | 2005-12-27 02:43:12 -0200 | [diff] [blame] | 35 | struct sk_buff; |
| 36 | struct module; |
| 37 | |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 38 | struct ieee80211_crypto_ops { |
| 39 | const char *name; |
Christoph Hellwig | e330562 | 2005-11-09 01:01:04 -0500 | [diff] [blame] | 40 | struct list_head list; |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 41 | |
| 42 | /* init new crypto context (e.g., allocate private data space, |
| 43 | * select IV, etc.); returns NULL on failure or pointer to allocated |
| 44 | * private data on success */ |
James Ketrenos | 6eb6edf | 2005-09-22 10:34:15 +0000 | [diff] [blame] | 45 | void *(*init) (int keyidx); |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 46 | |
| 47 | /* deinitialize crypto context and free allocated private data */ |
James Ketrenos | 74079fd | 2005-09-13 17:35:21 -0500 | [diff] [blame] | 48 | void (*deinit) (void *priv); |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 49 | |
Zhu Yi | 9184d93 | 2006-01-19 16:22:32 +0800 | [diff] [blame] | 50 | int (*build_iv) (struct sk_buff * skb, int hdr_len, |
| 51 | u8 *key, int keylen, void *priv); |
James Ketrenos | 31b59ea | 2005-09-21 11:58:49 -0500 | [diff] [blame] | 52 | |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 53 | /* encrypt/decrypt return < 0 on error or >= 0 on success. The return |
| 54 | * value from decrypt_mpdu is passed as the keyidx value for |
| 55 | * decrypt_msdu. skb must have enough head and tail room for the |
| 56 | * encryption; if not, error will be returned; these functions are |
| 57 | * called for all MPDUs (i.e., fragments). |
| 58 | */ |
James Ketrenos | 74079fd | 2005-09-13 17:35:21 -0500 | [diff] [blame] | 59 | int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv); |
| 60 | int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv); |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 61 | |
| 62 | /* These functions are called for full MSDUs, i.e. full frames. |
| 63 | * These can be NULL if full MSDU operations are not needed. */ |
James Ketrenos | 74079fd | 2005-09-13 17:35:21 -0500 | [diff] [blame] | 64 | int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv); |
| 65 | int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len, |
| 66 | void *priv); |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 67 | |
James Ketrenos | 74079fd | 2005-09-13 17:35:21 -0500 | [diff] [blame] | 68 | int (*set_key) (void *key, int len, u8 * seq, void *priv); |
| 69 | int (*get_key) (void *key, int len, u8 * seq, void *priv); |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 70 | |
| 71 | /* procfs handler for printing out key information and possible |
| 72 | * statistics */ |
James Ketrenos | 74079fd | 2005-09-13 17:35:21 -0500 | [diff] [blame] | 73 | char *(*print_stats) (char *p, void *priv); |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 74 | |
James Ketrenos | 6eb6edf | 2005-09-22 10:34:15 +0000 | [diff] [blame] | 75 | /* Crypto specific flag get/set for configuration settings */ |
James Ketrenos | ff0037b | 2005-10-03 10:23:42 -0500 | [diff] [blame] | 76 | unsigned long (*get_flags) (void *priv); |
| 77 | unsigned long (*set_flags) (unsigned long flags, void *priv); |
James Ketrenos | 6eb6edf | 2005-09-22 10:34:15 +0000 | [diff] [blame] | 78 | |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 79 | /* maximum number of bytes added by encryption; encrypt buf is |
| 80 | * allocated with extra_prefix_len bytes, copy of in_buf, and |
| 81 | * extra_postfix_len; encrypt need not use all this space, but |
| 82 | * the result must start at the beginning of the buffer and correct |
| 83 | * length must be returned */ |
James Ketrenos | 1264fc0 | 2005-09-21 11:54:53 -0500 | [diff] [blame] | 84 | int extra_mpdu_prefix_len, extra_mpdu_postfix_len; |
| 85 | int extra_msdu_prefix_len, extra_msdu_postfix_len; |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 86 | |
| 87 | struct module *owner; |
| 88 | }; |
| 89 | |
| 90 | struct ieee80211_crypt_data { |
James Ketrenos | 74079fd | 2005-09-13 17:35:21 -0500 | [diff] [blame] | 91 | struct list_head list; /* delayed deletion list */ |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 92 | struct ieee80211_crypto_ops *ops; |
| 93 | void *priv; |
| 94 | atomic_t refcnt; |
| 95 | }; |
| 96 | |
Arnaldo Carvalho de Melo | 14c8502 | 2005-12-27 02:43:12 -0200 | [diff] [blame] | 97 | struct ieee80211_device; |
| 98 | |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 99 | int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); |
| 100 | int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); |
James Ketrenos | 74079fd | 2005-09-13 17:35:21 -0500 | [diff] [blame] | 101 | struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name); |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 102 | void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); |
| 103 | void ieee80211_crypt_deinit_handler(unsigned long); |
| 104 | void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, |
| 105 | struct ieee80211_crypt_data **crypt); |
James Ketrenos | 0ad0c3c | 2005-09-21 11:54:15 -0500 | [diff] [blame] | 106 | void ieee80211_crypt_quiescing(struct ieee80211_device *ieee); |
Jeff Garzik | b453872 | 2005-05-12 22:48:20 -0400 | [diff] [blame] | 107 | |
| 108 | #endif |