aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/algapi.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-10-13 09:58:23 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2007-10-13 09:58:23 -0400
commitebf8889bd1fe3615991ff4494635d237280652a2 (patch)
tree10fb735717122bbb86474339eac07f26e7ccdf40 /crypto/algapi.c
parentb160292cc216a50fd0cd386b0bda2cd48352c73b (diff)
parent752097cec53eea111d087c545179b421e2bde98a (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'crypto/algapi.c')
-rw-r--r--crypto/algapi.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c
index 38aa9e99470..8ff8c2656d9 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -63,9 +63,6 @@ static int crypto_check_alg(struct crypto_alg *alg)
63 if (alg->cra_alignmask & (alg->cra_alignmask + 1)) 63 if (alg->cra_alignmask & (alg->cra_alignmask + 1))
64 return -EINVAL; 64 return -EINVAL;
65 65
66 if (alg->cra_alignmask & alg->cra_blocksize)
67 return -EINVAL;
68
69 if (alg->cra_blocksize > PAGE_SIZE / 8) 66 if (alg->cra_blocksize > PAGE_SIZE / 8)
70 return -EINVAL; 67 return -EINVAL;
71 68
@@ -152,6 +149,11 @@ static int __crypto_register_alg(struct crypto_alg *alg,
152 if (crypto_is_larval(q)) { 149 if (crypto_is_larval(q)) {
153 struct crypto_larval *larval = (void *)q; 150 struct crypto_larval *larval = (void *)q;
154 151
152 /*
153 * Check to see if either our generic name or
154 * specific name can satisfy the name requested
155 * by the larval entry q.
156 */
155 if (strcmp(alg->cra_name, q->cra_name) && 157 if (strcmp(alg->cra_name, q->cra_name) &&
156 strcmp(alg->cra_driver_name, q->cra_name)) 158 strcmp(alg->cra_driver_name, q->cra_name))
157 continue; 159 continue;
@@ -439,13 +441,15 @@ EXPORT_SYMBOL_GPL(crypto_unregister_notifier);
439 441
440struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb) 442struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb)
441{ 443{
442 struct rtattr *rta = tb[CRYPTOA_TYPE - 1]; 444 struct rtattr *rta = tb[0];
443 struct crypto_attr_type *algt; 445 struct crypto_attr_type *algt;
444 446
445 if (!rta) 447 if (!rta)
446 return ERR_PTR(-ENOENT); 448 return ERR_PTR(-ENOENT);
447 if (RTA_PAYLOAD(rta) < sizeof(*algt)) 449 if (RTA_PAYLOAD(rta) < sizeof(*algt))
448 return ERR_PTR(-EINVAL); 450 return ERR_PTR(-EINVAL);
451 if (rta->rta_type != CRYPTOA_TYPE)
452 return ERR_PTR(-EINVAL);
449 453
450 algt = RTA_DATA(rta); 454 algt = RTA_DATA(rta);
451 455
@@ -468,22 +472,41 @@ int crypto_check_attr_type(struct rtattr **tb, u32 type)
468} 472}
469EXPORT_SYMBOL_GPL(crypto_check_attr_type); 473EXPORT_SYMBOL_GPL(crypto_check_attr_type);
470 474
471struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb, u32 type, u32 mask) 475struct crypto_alg *crypto_attr_alg(struct rtattr *rta, u32 type, u32 mask)
472{ 476{
473 struct rtattr *rta = tb[CRYPTOA_ALG - 1];
474 struct crypto_attr_alg *alga; 477 struct crypto_attr_alg *alga;
475 478
476 if (!rta) 479 if (!rta)
477 return ERR_PTR(-ENOENT); 480 return ERR_PTR(-ENOENT);
478 if (RTA_PAYLOAD(rta) < sizeof(*alga)) 481 if (RTA_PAYLOAD(rta) < sizeof(*alga))
479 return ERR_PTR(-EINVAL); 482 return ERR_PTR(-EINVAL);
483 if (rta->rta_type != CRYPTOA_ALG)
484 return ERR_PTR(-EINVAL);
480 485
481 alga = RTA_DATA(rta); 486 alga = RTA_DATA(rta);
482 alga->name[CRYPTO_MAX_ALG_NAME - 1] = 0; 487 alga->name[CRYPTO_MAX_ALG_NAME - 1] = 0;
483 488
484 return crypto_alg_mod_lookup(alga->name, type, mask); 489 return crypto_alg_mod_lookup(alga->name, type, mask);
485} 490}
486EXPORT_SYMBOL_GPL(crypto_get_attr_alg); 491EXPORT_SYMBOL_GPL(crypto_attr_alg);
492
493int crypto_attr_u32(struct rtattr *rta, u32 *num)
494{
495 struct crypto_attr_u32 *nu32;
496
497 if (!rta)
498 return -ENOENT;
499 if (RTA_PAYLOAD(rta) < sizeof(*nu32))
500 return -EINVAL;
501 if (rta->rta_type != CRYPTOA_U32)
502 return -EINVAL;
503
504 nu32 = RTA_DATA(rta);
505 *num = nu32->num;
506
507 return 0;
508}
509EXPORT_SYMBOL_GPL(crypto_attr_u32);
487 510
488struct crypto_instance *crypto_alloc_instance(const char *name, 511struct crypto_instance *crypto_alloc_instance(const char *name,
489 struct crypto_alg *alg) 512 struct crypto_alg *alg)