diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2006-08-22 06:36:13 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2006-09-20 21:46:15 -0400 |
commit | f12cc2090d721647c23dfce20834f4306db3b77d (patch) | |
tree | fba6861bdb58153acaab1ba1e51ec4e48fe0fd99 /drivers/net/wireless | |
parent | 378c6697a282c383d89428380a3405bf95189347 (diff) |
[CRYPTO] users: Use block ciphers where applicable
This patch converts all remaining users to use the new block cipher type
where applicable. It also changes all simple cipher operations to use
the new encrypt_one/decrypt_one interface.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/airo.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index a4dd13942714..170c500169da 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c | |||
@@ -19,6 +19,7 @@ | |||
19 | 19 | ||
20 | ======================================================================*/ | 20 | ======================================================================*/ |
21 | 21 | ||
22 | #include <linux/err.h> | ||
22 | #include <linux/init.h> | 23 | #include <linux/init.h> |
23 | 24 | ||
24 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
@@ -1203,7 +1204,7 @@ struct airo_info { | |||
1203 | struct iw_spy_data spy_data; | 1204 | struct iw_spy_data spy_data; |
1204 | struct iw_public_data wireless_data; | 1205 | struct iw_public_data wireless_data; |
1205 | /* MIC stuff */ | 1206 | /* MIC stuff */ |
1206 | struct crypto_tfm *tfm; | 1207 | struct crypto_cipher *tfm; |
1207 | mic_module mod[2]; | 1208 | mic_module mod[2]; |
1208 | mic_statistics micstats; | 1209 | mic_statistics micstats; |
1209 | HostRxDesc rxfids[MPI_MAX_FIDS]; // rx/tx/config MPI350 descriptors | 1210 | HostRxDesc rxfids[MPI_MAX_FIDS]; // rx/tx/config MPI350 descriptors |
@@ -1271,7 +1272,8 @@ static int flashrestart(struct airo_info *ai,struct net_device *dev); | |||
1271 | 1272 | ||
1272 | static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq); | 1273 | static int RxSeqValid (struct airo_info *ai,miccntx *context,int mcast,u32 micSeq); |
1273 | static void MoveWindow(miccntx *context, u32 micSeq); | 1274 | static void MoveWindow(miccntx *context, u32 micSeq); |
1274 | static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *); | 1275 | static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, |
1276 | struct crypto_cipher *tfm); | ||
1275 | static void emmh32_init(emmh32_context *context); | 1277 | static void emmh32_init(emmh32_context *context); |
1276 | static void emmh32_update(emmh32_context *context, u8 *pOctets, int len); | 1278 | static void emmh32_update(emmh32_context *context, u8 *pOctets, int len); |
1277 | static void emmh32_final(emmh32_context *context, u8 digest[4]); | 1279 | static void emmh32_final(emmh32_context *context, u8 digest[4]); |
@@ -1339,10 +1341,11 @@ static int micsetup(struct airo_info *ai) { | |||
1339 | int i; | 1341 | int i; |
1340 | 1342 | ||
1341 | if (ai->tfm == NULL) | 1343 | if (ai->tfm == NULL) |
1342 | ai->tfm = crypto_alloc_tfm("aes", CRYPTO_TFM_REQ_MAY_SLEEP); | 1344 | ai->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); |
1343 | 1345 | ||
1344 | if (ai->tfm == NULL) { | 1346 | if (IS_ERR(ai->tfm)) { |
1345 | airo_print_err(ai->dev->name, "failed to load transform for AES"); | 1347 | airo_print_err(ai->dev->name, "failed to load transform for AES"); |
1348 | ai->tfm = NULL; | ||
1346 | return ERROR; | 1349 | return ERROR; |
1347 | } | 1350 | } |
1348 | 1351 | ||
@@ -1608,7 +1611,8 @@ static void MoveWindow(miccntx *context, u32 micSeq) | |||
1608 | static unsigned char aes_counter[16]; | 1611 | static unsigned char aes_counter[16]; |
1609 | 1612 | ||
1610 | /* expand the key to fill the MMH coefficient array */ | 1613 | /* expand the key to fill the MMH coefficient array */ |
1611 | static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct crypto_tfm *tfm) | 1614 | static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, |
1615 | struct crypto_cipher *tfm) | ||
1612 | { | 1616 | { |
1613 | /* take the keying material, expand if necessary, truncate at 16-bytes */ | 1617 | /* take the keying material, expand if necessary, truncate at 16-bytes */ |
1614 | /* run through AES counter mode to generate context->coeff[] */ | 1618 | /* run through AES counter mode to generate context->coeff[] */ |
@@ -1616,7 +1620,6 @@ static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct | |||
1616 | int i,j; | 1620 | int i,j; |
1617 | u32 counter; | 1621 | u32 counter; |
1618 | u8 *cipher, plain[16]; | 1622 | u8 *cipher, plain[16]; |
1619 | struct scatterlist sg[1]; | ||
1620 | 1623 | ||
1621 | crypto_cipher_setkey(tfm, pkey, 16); | 1624 | crypto_cipher_setkey(tfm, pkey, 16); |
1622 | counter = 0; | 1625 | counter = 0; |
@@ -1627,9 +1630,8 @@ static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct | |||
1627 | aes_counter[12] = (u8)(counter >> 24); | 1630 | aes_counter[12] = (u8)(counter >> 24); |
1628 | counter++; | 1631 | counter++; |
1629 | memcpy (plain, aes_counter, 16); | 1632 | memcpy (plain, aes_counter, 16); |
1630 | sg_set_buf(sg, plain, 16); | 1633 | crypto_cipher_encrypt_one(tfm, plain, plain); |
1631 | crypto_cipher_encrypt(tfm, sg, sg, 16); | 1634 | cipher = plain; |
1632 | cipher = kmap(sg->page) + sg->offset; | ||
1633 | for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) { | 1635 | for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) { |
1634 | context->coeff[i++] = ntohl(*(u32 *)&cipher[j]); | 1636 | context->coeff[i++] = ntohl(*(u32 *)&cipher[j]); |
1635 | j += 4; | 1637 | j += 4; |
@@ -2432,7 +2434,7 @@ void stop_airo_card( struct net_device *dev, int freeres ) | |||
2432 | ai->shared, ai->shared_dma); | 2434 | ai->shared, ai->shared_dma); |
2433 | } | 2435 | } |
2434 | } | 2436 | } |
2435 | crypto_free_tfm(ai->tfm); | 2437 | crypto_free_cipher(ai->tfm); |
2436 | del_airo_dev( dev ); | 2438 | del_airo_dev( dev ); |
2437 | free_netdev( dev ); | 2439 | free_netdev( dev ); |
2438 | } | 2440 | } |