aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/algapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/algapi.c')
-rw-r--r--crypto/algapi.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/crypto/algapi.c b/crypto/algapi.c
index f7d2185b2c8f..491205e11cbe 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -425,15 +425,45 @@ int crypto_unregister_notifier(struct notifier_block *nb)
425} 425}
426EXPORT_SYMBOL_GPL(crypto_unregister_notifier); 426EXPORT_SYMBOL_GPL(crypto_unregister_notifier);
427 427
428struct crypto_alg *crypto_get_attr_alg(void *param, unsigned int len, 428struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb)
429 u32 type, u32 mask)
430{ 429{
431 struct rtattr *rta = param; 430 struct rtattr *rta = tb[CRYPTOA_TYPE - 1];
431 struct crypto_attr_type *algt;
432
433 if (!rta)
434 return ERR_PTR(-ENOENT);
435 if (RTA_PAYLOAD(rta) < sizeof(*algt))
436 return ERR_PTR(-EINVAL);
437
438 algt = RTA_DATA(rta);
439
440 return algt;
441}
442EXPORT_SYMBOL_GPL(crypto_get_attr_type);
443
444int crypto_check_attr_type(struct rtattr **tb, u32 type)
445{
446 struct crypto_attr_type *algt;
447
448 algt = crypto_get_attr_type(tb);
449 if (IS_ERR(algt))
450 return PTR_ERR(algt);
451
452 if ((algt->type ^ type) & algt->mask)
453 return -EINVAL;
454
455 return 0;
456}
457EXPORT_SYMBOL_GPL(crypto_check_attr_type);
458
459struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb, u32 type, u32 mask)
460{
461 struct rtattr *rta = tb[CRYPTOA_ALG - 1];
432 struct crypto_attr_alg *alga; 462 struct crypto_attr_alg *alga;
433 463
434 if (!RTA_OK(rta, len)) 464 if (!rta)
435 return ERR_PTR(-EBADR); 465 return ERR_PTR(-ENOENT);
436 if (rta->rta_type != CRYPTOA_ALG || RTA_PAYLOAD(rta) < sizeof(*alga)) 466 if (RTA_PAYLOAD(rta) < sizeof(*alga))
437 return ERR_PTR(-EINVAL); 467 return ERR_PTR(-EINVAL);
438 468
439 alga = RTA_DATA(rta); 469 alga = RTA_DATA(rta);