diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-05-28 10:07:53 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-06-02 22:48:33 -0400 |
commit | 5eb8ec6dc857d5027bc8cf7268a199107a583ae5 (patch) | |
tree | 10e5d26c2b95a199307219cd78838c5ab1fd251d /crypto/aead.c | |
parent | addfda2fc2ed2fcd7896ef689aa75a7d35a7579b (diff) |
crypto: aead - Add type-safe init/exit functions
As it stands the only non-type safe functions left in the new
AEAD interface are the cra_init/cra_exit functions. It means
exposing the ugly __crypto_aead_cast to every AEAD implementor.
This patch adds type-safe init/exit functions to AEAD. Existing
algorithms are unaffected while new implementations can simply
fill in these two instead of cra_init/cra_exit.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/aead.c')
-rw-r--r-- | crypto/aead.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/aead.c b/crypto/aead.c index 8cdea89909cd..4bab3cff3578 100644 --- a/crypto/aead.c +++ b/crypto/aead.c | |||
@@ -174,6 +174,14 @@ static int crypto_old_aead_init_tfm(struct crypto_tfm *tfm) | |||
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
176 | 176 | ||
177 | static void crypto_aead_exit_tfm(struct crypto_tfm *tfm) | ||
178 | { | ||
179 | struct crypto_aead *aead = __crypto_aead_cast(tfm); | ||
180 | struct aead_alg *alg = crypto_aead_alg(aead); | ||
181 | |||
182 | alg->exit(aead); | ||
183 | } | ||
184 | |||
177 | static int crypto_aead_init_tfm(struct crypto_tfm *tfm) | 185 | static int crypto_aead_init_tfm(struct crypto_tfm *tfm) |
178 | { | 186 | { |
179 | struct crypto_aead *aead = __crypto_aead_cast(tfm); | 187 | struct crypto_aead *aead = __crypto_aead_cast(tfm); |
@@ -189,6 +197,12 @@ static int crypto_aead_init_tfm(struct crypto_tfm *tfm) | |||
189 | aead->child = __crypto_aead_cast(tfm); | 197 | aead->child = __crypto_aead_cast(tfm); |
190 | aead->authsize = alg->maxauthsize; | 198 | aead->authsize = alg->maxauthsize; |
191 | 199 | ||
200 | if (alg->exit) | ||
201 | aead->base.exit = crypto_aead_exit_tfm; | ||
202 | |||
203 | if (alg->init) | ||
204 | return alg->init(aead); | ||
205 | |||
192 | return 0; | 206 | return 0; |
193 | } | 207 | } |
194 | 208 | ||