mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
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 <[email protected]>
This commit is contained in:
parent
addfda2fc2
commit
5eb8ec6dc8
2 changed files with 27 additions and 0 deletions
|
|
@ -174,6 +174,14 @@ static int crypto_old_aead_init_tfm(struct crypto_tfm *tfm)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void crypto_aead_exit_tfm(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct crypto_aead *aead = __crypto_aead_cast(tfm);
|
||||
struct aead_alg *alg = crypto_aead_alg(aead);
|
||||
|
||||
alg->exit(aead);
|
||||
}
|
||||
|
||||
static int crypto_aead_init_tfm(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct crypto_aead *aead = __crypto_aead_cast(tfm);
|
||||
|
|
@ -189,6 +197,12 @@ static int crypto_aead_init_tfm(struct crypto_tfm *tfm)
|
|||
aead->child = __crypto_aead_cast(tfm);
|
||||
aead->authsize = alg->maxauthsize;
|
||||
|
||||
if (alg->exit)
|
||||
aead->base.exit = crypto_aead_exit_tfm;
|
||||
|
||||
if (alg->init)
|
||||
return alg->init(aead);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue