-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 134447 b: refs/heads/master c: 4adb474 h: refs/heads/master i: 134445: 27f3a9b 134443: 9f3b5ec 134439: f10305f 134431: 0dea42c v: v3
- Loading branch information
David Kilroy
authored and
John W. Linville
committed
Feb 13, 2009
1 parent
14e94b4
commit 70dc241
Showing
5 changed files
with
106 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: fb791b1cfb74937332a22d6bf06eed7866fbcc3c | ||
refs/heads/master: 4adb474b6b7e26e1318acab5e98864aa78f9b233 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* Orinoco MIC helpers | ||
* | ||
* See copyright notice in main.c | ||
*/ | ||
#include <linux/kernel.h> | ||
#include <linux/string.h> | ||
#include <linux/if_ether.h> | ||
#include <linux/scatterlist.h> | ||
#include <linux/crypto.h> | ||
|
||
#include "orinoco.h" | ||
#include "mic.h" | ||
|
||
/********************************************************************/ | ||
/* Michael MIC crypto setup */ | ||
/********************************************************************/ | ||
int orinoco_mic_init(struct orinoco_private *priv) | ||
{ | ||
priv->tx_tfm_mic = crypto_alloc_hash("michael_mic", 0, 0); | ||
if (IS_ERR(priv->tx_tfm_mic)) { | ||
printk(KERN_DEBUG "orinoco_mic_init: could not allocate " | ||
"crypto API michael_mic\n"); | ||
priv->tx_tfm_mic = NULL; | ||
return -ENOMEM; | ||
} | ||
|
||
priv->rx_tfm_mic = crypto_alloc_hash("michael_mic", 0, 0); | ||
if (IS_ERR(priv->rx_tfm_mic)) { | ||
printk(KERN_DEBUG "orinoco_mic_init: could not allocate " | ||
"crypto API michael_mic\n"); | ||
priv->rx_tfm_mic = NULL; | ||
return -ENOMEM; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
void orinoco_mic_free(struct orinoco_private *priv) | ||
{ | ||
if (priv->tx_tfm_mic) | ||
crypto_free_hash(priv->tx_tfm_mic); | ||
if (priv->rx_tfm_mic) | ||
crypto_free_hash(priv->rx_tfm_mic); | ||
} | ||
|
||
int orinoco_mic(struct crypto_hash *tfm_michael, u8 *key, | ||
u8 *da, u8 *sa, u8 priority, | ||
u8 *data, size_t data_len, u8 *mic) | ||
{ | ||
struct hash_desc desc; | ||
struct scatterlist sg[2]; | ||
u8 hdr[ETH_HLEN + 2]; /* size of header + padding */ | ||
|
||
if (tfm_michael == NULL) { | ||
printk(KERN_WARNING "orinoco_mic: tfm_michael == NULL\n"); | ||
return -1; | ||
} | ||
|
||
/* Copy header into buffer. We need the padding on the end zeroed */ | ||
memcpy(&hdr[0], da, ETH_ALEN); | ||
memcpy(&hdr[ETH_ALEN], sa, ETH_ALEN); | ||
hdr[ETH_ALEN*2] = priority; | ||
hdr[ETH_ALEN*2+1] = 0; | ||
hdr[ETH_ALEN*2+2] = 0; | ||
hdr[ETH_ALEN*2+3] = 0; | ||
|
||
/* Use scatter gather to MIC header and data in one go */ | ||
sg_init_table(sg, 2); | ||
sg_set_buf(&sg[0], hdr, sizeof(hdr)); | ||
sg_set_buf(&sg[1], data, data_len); | ||
|
||
if (crypto_hash_setkey(tfm_michael, key, MIC_KEYLEN)) | ||
return -1; | ||
|
||
desc.tfm = tfm_michael; | ||
desc.flags = 0; | ||
return crypto_hash_digest(&desc, sg, data_len + sizeof(hdr), | ||
mic); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* Orinoco MIC helpers | ||
* | ||
* See copyright notice in main.c | ||
*/ | ||
#ifndef _ORINOCO_MIC_H_ | ||
#define _ORINOCO_MIC_H_ | ||
|
||
#include <linux/types.h> | ||
|
||
#define MICHAEL_MIC_LEN 8 | ||
|
||
/* Forward declarations */ | ||
struct orinoco_private; | ||
struct crypto_hash; | ||
|
||
int orinoco_mic_init(struct orinoco_private *priv); | ||
void orinoco_mic_free(struct orinoco_private *priv); | ||
int orinoco_mic(struct crypto_hash *tfm_michael, u8 *key, | ||
u8 *da, u8 *sa, u8 priority, | ||
u8 *data, size_t data_len, u8 *mic); | ||
|
||
#endif /* ORINOCO_MIC_H */ |