diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-22 15:51:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-22 15:51:33 -0400 |
commit | 6bbd9b6d694ff7242d63cda2faac4bd59ee4328e (patch) | |
tree | 0641aa896e2ea01f4692973e5fbea429408854f4 /drivers/net | |
parent | a489d159229fcc07bbb7566ac4fac745b79197ad (diff) | |
parent | 3c164bd8153c4644a22dc2101b003c67cd2a0d0a (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (64 commits)
[BLOCK] dm-crypt: trivial comment improvements
[CRYPTO] api: Deprecate crypto_digest_* and crypto_alg_available
[CRYPTO] padlock: Convert padlock-sha to use crypto_hash
[CRYPTO] users: Use crypto_comp and crypto_has_*
[CRYPTO] api: Add crypto_comp and crypto_has_*
[CRYPTO] users: Use crypto_hash interface instead of crypto_digest
[SCSI] iscsi: Use crypto_hash interface instead of crypto_digest
[CRYPTO] digest: Remove old HMAC implementation
[CRYPTO] doc: Update documentation for hash and me
[SCTP]: Use HMAC template and hash interface
[IPSEC]: Use HMAC template and hash interface
[CRYPTO] tcrypt: Use HMAC template and hash interface
[CRYPTO] hmac: Add crypto template implementation
[CRYPTO] digest: Added user API for new hash type
[CRYPTO] api: Mark parts of cipher interface as deprecated
[PATCH] scatterlist: Add const to sg_set_buf/sg_init_one pointer argument
[CRYPTO] drivers: Remove obsolete block cipher operations
[CRYPTO] users: Use block ciphers where applicable
[SUNRPC] GSS: Use block ciphers where applicable
[IPSEC] ESP: Use block ciphers where applicable
...
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ppp_mppe.c | 68 | ||||
-rw-r--r-- | drivers/net/wireless/airo.c | 22 |
2 files changed, 54 insertions, 36 deletions
diff --git a/drivers/net/ppp_mppe.c b/drivers/net/ppp_mppe.c index 51ff9a9d1bb5..f3655fd772f5 100644 --- a/drivers/net/ppp_mppe.c +++ b/drivers/net/ppp_mppe.c | |||
@@ -43,6 +43,7 @@ | |||
43 | * deprecated in 2.6 | 43 | * deprecated in 2.6 |
44 | */ | 44 | */ |
45 | 45 | ||
46 | #include <linux/err.h> | ||
46 | #include <linux/module.h> | 47 | #include <linux/module.h> |
47 | #include <linux/kernel.h> | 48 | #include <linux/kernel.h> |
48 | #include <linux/version.h> | 49 | #include <linux/version.h> |
@@ -64,12 +65,13 @@ MODULE_LICENSE("Dual BSD/GPL"); | |||
64 | MODULE_ALIAS("ppp-compress-" __stringify(CI_MPPE)); | 65 | MODULE_ALIAS("ppp-compress-" __stringify(CI_MPPE)); |
65 | MODULE_VERSION("1.0.2"); | 66 | MODULE_VERSION("1.0.2"); |
66 | 67 | ||
67 | static void | 68 | static unsigned int |
68 | setup_sg(struct scatterlist *sg, const void *address, unsigned int length) | 69 | setup_sg(struct scatterlist *sg, const void *address, unsigned int length) |
69 | { | 70 | { |
70 | sg[0].page = virt_to_page(address); | 71 | sg[0].page = virt_to_page(address); |
71 | sg[0].offset = offset_in_page(address); | 72 | sg[0].offset = offset_in_page(address); |
72 | sg[0].length = length; | 73 | sg[0].length = length; |
74 | return length; | ||
73 | } | 75 | } |
74 | 76 | ||
75 | #define SHA1_PAD_SIZE 40 | 77 | #define SHA1_PAD_SIZE 40 |
@@ -95,8 +97,8 @@ static inline void sha_pad_init(struct sha_pad *shapad) | |||
95 | * State for an MPPE (de)compressor. | 97 | * State for an MPPE (de)compressor. |
96 | */ | 98 | */ |
97 | struct ppp_mppe_state { | 99 | struct ppp_mppe_state { |
98 | struct crypto_tfm *arc4; | 100 | struct crypto_blkcipher *arc4; |
99 | struct crypto_tfm *sha1; | 101 | struct crypto_hash *sha1; |
100 | unsigned char *sha1_digest; | 102 | unsigned char *sha1_digest; |
101 | unsigned char master_key[MPPE_MAX_KEY_LEN]; | 103 | unsigned char master_key[MPPE_MAX_KEY_LEN]; |
102 | unsigned char session_key[MPPE_MAX_KEY_LEN]; | 104 | unsigned char session_key[MPPE_MAX_KEY_LEN]; |
@@ -136,14 +138,21 @@ struct ppp_mppe_state { | |||
136 | */ | 138 | */ |
137 | static void get_new_key_from_sha(struct ppp_mppe_state * state, unsigned char *InterimKey) | 139 | static void get_new_key_from_sha(struct ppp_mppe_state * state, unsigned char *InterimKey) |
138 | { | 140 | { |
141 | struct hash_desc desc; | ||
139 | struct scatterlist sg[4]; | 142 | struct scatterlist sg[4]; |
143 | unsigned int nbytes; | ||
140 | 144 | ||
141 | setup_sg(&sg[0], state->master_key, state->keylen); | 145 | nbytes = setup_sg(&sg[0], state->master_key, state->keylen); |
142 | setup_sg(&sg[1], sha_pad->sha_pad1, sizeof(sha_pad->sha_pad1)); | 146 | nbytes += setup_sg(&sg[1], sha_pad->sha_pad1, |
143 | setup_sg(&sg[2], state->session_key, state->keylen); | 147 | sizeof(sha_pad->sha_pad1)); |
144 | setup_sg(&sg[3], sha_pad->sha_pad2, sizeof(sha_pad->sha_pad2)); | 148 | nbytes += setup_sg(&sg[2], state->session_key, state->keylen); |
149 | nbytes += setup_sg(&sg[3], sha_pad->sha_pad2, | ||
150 | sizeof(sha_pad->sha_pad2)); | ||
145 | 151 | ||
146 | crypto_digest_digest (state->sha1, sg, 4, state->sha1_digest); | 152 | desc.tfm = state->sha1; |
153 | desc.flags = 0; | ||
154 | |||
155 | crypto_hash_digest(&desc, sg, nbytes, state->sha1_digest); | ||
147 | 156 | ||
148 | memcpy(InterimKey, state->sha1_digest, state->keylen); | 157 | memcpy(InterimKey, state->sha1_digest, state->keylen); |
149 | } | 158 | } |
@@ -156,14 +165,15 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key) | |||
156 | { | 165 | { |
157 | unsigned char InterimKey[MPPE_MAX_KEY_LEN]; | 166 | unsigned char InterimKey[MPPE_MAX_KEY_LEN]; |
158 | struct scatterlist sg_in[1], sg_out[1]; | 167 | struct scatterlist sg_in[1], sg_out[1]; |
168 | struct blkcipher_desc desc = { .tfm = state->arc4 }; | ||
159 | 169 | ||
160 | get_new_key_from_sha(state, InterimKey); | 170 | get_new_key_from_sha(state, InterimKey); |
161 | if (!initial_key) { | 171 | if (!initial_key) { |
162 | crypto_cipher_setkey(state->arc4, InterimKey, state->keylen); | 172 | crypto_blkcipher_setkey(state->arc4, InterimKey, state->keylen); |
163 | setup_sg(sg_in, InterimKey, state->keylen); | 173 | setup_sg(sg_in, InterimKey, state->keylen); |
164 | setup_sg(sg_out, state->session_key, state->keylen); | 174 | setup_sg(sg_out, state->session_key, state->keylen); |
165 | if (crypto_cipher_encrypt(state->arc4, sg_out, sg_in, | 175 | if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, |
166 | state->keylen) != 0) { | 176 | state->keylen) != 0) { |
167 | printk(KERN_WARNING "mppe_rekey: cipher_encrypt failed\n"); | 177 | printk(KERN_WARNING "mppe_rekey: cipher_encrypt failed\n"); |
168 | } | 178 | } |
169 | } else { | 179 | } else { |
@@ -175,7 +185,7 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key) | |||
175 | state->session_key[1] = 0x26; | 185 | state->session_key[1] = 0x26; |
176 | state->session_key[2] = 0x9e; | 186 | state->session_key[2] = 0x9e; |
177 | } | 187 | } |
178 | crypto_cipher_setkey(state->arc4, state->session_key, state->keylen); | 188 | crypto_blkcipher_setkey(state->arc4, state->session_key, state->keylen); |
179 | } | 189 | } |
180 | 190 | ||
181 | /* | 191 | /* |
@@ -196,15 +206,19 @@ static void *mppe_alloc(unsigned char *options, int optlen) | |||
196 | 206 | ||
197 | memset(state, 0, sizeof(*state)); | 207 | memset(state, 0, sizeof(*state)); |
198 | 208 | ||
199 | state->arc4 = crypto_alloc_tfm("arc4", 0); | 209 | state->arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); |
200 | if (!state->arc4) | 210 | if (IS_ERR(state->arc4)) { |
211 | state->arc4 = NULL; | ||
201 | goto out_free; | 212 | goto out_free; |
213 | } | ||
202 | 214 | ||
203 | state->sha1 = crypto_alloc_tfm("sha1", 0); | 215 | state->sha1 = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC); |
204 | if (!state->sha1) | 216 | if (IS_ERR(state->sha1)) { |
217 | state->sha1 = NULL; | ||
205 | goto out_free; | 218 | goto out_free; |
219 | } | ||
206 | 220 | ||
207 | digestsize = crypto_tfm_alg_digestsize(state->sha1); | 221 | digestsize = crypto_hash_digestsize(state->sha1); |
208 | if (digestsize < MPPE_MAX_KEY_LEN) | 222 | if (digestsize < MPPE_MAX_KEY_LEN) |
209 | goto out_free; | 223 | goto out_free; |
210 | 224 | ||
@@ -229,9 +243,9 @@ static void *mppe_alloc(unsigned char *options, int optlen) | |||
229 | if (state->sha1_digest) | 243 | if (state->sha1_digest) |
230 | kfree(state->sha1_digest); | 244 | kfree(state->sha1_digest); |
231 | if (state->sha1) | 245 | if (state->sha1) |
232 | crypto_free_tfm(state->sha1); | 246 | crypto_free_hash(state->sha1); |
233 | if (state->arc4) | 247 | if (state->arc4) |
234 | crypto_free_tfm(state->arc4); | 248 | crypto_free_blkcipher(state->arc4); |
235 | kfree(state); | 249 | kfree(state); |
236 | out: | 250 | out: |
237 | return NULL; | 251 | return NULL; |
@@ -247,9 +261,9 @@ static void mppe_free(void *arg) | |||
247 | if (state->sha1_digest) | 261 | if (state->sha1_digest) |
248 | kfree(state->sha1_digest); | 262 | kfree(state->sha1_digest); |
249 | if (state->sha1) | 263 | if (state->sha1) |
250 | crypto_free_tfm(state->sha1); | 264 | crypto_free_hash(state->sha1); |
251 | if (state->arc4) | 265 | if (state->arc4) |
252 | crypto_free_tfm(state->arc4); | 266 | crypto_free_blkcipher(state->arc4); |
253 | kfree(state); | 267 | kfree(state); |
254 | } | 268 | } |
255 | } | 269 | } |
@@ -356,6 +370,7 @@ mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf, | |||
356 | int isize, int osize) | 370 | int isize, int osize) |
357 | { | 371 | { |
358 | struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; | 372 | struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; |
373 | struct blkcipher_desc desc = { .tfm = state->arc4 }; | ||
359 | int proto; | 374 | int proto; |
360 | struct scatterlist sg_in[1], sg_out[1]; | 375 | struct scatterlist sg_in[1], sg_out[1]; |
361 | 376 | ||
@@ -413,7 +428,7 @@ mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf, | |||
413 | /* Encrypt packet */ | 428 | /* Encrypt packet */ |
414 | setup_sg(sg_in, ibuf, isize); | 429 | setup_sg(sg_in, ibuf, isize); |
415 | setup_sg(sg_out, obuf, osize); | 430 | setup_sg(sg_out, obuf, osize); |
416 | if (crypto_cipher_encrypt(state->arc4, sg_out, sg_in, isize) != 0) { | 431 | if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, isize) != 0) { |
417 | printk(KERN_DEBUG "crypto_cypher_encrypt failed\n"); | 432 | printk(KERN_DEBUG "crypto_cypher_encrypt failed\n"); |
418 | return -1; | 433 | return -1; |
419 | } | 434 | } |
@@ -462,6 +477,7 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf, | |||
462 | int osize) | 477 | int osize) |
463 | { | 478 | { |
464 | struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; | 479 | struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg; |
480 | struct blkcipher_desc desc = { .tfm = state->arc4 }; | ||
465 | unsigned ccount; | 481 | unsigned ccount; |
466 | int flushed = MPPE_BITS(ibuf) & MPPE_BIT_FLUSHED; | 482 | int flushed = MPPE_BITS(ibuf) & MPPE_BIT_FLUSHED; |
467 | int sanity = 0; | 483 | int sanity = 0; |
@@ -599,7 +615,7 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf, | |||
599 | */ | 615 | */ |
600 | setup_sg(sg_in, ibuf, 1); | 616 | setup_sg(sg_in, ibuf, 1); |
601 | setup_sg(sg_out, obuf, 1); | 617 | setup_sg(sg_out, obuf, 1); |
602 | if (crypto_cipher_decrypt(state->arc4, sg_out, sg_in, 1) != 0) { | 618 | if (crypto_blkcipher_decrypt(&desc, sg_out, sg_in, 1) != 0) { |
603 | printk(KERN_DEBUG "crypto_cypher_decrypt failed\n"); | 619 | printk(KERN_DEBUG "crypto_cypher_decrypt failed\n"); |
604 | return DECOMP_ERROR; | 620 | return DECOMP_ERROR; |
605 | } | 621 | } |
@@ -619,7 +635,7 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf, | |||
619 | /* And finally, decrypt the rest of the packet. */ | 635 | /* And finally, decrypt the rest of the packet. */ |
620 | setup_sg(sg_in, ibuf + 1, isize - 1); | 636 | setup_sg(sg_in, ibuf + 1, isize - 1); |
621 | setup_sg(sg_out, obuf + 1, osize - 1); | 637 | setup_sg(sg_out, obuf + 1, osize - 1); |
622 | if (crypto_cipher_decrypt(state->arc4, sg_out, sg_in, isize - 1) != 0) { | 638 | if (crypto_blkcipher_decrypt(&desc, sg_out, sg_in, isize - 1)) { |
623 | printk(KERN_DEBUG "crypto_cypher_decrypt failed\n"); | 639 | printk(KERN_DEBUG "crypto_cypher_decrypt failed\n"); |
624 | return DECOMP_ERROR; | 640 | return DECOMP_ERROR; |
625 | } | 641 | } |
@@ -694,8 +710,8 @@ static struct compressor ppp_mppe = { | |||
694 | static int __init ppp_mppe_init(void) | 710 | static int __init ppp_mppe_init(void) |
695 | { | 711 | { |
696 | int answer; | 712 | int answer; |
697 | if (!(crypto_alg_available("arc4", 0) && | 713 | if (!(crypto_has_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC) && |
698 | crypto_alg_available("sha1", 0))) | 714 | crypto_has_hash("sha1", 0, CRYPTO_ALG_ASYNC))) |
699 | return -ENODEV; | 715 | return -ENODEV; |
700 | 716 | ||
701 | sha_pad = kmalloc(sizeof(struct sha_pad), GFP_KERNEL); | 717 | sha_pad = kmalloc(sizeof(struct sha_pad), GFP_KERNEL); |
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 | } |