summaryrefslogtreecommitdiff
path: root/include/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'include/crypto')
-rw-r--r--include/crypto/aead.h21
-rw-r--r--include/crypto/internal/aead.h19
2 files changed, 25 insertions, 15 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));
}
/**
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 {
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);
@@ -145,9 +134,15 @@ static inline void crypto_aead_set_reqsize(struct crypto_aead *aead,
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);