Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 134262
b: refs/heads/master
c: 018697d
h: refs/heads/master
v: v3
  • Loading branch information
Dan Williams authored and John W. Linville committed Jan 29, 2009
1 parent 89a809c commit 2f8bfe6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 99590ffefc803caaf6ba923da092cde739269c06
refs/heads/master: 018697d178717d63f668b9e5f3b473f4e37f6304
82 changes: 41 additions & 41 deletions trunk/drivers/net/wireless/airo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,29 @@ static void emmh32_update(emmh32_context *context, u8 *pOctets, int len);
static void emmh32_final(emmh32_context *context, u8 digest[4]);
static int flashpchar(struct airo_info *ai,int byte,int dwelltime);

static void age_mic_context(miccntx *cur, miccntx *old, u8 *key, int key_len,
struct crypto_cipher *tfm)
{
/* If the current MIC context is valid and its key is the same as
* the MIC register, there's nothing to do.
*/
if (cur->valid && (memcmp(cur->key, key, key_len) == 0))
return;

/* Age current mic Context */
memcpy(old, cur, sizeof(*cur));

/* Initialize new context */
memcpy(cur->key, key, key_len);
cur->window = 33; /* Window always points to the middle */
cur->rx = 0; /* Rx Sequence numbers */
cur->tx = 0; /* Tx sequence numbers */
cur->valid = 1; /* Key is now valid */

/* Give key to mic seed */
emmh32_setseed(&cur->seed, key, key_len, tfm);
}

/* micinit - Initialize mic seed */

static void micinit(struct airo_info *ai)
Expand All @@ -1312,49 +1335,26 @@ static void micinit(struct airo_info *ai)
PC4500_readrid(ai, RID_MIC, &mic_rid, sizeof(mic_rid), 0);
up(&ai->sem);

ai->micstats.enabled = (mic_rid.state & 0x00FF) ? 1 : 0;

if (ai->micstats.enabled) {
/* Key must be valid and different */
if (mic_rid.multicastValid && (!ai->mod[0].mCtx.valid ||
(memcmp (ai->mod[0].mCtx.key, mic_rid.multicast,
sizeof(ai->mod[0].mCtx.key)) != 0))) {
/* Age current mic Context */
memcpy(&ai->mod[1].mCtx,&ai->mod[0].mCtx,sizeof(miccntx));
/* Initialize new context */
memcpy(&ai->mod[0].mCtx.key,mic_rid.multicast,sizeof(mic_rid.multicast));
ai->mod[0].mCtx.window = 33; //Window always points to the middle
ai->mod[0].mCtx.rx = 0; //Rx Sequence numbers
ai->mod[0].mCtx.tx = 0; //Tx sequence numbers
ai->mod[0].mCtx.valid = 1; //Key is now valid

/* Give key to mic seed */
emmh32_setseed(&ai->mod[0].mCtx.seed,mic_rid.multicast,sizeof(mic_rid.multicast), ai->tfm);
}

/* Key must be valid and different */
if (mic_rid.unicastValid && (!ai->mod[0].uCtx.valid ||
(memcmp(ai->mod[0].uCtx.key, mic_rid.unicast,
sizeof(ai->mod[0].uCtx.key)) != 0))) {
/* Age current mic Context */
memcpy(&ai->mod[1].uCtx,&ai->mod[0].uCtx,sizeof(miccntx));
/* Initialize new context */
memcpy(&ai->mod[0].uCtx.key,mic_rid.unicast,sizeof(mic_rid.unicast));

ai->mod[0].uCtx.window = 33; //Window always points to the middle
ai->mod[0].uCtx.rx = 0; //Rx Sequence numbers
ai->mod[0].uCtx.tx = 0; //Tx sequence numbers
ai->mod[0].uCtx.valid = 1; //Key is now valid

//Give key to mic seed
emmh32_setseed(&ai->mod[0].uCtx.seed, mic_rid.unicast, sizeof(mic_rid.unicast), ai->tfm);
}
} else {
/* So next time we have a valid key and mic is enabled, we will update
* the sequence number if the key is the same as before.
*/
ai->micstats.enabled = (le16_to_cpu(mic_rid.state) & 0x00FF) ? 1 : 0;
if (!ai->micstats.enabled) {
/* So next time we have a valid key and mic is enabled, we will
* update the sequence number if the key is the same as before.
*/
ai->mod[0].uCtx.valid = 0;
ai->mod[0].mCtx.valid = 0;
return;
}

if (mic_rid.multicastValid) {
age_mic_context(&ai->mod[0].mCtx, &ai->mod[1].mCtx,
mic_rid.multicast, sizeof(mic_rid.multicast),
ai->tfm);
}

if (mic_rid.unicastValid) {
age_mic_context(&ai->mod[0].uCtx, &ai->mod[1].uCtx,
mic_rid.unicast, sizeof(mic_rid.unicast),
ai->tfm);
}
}

Expand Down

0 comments on commit 2f8bfe6

Please sign in to comment.