Commit 03be4e45 authored by Eric Biggers's avatar Eric Biggers Committed by Herbert Xu

crypto: authencesn - stop using alignmask of ahash

Now that the alignmask for ahash and shash algorithms is always 0,
simplify the code in authenc accordingly.
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 58e4bb5f
...@@ -87,11 +87,8 @@ static int crypto_authenc_esn_genicv_tail(struct aead_request *req, ...@@ -87,11 +87,8 @@ static int crypto_authenc_esn_genicv_tail(struct aead_request *req,
unsigned int flags) unsigned int flags)
{ {
struct crypto_aead *authenc_esn = crypto_aead_reqtfm(req); struct crypto_aead *authenc_esn = crypto_aead_reqtfm(req);
struct crypto_authenc_esn_ctx *ctx = crypto_aead_ctx(authenc_esn);
struct authenc_esn_request_ctx *areq_ctx = aead_request_ctx(req); struct authenc_esn_request_ctx *areq_ctx = aead_request_ctx(req);
struct crypto_ahash *auth = ctx->auth; u8 *hash = areq_ctx->tail;
u8 *hash = PTR_ALIGN((u8 *)areq_ctx->tail,
crypto_ahash_alignmask(auth) + 1);
unsigned int authsize = crypto_aead_authsize(authenc_esn); unsigned int authsize = crypto_aead_authsize(authenc_esn);
unsigned int assoclen = req->assoclen; unsigned int assoclen = req->assoclen;
unsigned int cryptlen = req->cryptlen; unsigned int cryptlen = req->cryptlen;
...@@ -122,8 +119,7 @@ static int crypto_authenc_esn_genicv(struct aead_request *req, ...@@ -122,8 +119,7 @@ static int crypto_authenc_esn_genicv(struct aead_request *req,
struct authenc_esn_request_ctx *areq_ctx = aead_request_ctx(req); struct authenc_esn_request_ctx *areq_ctx = aead_request_ctx(req);
struct crypto_authenc_esn_ctx *ctx = crypto_aead_ctx(authenc_esn); struct crypto_authenc_esn_ctx *ctx = crypto_aead_ctx(authenc_esn);
struct crypto_ahash *auth = ctx->auth; struct crypto_ahash *auth = ctx->auth;
u8 *hash = PTR_ALIGN((u8 *)areq_ctx->tail, u8 *hash = areq_ctx->tail;
crypto_ahash_alignmask(auth) + 1);
struct ahash_request *ahreq = (void *)(areq_ctx->tail + ctx->reqoff); struct ahash_request *ahreq = (void *)(areq_ctx->tail + ctx->reqoff);
unsigned int authsize = crypto_aead_authsize(authenc_esn); unsigned int authsize = crypto_aead_authsize(authenc_esn);
unsigned int assoclen = req->assoclen; unsigned int assoclen = req->assoclen;
...@@ -224,8 +220,7 @@ static int crypto_authenc_esn_decrypt_tail(struct aead_request *req, ...@@ -224,8 +220,7 @@ static int crypto_authenc_esn_decrypt_tail(struct aead_request *req,
struct skcipher_request *skreq = (void *)(areq_ctx->tail + struct skcipher_request *skreq = (void *)(areq_ctx->tail +
ctx->reqoff); ctx->reqoff);
struct crypto_ahash *auth = ctx->auth; struct crypto_ahash *auth = ctx->auth;
u8 *ohash = PTR_ALIGN((u8 *)areq_ctx->tail, u8 *ohash = areq_ctx->tail;
crypto_ahash_alignmask(auth) + 1);
unsigned int cryptlen = req->cryptlen - authsize; unsigned int cryptlen = req->cryptlen - authsize;
unsigned int assoclen = req->assoclen; unsigned int assoclen = req->assoclen;
struct scatterlist *dst = req->dst; struct scatterlist *dst = req->dst;
...@@ -272,8 +267,7 @@ static int crypto_authenc_esn_decrypt(struct aead_request *req) ...@@ -272,8 +267,7 @@ static int crypto_authenc_esn_decrypt(struct aead_request *req)
struct ahash_request *ahreq = (void *)(areq_ctx->tail + ctx->reqoff); struct ahash_request *ahreq = (void *)(areq_ctx->tail + ctx->reqoff);
unsigned int authsize = crypto_aead_authsize(authenc_esn); unsigned int authsize = crypto_aead_authsize(authenc_esn);
struct crypto_ahash *auth = ctx->auth; struct crypto_ahash *auth = ctx->auth;
u8 *ohash = PTR_ALIGN((u8 *)areq_ctx->tail, u8 *ohash = areq_ctx->tail;
crypto_ahash_alignmask(auth) + 1);
unsigned int assoclen = req->assoclen; unsigned int assoclen = req->assoclen;
unsigned int cryptlen = req->cryptlen; unsigned int cryptlen = req->cryptlen;
u8 *ihash = ohash + crypto_ahash_digestsize(auth); u8 *ihash = ohash + crypto_ahash_digestsize(auth);
...@@ -344,8 +338,7 @@ static int crypto_authenc_esn_init_tfm(struct crypto_aead *tfm) ...@@ -344,8 +338,7 @@ static int crypto_authenc_esn_init_tfm(struct crypto_aead *tfm)
ctx->enc = enc; ctx->enc = enc;
ctx->null = null; ctx->null = null;
ctx->reqoff = ALIGN(2 * crypto_ahash_digestsize(auth), ctx->reqoff = 2 * crypto_ahash_digestsize(auth);
crypto_ahash_alignmask(auth) + 1);
crypto_aead_set_reqsize( crypto_aead_set_reqsize(
tfm, tfm,
...@@ -431,8 +424,7 @@ static int crypto_authenc_esn_create(struct crypto_template *tmpl, ...@@ -431,8 +424,7 @@ static int crypto_authenc_esn_create(struct crypto_template *tmpl,
inst->alg.base.cra_priority = enc->base.cra_priority * 10 + inst->alg.base.cra_priority = enc->base.cra_priority * 10 +
auth_base->cra_priority; auth_base->cra_priority;
inst->alg.base.cra_blocksize = enc->base.cra_blocksize; inst->alg.base.cra_blocksize = enc->base.cra_blocksize;
inst->alg.base.cra_alignmask = auth_base->cra_alignmask | inst->alg.base.cra_alignmask = enc->base.cra_alignmask;
enc->base.cra_alignmask;
inst->alg.base.cra_ctxsize = sizeof(struct crypto_authenc_esn_ctx); inst->alg.base.cra_ctxsize = sizeof(struct crypto_authenc_esn_ctx);
inst->alg.ivsize = enc->ivsize; inst->alg.ivsize = enc->ivsize;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment