Skip to content

Commit 03be4e4

Browse files
ebiggersherbertx
authored andcommitted
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: Eric Biggers <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 58e4bb5 commit 03be4e4

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

crypto/authencesn.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,8 @@ static int crypto_authenc_esn_genicv_tail(struct aead_request *req,
8787
unsigned int flags)
8888
{
8989
struct crypto_aead *authenc_esn = crypto_aead_reqtfm(req);
90-
struct crypto_authenc_esn_ctx *ctx = crypto_aead_ctx(authenc_esn);
9190
struct authenc_esn_request_ctx *areq_ctx = aead_request_ctx(req);
92-
struct crypto_ahash *auth = ctx->auth;
93-
u8 *hash = PTR_ALIGN((u8 *)areq_ctx->tail,
94-
crypto_ahash_alignmask(auth) + 1);
91+
u8 *hash = areq_ctx->tail;
9592
unsigned int authsize = crypto_aead_authsize(authenc_esn);
9693
unsigned int assoclen = req->assoclen;
9794
unsigned int cryptlen = req->cryptlen;
@@ -122,8 +119,7 @@ static int crypto_authenc_esn_genicv(struct aead_request *req,
122119
struct authenc_esn_request_ctx *areq_ctx = aead_request_ctx(req);
123120
struct crypto_authenc_esn_ctx *ctx = crypto_aead_ctx(authenc_esn);
124121
struct crypto_ahash *auth = ctx->auth;
125-
u8 *hash = PTR_ALIGN((u8 *)areq_ctx->tail,
126-
crypto_ahash_alignmask(auth) + 1);
122+
u8 *hash = areq_ctx->tail;
127123
struct ahash_request *ahreq = (void *)(areq_ctx->tail + ctx->reqoff);
128124
unsigned int authsize = crypto_aead_authsize(authenc_esn);
129125
unsigned int assoclen = req->assoclen;
@@ -224,8 +220,7 @@ static int crypto_authenc_esn_decrypt_tail(struct aead_request *req,
224220
struct skcipher_request *skreq = (void *)(areq_ctx->tail +
225221
ctx->reqoff);
226222
struct crypto_ahash *auth = ctx->auth;
227-
u8 *ohash = PTR_ALIGN((u8 *)areq_ctx->tail,
228-
crypto_ahash_alignmask(auth) + 1);
223+
u8 *ohash = areq_ctx->tail;
229224
unsigned int cryptlen = req->cryptlen - authsize;
230225
unsigned int assoclen = req->assoclen;
231226
struct scatterlist *dst = req->dst;
@@ -272,8 +267,7 @@ static int crypto_authenc_esn_decrypt(struct aead_request *req)
272267
struct ahash_request *ahreq = (void *)(areq_ctx->tail + ctx->reqoff);
273268
unsigned int authsize = crypto_aead_authsize(authenc_esn);
274269
struct crypto_ahash *auth = ctx->auth;
275-
u8 *ohash = PTR_ALIGN((u8 *)areq_ctx->tail,
276-
crypto_ahash_alignmask(auth) + 1);
270+
u8 *ohash = areq_ctx->tail;
277271
unsigned int assoclen = req->assoclen;
278272
unsigned int cryptlen = req->cryptlen;
279273
u8 *ihash = ohash + crypto_ahash_digestsize(auth);
@@ -344,8 +338,7 @@ static int crypto_authenc_esn_init_tfm(struct crypto_aead *tfm)
344338
ctx->enc = enc;
345339
ctx->null = null;
346340

347-
ctx->reqoff = ALIGN(2 * crypto_ahash_digestsize(auth),
348-
crypto_ahash_alignmask(auth) + 1);
341+
ctx->reqoff = 2 * crypto_ahash_digestsize(auth);
349342

350343
crypto_aead_set_reqsize(
351344
tfm,
@@ -431,8 +424,7 @@ static int crypto_authenc_esn_create(struct crypto_template *tmpl,
431424
inst->alg.base.cra_priority = enc->base.cra_priority * 10 +
432425
auth_base->cra_priority;
433426
inst->alg.base.cra_blocksize = enc->base.cra_blocksize;
434-
inst->alg.base.cra_alignmask = auth_base->cra_alignmask |
435-
enc->base.cra_alignmask;
427+
inst->alg.base.cra_alignmask = enc->base.cra_alignmask;
436428
inst->alg.base.cra_ctxsize = sizeof(struct crypto_authenc_esn_ctx);
437429

438430
inst->alg.ivsize = enc->ivsize;

0 commit comments

Comments
 (0)