{
int err;
- if (authsize > tfm->maxauthsize)
+ if (authsize > crypto_aead_maxauthsize(tfm))
return -EINVAL;
if (tfm->setauthsize) {
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;
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;
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)
struct crypto_aead *child;
- unsigned int ivsize;
unsigned int authsize;
- unsigned int maxauthsize;
unsigned int reqsize;
struct crypto_tfm base;
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
*/
static inline unsigned int crypto_aead_ivsize(struct crypto_aead *tfm)
{
- return tfm->ivsize;
+ return crypto_aead_alg_ivsize(crypto_aead_alg(tfm));
}
/**
extern const struct crypto_type crypto_aead_type;
extern const struct crypto_type crypto_nivaead_type;
-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 void *crypto_aead_ctx(struct crypto_aead *tfm)
{
return crypto_tfm_ctx(&tfm->base);
crypto_aead_crt(aead)->reqsize = reqsize;
}
+static inline unsigned int crypto_aead_alg_maxauthsize(struct aead_alg *alg)
+{
+ return alg->base.cra_aead.encrypt ? alg->base.cra_aead.maxauthsize :
+ alg->maxauthsize;
+}
+
static inline unsigned int crypto_aead_maxauthsize(struct crypto_aead *aead)
{
- return aead->maxauthsize;
+ return crypto_aead_alg_maxauthsize(crypto_aead_alg(aead));
}
int crypto_register_aead(struct aead_alg *alg);