aboutsummaryrefslogtreecommitdiffstats
path: root/include/crypto/internal/aead.h
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2015-05-22 04:30:48 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-05-25 06:41:25 -0400
commit30e4c010aefdbb81b2aaf64758850432eb289f47 (patch)
tree430936c4d6c4aa50c14d3d37c438c54f73a526fd /include/crypto/internal/aead.h
parent445a8e0df3ef80f3696014187a463d6c0772331b (diff)
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/internal/aead.h')
-rw-r--r--include/crypto/internal/aead.h19
1 files changed, 7 insertions, 12 deletions
diff --git a/include/crypto/internal/aead.h b/include/crypto/internal/aead.h
index 08f2ca6c020e..4137330f01ab 100644
--- a/include/crypto/internal/aead.h
+++ b/include/crypto/internal/aead.h
@@ -30,17 +30,6 @@ struct crypto_aead_spawn {
30extern const struct crypto_type crypto_aead_type; 30extern const struct crypto_type crypto_aead_type;
31extern const struct crypto_type crypto_nivaead_type; 31extern const struct crypto_type crypto_nivaead_type;
32 32
33static inline struct old_aead_alg *crypto_old_aead_alg(struct crypto_aead *tfm)
34{
35 return &crypto_aead_tfm(tfm)->__crt_alg->cra_aead;
36}
37
38static inline struct aead_alg *crypto_aead_alg(struct crypto_aead *tfm)
39{
40 return container_of(crypto_aead_tfm(tfm)->__crt_alg,
41 struct aead_alg, base);
42}
43
44static inline void *crypto_aead_ctx(struct crypto_aead *tfm) 33static inline void *crypto_aead_ctx(struct crypto_aead *tfm)
45{ 34{
46 return crypto_tfm_ctx(&tfm->base); 35 return crypto_tfm_ctx(&tfm->base);
@@ -145,9 +134,15 @@ static inline void crypto_aead_set_reqsize(struct crypto_aead *aead,
145 crypto_aead_crt(aead)->reqsize = reqsize; 134 crypto_aead_crt(aead)->reqsize = reqsize;
146} 135}
147 136
137static inline unsigned int crypto_aead_alg_maxauthsize(struct aead_alg *alg)
138{
139 return alg->base.cra_aead.encrypt ? alg->base.cra_aead.maxauthsize :
140 alg->maxauthsize;
141}
142
148static inline unsigned int crypto_aead_maxauthsize(struct crypto_aead *aead) 143static inline unsigned int crypto_aead_maxauthsize(struct crypto_aead *aead)
149{ 144{
150 return aead->maxauthsize; 145 return crypto_aead_alg_maxauthsize(crypto_aead_alg(aead));
151} 146}
152 147
153int crypto_register_aead(struct aead_alg *alg); 148int crypto_register_aead(struct aead_alg *alg);