diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-03-02 16:08:56 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-02 16:08:56 -0500 |
commit | c02368a9d059322f913a58111eade87a656fefd5 (patch) | |
tree | 2f02dbbe69b86535f58d2010d9adfb20a9c16fb9 /crypto | |
parent | f17c75453b2d195eba0a90d9f16a3ba88c85b3b4 (diff) | |
parent | 778ef1e6cbb049c9bcbf405936ee6f2b6e451892 (diff) |
Merge branch 'linus' into irq/genirq
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/ahash.c | 2 | ||||
-rw-r--r-- | crypto/algapi.c | 6 | ||||
-rw-r--r-- | crypto/api.c | 20 | ||||
-rw-r--r-- | crypto/authenc.c | 24 | ||||
-rw-r--r-- | crypto/blkcipher.c | 2 | ||||
-rw-r--r-- | crypto/ccm.c | 2 | ||||
-rw-r--r-- | crypto/lrw.c | 8 | ||||
-rw-r--r-- | crypto/scatterwalk.c | 3 | ||||
-rw-r--r-- | crypto/shash.c | 7 |
9 files changed, 49 insertions, 25 deletions
diff --git a/crypto/ahash.c b/crypto/ahash.c index ba5292d69ebd..b2d1ee32cfe8 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c | |||
@@ -214,7 +214,7 @@ static void crypto_ahash_show(struct seq_file *m, struct crypto_alg *alg) | |||
214 | seq_printf(m, "async : %s\n", alg->cra_flags & CRYPTO_ALG_ASYNC ? | 214 | seq_printf(m, "async : %s\n", alg->cra_flags & CRYPTO_ALG_ASYNC ? |
215 | "yes" : "no"); | 215 | "yes" : "no"); |
216 | seq_printf(m, "blocksize : %u\n", alg->cra_blocksize); | 216 | seq_printf(m, "blocksize : %u\n", alg->cra_blocksize); |
217 | seq_printf(m, "digestsize : %u\n", alg->cra_hash.digestsize); | 217 | seq_printf(m, "digestsize : %u\n", alg->cra_ahash.digestsize); |
218 | } | 218 | } |
219 | 219 | ||
220 | const struct crypto_type crypto_ahash_type = { | 220 | const struct crypto_type crypto_ahash_type = { |
diff --git a/crypto/algapi.c b/crypto/algapi.c index 7c41e7405c41..56c62e2858d5 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c | |||
@@ -149,6 +149,9 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) | |||
149 | if (q == alg) | 149 | if (q == alg) |
150 | goto err; | 150 | goto err; |
151 | 151 | ||
152 | if (crypto_is_moribund(q)) | ||
153 | continue; | ||
154 | |||
152 | if (crypto_is_larval(q)) { | 155 | if (crypto_is_larval(q)) { |
153 | if (!strcmp(alg->cra_driver_name, q->cra_driver_name)) | 156 | if (!strcmp(alg->cra_driver_name, q->cra_driver_name)) |
154 | goto err; | 157 | goto err; |
@@ -197,7 +200,7 @@ void crypto_alg_tested(const char *name, int err) | |||
197 | 200 | ||
198 | down_write(&crypto_alg_sem); | 201 | down_write(&crypto_alg_sem); |
199 | list_for_each_entry(q, &crypto_alg_list, cra_list) { | 202 | list_for_each_entry(q, &crypto_alg_list, cra_list) { |
200 | if (!crypto_is_larval(q)) | 203 | if (crypto_is_moribund(q) || !crypto_is_larval(q)) |
201 | continue; | 204 | continue; |
202 | 205 | ||
203 | test = (struct crypto_larval *)q; | 206 | test = (struct crypto_larval *)q; |
@@ -210,6 +213,7 @@ void crypto_alg_tested(const char *name, int err) | |||
210 | goto unlock; | 213 | goto unlock; |
211 | 214 | ||
212 | found: | 215 | found: |
216 | q->cra_flags |= CRYPTO_ALG_DEAD; | ||
213 | alg = test->adult; | 217 | alg = test->adult; |
214 | if (err || list_empty(&alg->cra_list)) | 218 | if (err || list_empty(&alg->cra_list)) |
215 | goto complete; | 219 | goto complete; |
diff --git a/crypto/api.c b/crypto/api.c index 9975a7bd246c..efe77df6863f 100644 --- a/crypto/api.c +++ b/crypto/api.c | |||
@@ -557,34 +557,34 @@ err: | |||
557 | return ERR_PTR(err); | 557 | return ERR_PTR(err); |
558 | } | 558 | } |
559 | EXPORT_SYMBOL_GPL(crypto_alloc_tfm); | 559 | EXPORT_SYMBOL_GPL(crypto_alloc_tfm); |
560 | 560 | ||
561 | /* | 561 | /* |
562 | * crypto_free_tfm - Free crypto transform | 562 | * crypto_destroy_tfm - Free crypto transform |
563 | * @mem: Start of tfm slab | ||
563 | * @tfm: Transform to free | 564 | * @tfm: Transform to free |
564 | * | 565 | * |
565 | * crypto_free_tfm() frees up the transform and any associated resources, | 566 | * This function frees up the transform and any associated resources, |
566 | * then drops the refcount on the associated algorithm. | 567 | * then drops the refcount on the associated algorithm. |
567 | */ | 568 | */ |
568 | void crypto_free_tfm(struct crypto_tfm *tfm) | 569 | void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm) |
569 | { | 570 | { |
570 | struct crypto_alg *alg; | 571 | struct crypto_alg *alg; |
571 | int size; | 572 | int size; |
572 | 573 | ||
573 | if (unlikely(!tfm)) | 574 | if (unlikely(!mem)) |
574 | return; | 575 | return; |
575 | 576 | ||
576 | alg = tfm->__crt_alg; | 577 | alg = tfm->__crt_alg; |
577 | size = sizeof(*tfm) + alg->cra_ctxsize; | 578 | size = ksize(mem); |
578 | 579 | ||
579 | if (!tfm->exit && alg->cra_exit) | 580 | if (!tfm->exit && alg->cra_exit) |
580 | alg->cra_exit(tfm); | 581 | alg->cra_exit(tfm); |
581 | crypto_exit_ops(tfm); | 582 | crypto_exit_ops(tfm); |
582 | crypto_mod_put(alg); | 583 | crypto_mod_put(alg); |
583 | memset(tfm, 0, size); | 584 | memset(mem, 0, size); |
584 | kfree(tfm); | 585 | kfree(mem); |
585 | } | 586 | } |
586 | 587 | EXPORT_SYMBOL_GPL(crypto_destroy_tfm); | |
587 | EXPORT_SYMBOL_GPL(crypto_free_tfm); | ||
588 | 588 | ||
589 | int crypto_has_alg(const char *name, u32 type, u32 mask) | 589 | int crypto_has_alg(const char *name, u32 type, u32 mask) |
590 | { | 590 | { |
diff --git a/crypto/authenc.c b/crypto/authenc.c index 40b6e9ec9e3a..5793b64c81a8 100644 --- a/crypto/authenc.c +++ b/crypto/authenc.c | |||
@@ -158,16 +158,19 @@ static int crypto_authenc_genicv(struct aead_request *req, u8 *iv, | |||
158 | dstp = sg_page(dst); | 158 | dstp = sg_page(dst); |
159 | vdst = PageHighMem(dstp) ? NULL : page_address(dstp) + dst->offset; | 159 | vdst = PageHighMem(dstp) ? NULL : page_address(dstp) + dst->offset; |
160 | 160 | ||
161 | sg_init_table(cipher, 2); | 161 | if (ivsize) { |
162 | sg_set_buf(cipher, iv, ivsize); | 162 | sg_init_table(cipher, 2); |
163 | authenc_chain(cipher, dst, vdst == iv + ivsize); | 163 | sg_set_buf(cipher, iv, ivsize); |
164 | authenc_chain(cipher, dst, vdst == iv + ivsize); | ||
165 | dst = cipher; | ||
166 | } | ||
164 | 167 | ||
165 | cryptlen = req->cryptlen + ivsize; | 168 | cryptlen = req->cryptlen + ivsize; |
166 | hash = crypto_authenc_hash(req, flags, cipher, cryptlen); | 169 | hash = crypto_authenc_hash(req, flags, dst, cryptlen); |
167 | if (IS_ERR(hash)) | 170 | if (IS_ERR(hash)) |
168 | return PTR_ERR(hash); | 171 | return PTR_ERR(hash); |
169 | 172 | ||
170 | scatterwalk_map_and_copy(hash, cipher, cryptlen, | 173 | scatterwalk_map_and_copy(hash, dst, cryptlen, |
171 | crypto_aead_authsize(authenc), 1); | 174 | crypto_aead_authsize(authenc), 1); |
172 | return 0; | 175 | return 0; |
173 | } | 176 | } |
@@ -285,11 +288,14 @@ static int crypto_authenc_iverify(struct aead_request *req, u8 *iv, | |||
285 | srcp = sg_page(src); | 288 | srcp = sg_page(src); |
286 | vsrc = PageHighMem(srcp) ? NULL : page_address(srcp) + src->offset; | 289 | vsrc = PageHighMem(srcp) ? NULL : page_address(srcp) + src->offset; |
287 | 290 | ||
288 | sg_init_table(cipher, 2); | 291 | if (ivsize) { |
289 | sg_set_buf(cipher, iv, ivsize); | 292 | sg_init_table(cipher, 2); |
290 | authenc_chain(cipher, src, vsrc == iv + ivsize); | 293 | sg_set_buf(cipher, iv, ivsize); |
294 | authenc_chain(cipher, src, vsrc == iv + ivsize); | ||
295 | src = cipher; | ||
296 | } | ||
291 | 297 | ||
292 | return crypto_authenc_verify(req, cipher, cryptlen + ivsize); | 298 | return crypto_authenc_verify(req, src, cryptlen + ivsize); |
293 | } | 299 | } |
294 | 300 | ||
295 | static int crypto_authenc_decrypt(struct aead_request *req) | 301 | static int crypto_authenc_decrypt(struct aead_request *req) |
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c index 4a7e65c4df4d..d70a41c002df 100644 --- a/crypto/blkcipher.c +++ b/crypto/blkcipher.c | |||
@@ -124,6 +124,7 @@ int blkcipher_walk_done(struct blkcipher_desc *desc, | |||
124 | scatterwalk_done(&walk->in, 0, nbytes); | 124 | scatterwalk_done(&walk->in, 0, nbytes); |
125 | scatterwalk_done(&walk->out, 1, nbytes); | 125 | scatterwalk_done(&walk->out, 1, nbytes); |
126 | 126 | ||
127 | err: | ||
127 | walk->total = nbytes; | 128 | walk->total = nbytes; |
128 | walk->nbytes = nbytes; | 129 | walk->nbytes = nbytes; |
129 | 130 | ||
@@ -132,7 +133,6 @@ int blkcipher_walk_done(struct blkcipher_desc *desc, | |||
132 | return blkcipher_walk_next(desc, walk); | 133 | return blkcipher_walk_next(desc, walk); |
133 | } | 134 | } |
134 | 135 | ||
135 | err: | ||
136 | if (walk->iv != desc->info) | 136 | if (walk->iv != desc->info) |
137 | memcpy(desc->info, walk->iv, crypto_blkcipher_ivsize(tfm)); | 137 | memcpy(desc->info, walk->iv, crypto_blkcipher_ivsize(tfm)); |
138 | if (walk->buffer != walk->page) | 138 | if (walk->buffer != walk->page) |
diff --git a/crypto/ccm.c b/crypto/ccm.c index 7cf7e5a6b781..c36d654cf56a 100644 --- a/crypto/ccm.c +++ b/crypto/ccm.c | |||
@@ -266,6 +266,8 @@ static int crypto_ccm_auth(struct aead_request *req, struct scatterlist *plain, | |||
266 | if (assoclen) { | 266 | if (assoclen) { |
267 | pctx->ilen = format_adata(idata, assoclen); | 267 | pctx->ilen = format_adata(idata, assoclen); |
268 | get_data_to_compute(cipher, pctx, req->assoc, req->assoclen); | 268 | get_data_to_compute(cipher, pctx, req->assoc, req->assoclen); |
269 | } else { | ||
270 | pctx->ilen = 0; | ||
269 | } | 271 | } |
270 | 272 | ||
271 | /* compute plaintext into mac */ | 273 | /* compute plaintext into mac */ |
diff --git a/crypto/lrw.c b/crypto/lrw.c index 8ef664e3bcd9..358f80be2bf9 100644 --- a/crypto/lrw.c +++ b/crypto/lrw.c | |||
@@ -45,7 +45,13 @@ struct priv { | |||
45 | 45 | ||
46 | static inline void setbit128_bbe(void *b, int bit) | 46 | static inline void setbit128_bbe(void *b, int bit) |
47 | { | 47 | { |
48 | __set_bit(bit ^ 0x78, b); | 48 | __set_bit(bit ^ (0x80 - |
49 | #ifdef __BIG_ENDIAN | ||
50 | BITS_PER_LONG | ||
51 | #else | ||
52 | BITS_PER_BYTE | ||
53 | #endif | ||
54 | ), b); | ||
49 | } | 55 | } |
50 | 56 | ||
51 | static int setkey(struct crypto_tfm *parent, const u8 *key, | 57 | static int setkey(struct crypto_tfm *parent, const u8 *key, |
diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c index 9aeeb52004a5..3de89a424401 100644 --- a/crypto/scatterwalk.c +++ b/crypto/scatterwalk.c | |||
@@ -54,7 +54,8 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out, | |||
54 | struct page *page; | 54 | struct page *page; |
55 | 55 | ||
56 | page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT); | 56 | page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT); |
57 | flush_dcache_page(page); | 57 | if (!PageSlab(page)) |
58 | flush_dcache_page(page); | ||
58 | } | 59 | } |
59 | 60 | ||
60 | if (more) { | 61 | if (more) { |
diff --git a/crypto/shash.c b/crypto/shash.c index c9df367332ff..d5a2b619c55f 100644 --- a/crypto/shash.c +++ b/crypto/shash.c | |||
@@ -388,10 +388,15 @@ static int crypto_init_shash_ops_compat(struct crypto_tfm *tfm) | |||
388 | struct shash_desc *desc = crypto_tfm_ctx(tfm); | 388 | struct shash_desc *desc = crypto_tfm_ctx(tfm); |
389 | struct crypto_shash *shash; | 389 | struct crypto_shash *shash; |
390 | 390 | ||
391 | if (!crypto_mod_get(calg)) | ||
392 | return -EAGAIN; | ||
393 | |||
391 | shash = __crypto_shash_cast(crypto_create_tfm( | 394 | shash = __crypto_shash_cast(crypto_create_tfm( |
392 | calg, &crypto_shash_type)); | 395 | calg, &crypto_shash_type)); |
393 | if (IS_ERR(shash)) | 396 | if (IS_ERR(shash)) { |
397 | crypto_mod_put(calg); | ||
394 | return PTR_ERR(shash); | 398 | return PTR_ERR(shash); |
399 | } | ||
395 | 400 | ||
396 | desc->tfm = shash; | 401 | desc->tfm = shash; |
397 | tfm->exit = crypto_exit_shash_ops_compat; | 402 | tfm->exit = crypto_exit_shash_ops_compat; |