summaryrefslogtreecommitdiffstats
path: root/include/crypto/aead.h
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
commit30e4c010aefdbb81b2aaf64758850432eb289f47 (patch)
tree430936c4d6c4aa50c14d3d37c438c54f73a526fd /include/crypto/aead.h
parent445a8e0df3ef80f3696014187a463d6c0772331b (diff)
downloadlinux-30e4c010aefdbb81b2aaf64758850432eb289f47.tar.bz2
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 'include/crypto/aead.h')
-rw-r--r--include/crypto/aead.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/include/crypto/aead.h b/include/crypto/aead.h
index 177e6f46e2bb..ba28c61e765f 100644
--- a/include/crypto/aead.h
+++ b/include/crypto/aead.h
@@ -139,9 +139,7 @@ struct crypto_aead {
struct crypto_aead *child;
- unsigned int ivsize;
unsigned int authsize;
- unsigned int maxauthsize;
unsigned int reqsize;
struct crypto_tfm base;
@@ -187,6 +185,23 @@ static inline struct crypto_aead *crypto_aead_crt(struct crypto_aead *tfm)
return tfm;
}
+static inline struct old_aead_alg *crypto_old_aead_alg(struct crypto_aead *tfm)
+{
+ return &crypto_aead_tfm(tfm)->__crt_alg->cra_aead;
+}
+
+static inline struct aead_alg *crypto_aead_alg(struct crypto_aead *tfm)
+{
+ return container_of(crypto_aead_tfm(tfm)->__crt_alg,
+ struct aead_alg, base);
+}
+
+static inline unsigned int crypto_aead_alg_ivsize(struct aead_alg *alg)
+{
+ return alg->base.cra_aead.encrypt ? alg->base.cra_aead.ivsize :
+ alg->ivsize;
+}
+
/**
* crypto_aead_ivsize() - obtain IV size
* @tfm: cipher handle
@@ -198,7 +213,7 @@ static inline struct crypto_aead *crypto_aead_crt(struct crypto_aead *tfm)
*/
static inline unsigned int crypto_aead_ivsize(struct crypto_aead *tfm)
{
- return tfm->ivsize;
+ return crypto_aead_alg_ivsize(crypto_aead_alg(tfm));
}
/**