1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Original code based on Host AP (software wireless LAN access point) driver 4 * for Intersil Prism2/2.5/3. 5 * 6 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen 7 * <jkmaline@cc.hut.fi> 8 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi> 9 * 10 * Adaption to a generic IEEE 802.11 stack by James Ketrenos 11 * <jketreno@linux.intel.com> 12 * 13 * Copyright (c) 2004, Intel Corporation 14 */ 15 16 /* 17 * This file defines the interface to the ieee80211 crypto module. 18 */ 19 #ifndef IEEE80211_CRYPT_H 20 #define IEEE80211_CRYPT_H 21 22 #include <linux/skbuff.h> 23 24 struct ieee80211_crypto_ops { 25 const char *name; 26 27 /* init new crypto context (e.g., allocate private data space, 28 * select IV, etc.); returns NULL on failure or pointer to allocated 29 * private data on success 30 */ 31 void * (*init)(int keyidx); 32 33 /* deinitialize crypto context and free allocated private data */ 34 void (*deinit)(void *priv); 35 36 /* encrypt/decrypt return < 0 on error or >= 0 on success. The return 37 * value from decrypt_mpdu is passed as the keyidx value for 38 * decrypt_msdu. skb must have enough head and tail room for the 39 * encryption; if not, error will be returned; these functions are 40 * called for all MPDUs (i.e., fragments). 41 */ 42 int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv); 43 int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv); 44 45 /* These functions are called for full MSDUs, i.e. full frames. 46 * These can be NULL if full MSDU operations are not needed. 47 */ 48 int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv); 49 int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len, 50 void *priv); 51 52 int (*set_key)(void *key, int len, u8 *seq, void *priv); 53 int (*get_key)(void *key, int len, u8 *seq, void *priv); 54 55 /* procfs handler for printing out key information and possible 56 * statistics 57 */ 58 char * (*print_stats)(char *p, void *priv); 59 60 /* maximum number of bytes added by encryption; encrypt buf is 61 * allocated with extra_prefix_len bytes, copy of in_buf, and 62 * extra_postfix_len; encrypt need not use all this space, but 63 * the result must start at the beginning of the buffer and correct 64 * length must be returned 65 */ 66 int extra_prefix_len, extra_postfix_len; 67 68 struct module *owner; 69 }; 70 71 struct ieee80211_crypt_data { 72 struct list_head list; /* delayed deletion list */ 73 struct ieee80211_crypto_ops *ops; 74 void *priv; 75 atomic_t refcnt; 76 }; 77 78 int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); 79 int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); 80 struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name); 81 void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee, int force); 82 void ieee80211_crypt_deinit_handler(struct timer_list *t); 83 void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, 84 struct ieee80211_crypt_data **crypt); 85 86 #endif