summaryrefslogtreecommitdiff
path: root/crypto/aead.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2015-05-22 16:30:48 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2015-05-25 18:41:25 +0800
commit8684eae8dddde8a05435386f6491d530e2a203e4 (patch)
tree31b5e74421e4fef2fbb36336a7bd86e5b1ac8a52 /crypto/aead.c
parent27a67168660a99202c8b089edf98c1d8e56145a5 (diff)
downloadlinux-crypto-8684eae8dddde8a05435386f6491d530e2a203e4.tar.gz
linux-crypto-8684eae8dddde8a05435386f6491d530e2a203e4.zip
crypto: aead - Add crypto_aead_alg_ivsize/maxauthsize
AEAD algorithm implementors need to figure out a given algorithm's IV size and maximum authentication size. During the transition this is difficult to do as an algorithm could be new style or old style. This patch creates two helpers to make this easier. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/aead.c')
-rw-r--r--crypto/aead.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/crypto/aead.c b/crypto/aead.c
index 5fa992ac..c1f73a96 100644
--- a/crypto/aead.c
+++ b/crypto/aead.c
@@ -69,7 +69,7 @@ int crypto_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize)
{
int err;
- if (authsize > tfm->maxauthsize)
+ if (authsize > crypto_aead_maxauthsize(tfm))
return -EINVAL;
if (tfm->setauthsize) {
@@ -162,8 +162,6 @@ static int crypto_old_aead_init_tfm(struct crypto_tfm *tfm)
crt->givdecrypt = aead_null_givdecrypt;
}
crt->child = __crypto_aead_cast(tfm);
- crt->ivsize = alg->ivsize;
- crt->maxauthsize = alg->maxauthsize;
crt->authsize = alg->maxauthsize;
return 0;
@@ -182,8 +180,6 @@ static int crypto_aead_init_tfm(struct crypto_tfm *tfm)
aead->encrypt = alg->encrypt;
aead->decrypt = alg->decrypt;
aead->child = __crypto_aead_cast(tfm);
- aead->ivsize = alg->ivsize;
- aead->maxauthsize = alg->maxauthsize;
aead->authsize = alg->maxauthsize;
return 0;
@@ -418,13 +414,8 @@ struct aead_instance *aead_geniv_alloc(struct crypto_template *tmpl,
alg = crypto_spawn_aead_alg(spawn);
- if (alg->base.cra_aead.encrypt) {
- ivsize = alg->base.cra_aead.ivsize;
- maxauthsize = alg->base.cra_aead.maxauthsize;
- } else {
- ivsize = alg->ivsize;
- maxauthsize = alg->maxauthsize;
- }
+ ivsize = crypto_aead_alg_ivsize(alg);
+ maxauthsize = crypto_aead_alg_maxauthsize(alg);
err = -EINVAL;
if (!ivsize)