diff options
author | Andrzej Zaborowski <andrew.zaborowski@intel.com> | 2015-12-05 11:09:33 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-12-09 07:03:57 -0500 |
commit | 28a4618ad14cf17009a87d8b5718132a5d4ef852 (patch) | |
tree | 64606786f9b6ab9283f714328acde19990b786a1 /crypto | |
parent | 3771df3cff7536da19cba2b4755ad628dc4bf371 (diff) |
crypto: akcipher - add akcipher declarations needed by templates.
Add a struct akcipher_instance and struct akcipher_spawn similar to
how AEAD declares them and the macros for converting to/from
crypto_instance/crypto_spawn. Also add register functions to
avoid exposing crypto_akcipher_type.
Signed-off-by: Andrew Zaborowski <andrew.zaborowski@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/akcipher.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/crypto/akcipher.c b/crypto/akcipher.c index 120ec042ec9e..def301ed1288 100644 --- a/crypto/akcipher.c +++ b/crypto/akcipher.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/cryptouser.h> | 21 | #include <linux/cryptouser.h> |
22 | #include <net/netlink.h> | 22 | #include <net/netlink.h> |
23 | #include <crypto/akcipher.h> | 23 | #include <crypto/akcipher.h> |
24 | #include <crypto/internal/akcipher.h> | ||
24 | #include "internal.h" | 25 | #include "internal.h" |
25 | 26 | ||
26 | #ifdef CONFIG_NET | 27 | #ifdef CONFIG_NET |
@@ -75,9 +76,17 @@ static int crypto_akcipher_init_tfm(struct crypto_tfm *tfm) | |||
75 | return 0; | 76 | return 0; |
76 | } | 77 | } |
77 | 78 | ||
79 | static void crypto_akcipher_free_instance(struct crypto_instance *inst) | ||
80 | { | ||
81 | struct akcipher_instance *akcipher = akcipher_instance(inst); | ||
82 | |||
83 | akcipher->free(akcipher); | ||
84 | } | ||
85 | |||
78 | static const struct crypto_type crypto_akcipher_type = { | 86 | static const struct crypto_type crypto_akcipher_type = { |
79 | .extsize = crypto_alg_extsize, | 87 | .extsize = crypto_alg_extsize, |
80 | .init_tfm = crypto_akcipher_init_tfm, | 88 | .init_tfm = crypto_akcipher_init_tfm, |
89 | .free = crypto_akcipher_free_instance, | ||
81 | #ifdef CONFIG_PROC_FS | 90 | #ifdef CONFIG_PROC_FS |
82 | .show = crypto_akcipher_show, | 91 | .show = crypto_akcipher_show, |
83 | #endif | 92 | #endif |
@@ -88,6 +97,14 @@ static const struct crypto_type crypto_akcipher_type = { | |||
88 | .tfmsize = offsetof(struct crypto_akcipher, base), | 97 | .tfmsize = offsetof(struct crypto_akcipher, base), |
89 | }; | 98 | }; |
90 | 99 | ||
100 | int crypto_grab_akcipher(struct crypto_akcipher_spawn *spawn, const char *name, | ||
101 | u32 type, u32 mask) | ||
102 | { | ||
103 | spawn->base.frontend = &crypto_akcipher_type; | ||
104 | return crypto_grab_spawn(&spawn->base, name, type, mask); | ||
105 | } | ||
106 | EXPORT_SYMBOL_GPL(crypto_grab_akcipher); | ||
107 | |||
91 | struct crypto_akcipher *crypto_alloc_akcipher(const char *alg_name, u32 type, | 108 | struct crypto_akcipher *crypto_alloc_akcipher(const char *alg_name, u32 type, |
92 | u32 mask) | 109 | u32 mask) |
93 | { | 110 | { |
@@ -95,13 +112,20 @@ struct crypto_akcipher *crypto_alloc_akcipher(const char *alg_name, u32 type, | |||
95 | } | 112 | } |
96 | EXPORT_SYMBOL_GPL(crypto_alloc_akcipher); | 113 | EXPORT_SYMBOL_GPL(crypto_alloc_akcipher); |
97 | 114 | ||
98 | int crypto_register_akcipher(struct akcipher_alg *alg) | 115 | static void akcipher_prepare_alg(struct akcipher_alg *alg) |
99 | { | 116 | { |
100 | struct crypto_alg *base = &alg->base; | 117 | struct crypto_alg *base = &alg->base; |
101 | 118 | ||
102 | base->cra_type = &crypto_akcipher_type; | 119 | base->cra_type = &crypto_akcipher_type; |
103 | base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK; | 120 | base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK; |
104 | base->cra_flags |= CRYPTO_ALG_TYPE_AKCIPHER; | 121 | base->cra_flags |= CRYPTO_ALG_TYPE_AKCIPHER; |
122 | } | ||
123 | |||
124 | int crypto_register_akcipher(struct akcipher_alg *alg) | ||
125 | { | ||
126 | struct crypto_alg *base = &alg->base; | ||
127 | |||
128 | akcipher_prepare_alg(alg); | ||
105 | return crypto_register_alg(base); | 129 | return crypto_register_alg(base); |
106 | } | 130 | } |
107 | EXPORT_SYMBOL_GPL(crypto_register_akcipher); | 131 | EXPORT_SYMBOL_GPL(crypto_register_akcipher); |
@@ -112,5 +136,13 @@ void crypto_unregister_akcipher(struct akcipher_alg *alg) | |||
112 | } | 136 | } |
113 | EXPORT_SYMBOL_GPL(crypto_unregister_akcipher); | 137 | EXPORT_SYMBOL_GPL(crypto_unregister_akcipher); |
114 | 138 | ||
139 | int akcipher_register_instance(struct crypto_template *tmpl, | ||
140 | struct akcipher_instance *inst) | ||
141 | { | ||
142 | akcipher_prepare_alg(&inst->alg); | ||
143 | return crypto_register_instance(tmpl, akcipher_crypto_instance(inst)); | ||
144 | } | ||
145 | EXPORT_SYMBOL_GPL(akcipher_register_instance); | ||
146 | |||
115 | MODULE_LICENSE("GPL"); | 147 | MODULE_LICENSE("GPL"); |
116 | MODULE_DESCRIPTION("Generic public key cipher type"); | 148 | MODULE_DESCRIPTION("Generic public key cipher type"); |