Greg Kroah-Hartman | ecdfa44 | 2009-08-04 15:57:55 -0700 | [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 |
| 6 | * <jkmaline@cc.hut.fi> |
| 7 | * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi> |
| 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 | /* |
Larry Finger | 94a7994 | 2011-08-23 19:00:42 -0500 | [diff] [blame] | 21 | * This file defines the interface to the rtllib crypto module. |
Greg Kroah-Hartman | ecdfa44 | 2009-08-04 15:57:55 -0700 | [diff] [blame] | 22 | */ |
Larry Finger | 94a7994 | 2011-08-23 19:00:42 -0500 | [diff] [blame] | 23 | #ifndef RTLLIB_CRYPT_H |
| 24 | #define RTLLIB_CRYPT_H |
Greg Kroah-Hartman | ecdfa44 | 2009-08-04 15:57:55 -0700 | [diff] [blame] | 25 | |
| 26 | #include <linux/skbuff.h> |
| 27 | |
Larry Finger | 94a7994 | 2011-08-23 19:00:42 -0500 | [diff] [blame] | 28 | struct rtllib_crypto_ops { |
Greg Kroah-Hartman | ecdfa44 | 2009-08-04 15:57:55 -0700 | [diff] [blame] | 29 | const char *name; |
| 30 | |
| 31 | /* init new crypto context (e.g., allocate private data space, |
| 32 | * select IV, etc.); returns NULL on failure or pointer to allocated |
| 33 | * private data on success */ |
| 34 | void * (*init)(int keyidx); |
| 35 | |
| 36 | /* deinitialize crypto context and free allocated private data */ |
| 37 | void (*deinit)(void *priv); |
| 38 | |
| 39 | /* encrypt/decrypt return < 0 on error or >= 0 on success. The return |
| 40 | * value from decrypt_mpdu is passed as the keyidx value for |
| 41 | * decrypt_msdu. skb must have enough head and tail room for the |
| 42 | * encryption; if not, error will be returned; these functions are |
| 43 | * called for all MPDUs (i.e., fragments). |
| 44 | */ |
| 45 | int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv); |
| 46 | int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv); |
| 47 | |
| 48 | /* These functions are called for full MSDUs, i.e. full frames. |
| 49 | * These can be NULL if full MSDU operations are not needed. */ |
| 50 | int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv); |
| 51 | int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len, |
Larry Finger | 94a7994 | 2011-08-23 19:00:42 -0500 | [diff] [blame] | 52 | void *priv, struct rtllib_device* ieee); |
Greg Kroah-Hartman | ecdfa44 | 2009-08-04 15:57:55 -0700 | [diff] [blame] | 53 | |
| 54 | int (*set_key)(void *key, int len, u8 *seq, void *priv); |
| 55 | int (*get_key)(void *key, int len, u8 *seq, void *priv); |
| 56 | |
| 57 | /* procfs handler for printing out key information and possible |
| 58 | * statistics */ |
| 59 | char * (*print_stats)(char *p, void *priv); |
| 60 | |
| 61 | /* maximum number of bytes added by encryption; encrypt buf is |
| 62 | * allocated with extra_prefix_len bytes, copy of in_buf, and |
| 63 | * extra_postfix_len; encrypt need not use all this space, but |
Larry Finger | a44325f | 2011-08-25 11:48:23 -0500 | [diff] [blame] | 64 | * the result must start at the beginning of the struct buffer and |
| 65 | * correct length must be returned */ |
Greg Kroah-Hartman | ecdfa44 | 2009-08-04 15:57:55 -0700 | [diff] [blame] | 66 | int extra_prefix_len, extra_postfix_len; |
| 67 | |
| 68 | struct module *owner; |
| 69 | }; |
| 70 | |
Larry Finger | 94a7994 | 2011-08-23 19:00:42 -0500 | [diff] [blame] | 71 | struct rtllib_crypt_data { |
Greg Kroah-Hartman | ecdfa44 | 2009-08-04 15:57:55 -0700 | [diff] [blame] | 72 | struct list_head list; /* delayed deletion list */ |
Larry Finger | 94a7994 | 2011-08-23 19:00:42 -0500 | [diff] [blame] | 73 | struct rtllib_crypto_ops *ops; |
Greg Kroah-Hartman | ecdfa44 | 2009-08-04 15:57:55 -0700 | [diff] [blame] | 74 | void *priv; |
| 75 | atomic_t refcnt; |
| 76 | }; |
| 77 | |
Larry Finger | 94a7994 | 2011-08-23 19:00:42 -0500 | [diff] [blame] | 78 | int rtllib_register_crypto_ops(struct rtllib_crypto_ops *ops); |
| 79 | int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops); |
Larry Finger | a44325f | 2011-08-25 11:48:23 -0500 | [diff] [blame] | 80 | struct rtllib_crypto_ops *rtllib_get_crypto_ops(const char *name); |
Larry Finger | 94a7994 | 2011-08-23 19:00:42 -0500 | [diff] [blame] | 81 | void rtllib_crypt_deinit_entries(struct rtllib_device *, int); |
| 82 | void rtllib_crypt_deinit_handler(unsigned long); |
| 83 | void rtllib_crypt_delayed_deinit(struct rtllib_device *ieee, |
Larry Finger | a44325f | 2011-08-25 11:48:23 -0500 | [diff] [blame] | 84 | struct rtllib_crypt_data **crypt); |
Greg Kroah-Hartman | ecdfa44 | 2009-08-04 15:57:55 -0700 | [diff] [blame] | 85 | #endif |