Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32c44cb5 authored by Sean MacLennan's avatar Sean MacLennan Committed by Greg Kroah-Hartman
Browse files

staging/rtl8192e: Convert to lib80211_crypt_data and lib80211_crypt_ops



Convert rtllib_crypt_data to lib80211_crypt_data and
rtllib_crypt_ops to lib80211_crypt_ops.

This is almost a 1:1 replacement, only extra_prefix_len and
extra_postfix_len changed.

Signed-off-by: default avatarSean MacLennan <seanm@seanm.ca>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 184f1938
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@

struct rtllib_crypto_alg {
	struct list_head list;
	struct rtllib_crypto_ops *ops;
	struct lib80211_crypto_ops *ops;
};


@@ -36,11 +36,11 @@ void rtllib_crypt_deinit_entries(struct rtllib_device *ieee,
					   int force)
{
	struct list_head *ptr, *n;
	struct rtllib_crypt_data *entry;
	struct lib80211_crypt_data *entry;

	for (ptr = ieee->crypt_deinit_list.next, n = ptr->next;
	     ptr != &ieee->crypt_deinit_list; ptr = n, n = ptr->next) {
		entry = list_entry(ptr, struct rtllib_crypt_data, list);
		entry = list_entry(ptr, struct lib80211_crypt_data, list);

		if (atomic_read(&entry->refcnt) != 0 && !force)
			continue;
@@ -73,9 +73,9 @@ void rtllib_crypt_deinit_handler(unsigned long data)
EXPORT_SYMBOL(rtllib_crypt_deinit_handler);

void rtllib_crypt_delayed_deinit(struct rtllib_device *ieee,
				    struct rtllib_crypt_data **crypt)
				    struct lib80211_crypt_data **crypt)
{
	struct rtllib_crypt_data *tmp;
	struct lib80211_crypt_data *tmp;
	unsigned long flags;

	if (*crypt == NULL)
@@ -98,7 +98,7 @@ void rtllib_crypt_delayed_deinit(struct rtllib_device *ieee,
}
EXPORT_SYMBOL(rtllib_crypt_delayed_deinit);

int rtllib_register_crypto_ops(struct rtllib_crypto_ops *ops)
int rtllib_register_crypto_ops(struct lib80211_crypto_ops *ops)
{
	unsigned long flags;
	struct rtllib_crypto_alg *alg;
@@ -123,7 +123,7 @@ int rtllib_register_crypto_ops(struct rtllib_crypto_ops *ops)
}
EXPORT_SYMBOL(rtllib_register_crypto_ops);

int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops)
int rtllib_unregister_crypto_ops(struct lib80211_crypto_ops *ops)
{
	unsigned long flags;
	struct list_head *ptr;
@@ -155,7 +155,7 @@ int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops)
EXPORT_SYMBOL(rtllib_unregister_crypto_ops);


struct rtllib_crypto_ops *rtllib_get_crypto_ops(const char *name)
struct lib80211_crypto_ops *rtllib_get_crypto_ops(const char *name)
{
	unsigned long flags;
	struct list_head *ptr;
@@ -186,7 +186,7 @@ EXPORT_SYMBOL(rtllib_get_crypto_ops);
static void * rtllib_crypt_null_init(int keyidx) { return (void *) 1; }
static void rtllib_crypt_null_deinit(void *priv) {}

static struct rtllib_crypto_ops rtllib_crypt_null = {
static struct lib80211_crypto_ops rtllib_crypt_null = {
	.name			= "NULL",
	.init			= rtllib_crypt_null_init,
	.deinit			= rtllib_crypt_null_deinit,
@@ -196,8 +196,10 @@ static struct rtllib_crypto_ops rtllib_crypt_null = {
	.decrypt_msdu		= NULL,
	.set_key		= NULL,
	.get_key		= NULL,
	.extra_prefix_len	= 0,
	.extra_postfix_len	= 0,
	.extra_mpdu_prefix_len	= 0,
	.extra_mpdu_postfix_len	= 0,
	.extra_msdu_prefix_len	= 0,
	.extra_msdu_postfix_len	= 0,
	.owner			= THIS_MODULE,
};

+4 −54
Original line number Diff line number Diff line
@@ -25,61 +25,11 @@

#include <linux/skbuff.h>

struct rtllib_crypto_ops {
	const char *name;

	/* init new crypto context (e.g., allocate private data space,
	 * select IV, etc.); returns NULL on failure or pointer to allocated
	 * private data on success */
	void * (*init)(int keyidx);

	/* deinitialize crypto context and free allocated private data */
	void (*deinit)(void *priv);

	/* encrypt/decrypt return < 0 on error or >= 0 on success. The return
	 * value from decrypt_mpdu is passed as the keyidx value for
	 * decrypt_msdu. skb must have enough head and tail room for the
	 * encryption; if not, error will be returned; these functions are
	 * called for all MPDUs (i.e., fragments).
	 */
	int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
	int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);

	/* These functions are called for full MSDUs, i.e. full frames.
	 * These can be NULL if full MSDU operations are not needed. */
	int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv);
	int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len,
			    void *priv, struct rtllib_device* ieee);

	int (*set_key)(void *key, int len, u8 *seq, void *priv);
	int (*get_key)(void *key, int len, u8 *seq, void *priv);

	/* procfs handler for printing out key information and possible
	 * statistics */
	char * (*print_stats)(char *p, void *priv);

	/* maximum number of bytes added by encryption; encrypt buf is
	 * allocated with extra_prefix_len bytes, copy of in_buf, and
	 * extra_postfix_len; encrypt need not use all this space, but
	 * the result must start at the beginning of the struct buffer and
	 * correct length must be returned */
	int extra_prefix_len, extra_postfix_len;

	struct module *owner;
};

struct rtllib_crypt_data {
	struct list_head list; /* delayed deletion list */
	struct rtllib_crypto_ops *ops;
	void *priv;
	atomic_t refcnt;
};

int rtllib_register_crypto_ops(struct rtllib_crypto_ops *ops);
int rtllib_unregister_crypto_ops(struct rtllib_crypto_ops *ops);
struct rtllib_crypto_ops *rtllib_get_crypto_ops(const char *name);
int rtllib_register_crypto_ops(struct lib80211_crypto_ops *ops);
int rtllib_unregister_crypto_ops(struct lib80211_crypto_ops *ops);
struct lib80211_crypto_ops *rtllib_get_crypto_ops(const char *name);
void rtllib_crypt_deinit_entries(struct rtllib_device *, int);
void rtllib_crypt_deinit_handler(unsigned long);
void rtllib_crypt_delayed_deinit(struct rtllib_device *ieee,
				 struct rtllib_crypt_data **crypt);
				 struct lib80211_crypt_data **crypt);
#endif
+3 −3
Original line number Diff line number Diff line
@@ -427,7 +427,7 @@ static char *rtllib_ccmp_print_stats(char *p, void *priv)
	return p;
}

static struct rtllib_crypto_ops rtllib_crypt_ccmp = {
static struct lib80211_crypto_ops rtllib_crypt_ccmp = {
	.name			= "CCMP",
	.init			= rtllib_ccmp_init,
	.deinit			= rtllib_ccmp_deinit,
@@ -438,8 +438,8 @@ static struct rtllib_crypto_ops rtllib_crypt_ccmp = {
	.set_key		= rtllib_ccmp_set_key,
	.get_key		= rtllib_ccmp_get_key,
	.print_stats		= rtllib_ccmp_print_stats,
	.extra_prefix_len	= CCMP_HDR_LEN,
	.extra_postfix_len	= CCMP_MIC_LEN,
	.extra_mpdu_prefix_len = CCMP_HDR_LEN,
	.extra_mpdu_postfix_len = CCMP_MIC_LEN,
	.owner			= THIS_MODULE,
};

+8 −11
Original line number Diff line number Diff line
@@ -596,8 +596,7 @@ static void rtllib_michael_mic_failure(struct net_device *dev,
}

static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx,
				     int hdr_len, void *priv,
				     struct rtllib_device *ieee)
				     int hdr_len, void *priv)
{
	struct rtllib_tkip_data *tkey = priv;
	u8 mic[8];
@@ -616,23 +615,20 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx,
			skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
		return -1;

	if ((memcmp(mic, skb->data + skb->len - 8, 8) != 0) ||
	   (ieee->force_mic_error)) {
	if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
		struct rtllib_hdr_4addr *hdr;
		hdr = (struct rtllib_hdr_4addr *) skb->data;
		printk(KERN_DEBUG "%s: Michael MIC verification failed for "
		       "MSDU from %pM keyidx=%d\n",
		       skb->dev ? skb->dev->name : "N/A", hdr->addr2,
		       keyidx);
		printk(KERN_DEBUG "%d, force_mic_error = %d\n",
		       (memcmp(mic, skb->data + skb->len - 8, 8) != 0),\
			ieee->force_mic_error);
		printk(KERN_DEBUG "%d\n",
		       memcmp(mic, skb->data + skb->len - 8, 8) != 0);
		if (skb->dev) {
			printk(KERN_INFO "skb->dev != NULL\n");
			rtllib_michael_mic_failure(skb->dev, hdr, keyidx);
		}
		tkey->dot11RSNAStatsTKIPLocalMICFailures++;
		ieee->force_mic_error = false;
		return -1;
	}

@@ -738,7 +734,7 @@ static char *rtllib_tkip_print_stats(char *p, void *priv)
	return p;
}

static struct rtllib_crypto_ops rtllib_crypt_tkip = {
static struct lib80211_crypto_ops rtllib_crypt_tkip = {
	.name			= "TKIP",
	.init			= rtllib_tkip_init,
	.deinit			= rtllib_tkip_deinit,
@@ -749,8 +745,9 @@ static struct rtllib_crypto_ops rtllib_crypt_tkip = {
	.set_key		= rtllib_tkip_set_key,
	.get_key		= rtllib_tkip_get_key,
	.print_stats		= rtllib_tkip_print_stats,
	.extra_prefix_len	= 4 + 4, /* IV + ExtIV */
	.extra_postfix_len	= 8 + 4, /* MIC + ICV */
	.extra_mpdu_prefix_len = 4 + 4,	/* IV + ExtIV */
	.extra_mpdu_postfix_len = 4,	/* ICV */
	.extra_msdu_postfix_len = 8,	/* MIC */
	.owner			= THIS_MODULE,
};

+3 −3
Original line number Diff line number Diff line
@@ -255,7 +255,7 @@ static char *prism2_wep_print_stats(char *p, void *priv)
	return p;
}

static struct rtllib_crypto_ops rtllib_crypt_wep = {
static struct lib80211_crypto_ops rtllib_crypt_wep = {
	.name			= "WEP",
	.init			= prism2_wep_init,
	.deinit			= prism2_wep_deinit,
@@ -266,8 +266,8 @@ static struct rtllib_crypto_ops rtllib_crypt_wep = {
	.set_key		= prism2_wep_set_key,
	.get_key		= prism2_wep_get_key,
	.print_stats		= prism2_wep_print_stats,
	.extra_prefix_len	= 4, /* IV */
	.extra_postfix_len	= 4, /* ICV */
	.extra_mpdu_prefix_len  = 4,	/* IV */
	.extra_mpdu_postfix_len = 4,	/* ICV */
	.owner			= THIS_MODULE,
};

Loading