diff options
author | Steffen Klassert <steffen.klassert@secunet.com> | 2011-09-27 01:26:10 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2011-10-21 08:24:04 -0400 |
commit | f4d663ce6357e533f107ce3789bd8848c94bea81 (patch) | |
tree | dededa6ed501f8d6a0d141c4c94b72ec2395ea2c | |
parent | 6c5a86f529a9e9ca4c9aca5fa477e9557d4a3d3d (diff) |
crypto: Add userspace report for shash type algorithms
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | crypto/shash.c | 21 | ||||
-rw-r--r-- | include/linux/cryptouser.h | 7 |
2 files changed, 28 insertions, 0 deletions
diff --git a/crypto/shash.c b/crypto/shash.c index 76f74b963151..ea8a9c6e21e3 100644 --- a/crypto/shash.c +++ b/crypto/shash.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/seq_file.h> | 19 | #include <linux/seq_file.h> |
20 | #include <linux/cryptouser.h> | ||
21 | #include <net/netlink.h> | ||
20 | 22 | ||
21 | #include "internal.h" | 23 | #include "internal.h" |
22 | 24 | ||
@@ -522,6 +524,24 @@ static unsigned int crypto_shash_extsize(struct crypto_alg *alg) | |||
522 | return alg->cra_ctxsize; | 524 | return alg->cra_ctxsize; |
523 | } | 525 | } |
524 | 526 | ||
527 | static int crypto_shash_report(struct sk_buff *skb, struct crypto_alg *alg) | ||
528 | { | ||
529 | struct crypto_report_hash rhash; | ||
530 | struct shash_alg *salg = __crypto_shash_alg(alg); | ||
531 | |||
532 | snprintf(rhash.type, CRYPTO_MAX_ALG_NAME, "%s", "shash"); | ||
533 | rhash.blocksize = alg->cra_blocksize; | ||
534 | rhash.digestsize = salg->digestsize; | ||
535 | |||
536 | NLA_PUT(skb, CRYPTOCFGA_REPORT_HASH, | ||
537 | sizeof(struct crypto_report_hash), &rhash); | ||
538 | |||
539 | return 0; | ||
540 | |||
541 | nla_put_failure: | ||
542 | return -EMSGSIZE; | ||
543 | } | ||
544 | |||
525 | static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg) | 545 | static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg) |
526 | __attribute__ ((unused)); | 546 | __attribute__ ((unused)); |
527 | static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg) | 547 | static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg) |
@@ -541,6 +561,7 @@ static const struct crypto_type crypto_shash_type = { | |||
541 | #ifdef CONFIG_PROC_FS | 561 | #ifdef CONFIG_PROC_FS |
542 | .show = crypto_shash_show, | 562 | .show = crypto_shash_show, |
543 | #endif | 563 | #endif |
564 | .report = crypto_shash_report, | ||
544 | .maskclear = ~CRYPTO_ALG_TYPE_MASK, | 565 | .maskclear = ~CRYPTO_ALG_TYPE_MASK, |
545 | .maskset = CRYPTO_ALG_TYPE_MASK, | 566 | .maskset = CRYPTO_ALG_TYPE_MASK, |
546 | .type = CRYPTO_ALG_TYPE_SHASH, | 567 | .type = CRYPTO_ALG_TYPE_SHASH, |
diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h index 7a849b4c3b82..ee4688221975 100644 --- a/include/linux/cryptouser.h +++ b/include/linux/cryptouser.h | |||
@@ -37,6 +37,7 @@ enum crypto_attr_type_t { | |||
37 | CRYPTOCFGA_UNSPEC, | 37 | CRYPTOCFGA_UNSPEC, |
38 | CRYPTOCFGA_PRIORITY_VAL, /* __u32 */ | 38 | CRYPTOCFGA_PRIORITY_VAL, /* __u32 */ |
39 | CRYPTOCFGA_REPORT_LARVAL, /* struct crypto_report_larval */ | 39 | CRYPTOCFGA_REPORT_LARVAL, /* struct crypto_report_larval */ |
40 | CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */ | ||
40 | __CRYPTOCFGA_MAX | 41 | __CRYPTOCFGA_MAX |
41 | 42 | ||
42 | #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) | 43 | #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) |
@@ -55,3 +56,9 @@ struct crypto_user_alg { | |||
55 | struct crypto_report_larval { | 56 | struct crypto_report_larval { |
56 | char type[CRYPTO_MAX_NAME]; | 57 | char type[CRYPTO_MAX_NAME]; |
57 | }; | 58 | }; |
59 | |||
60 | struct crypto_report_hash { | ||
61 | char type[CRYPTO_MAX_NAME]; | ||
62 | unsigned int blocksize; | ||
63 | unsigned int digestsize; | ||
64 | }; | ||