]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: authencesn - stop using alignmask of ahash
authorEric Biggers <ebiggers@google.com>
Sun, 22 Oct 2023 08:10:46 +0000 (01:10 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 27 Oct 2023 10:04:29 +0000 (18:04 +0800)
Now that the alignmask for ahash and shash algorithms is always 0,
simplify the code in authenc accordingly.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/authencesn.c

index 60e9568f023f6ea62cb11be440f977dc49b298dc..2cc933e2f79011076be98ed53354b3363b3d0fb8 100644 (file)
@@ -87,11 +87,8 @@ static int crypto_authenc_esn_genicv_tail(struct aead_request *req,
                                          unsigned int flags)
 {
        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 crypto_ahash *auth = ctx->auth;
-       u8 *hash = PTR_ALIGN((u8 *)areq_ctx->tail,
-                            crypto_ahash_alignmask(auth) + 1);
+       u8 *hash = areq_ctx->tail;
        unsigned int authsize = crypto_aead_authsize(authenc_esn);
        unsigned int assoclen = req->assoclen;
        unsigned int cryptlen = req->cryptlen;
@@ -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 crypto_authenc_esn_ctx *ctx = crypto_aead_ctx(authenc_esn);
        struct crypto_ahash *auth = ctx->auth;
-       u8 *hash = PTR_ALIGN((u8 *)areq_ctx->tail,
-                            crypto_ahash_alignmask(auth) + 1);
+       u8 *hash = areq_ctx->tail;
        struct ahash_request *ahreq = (void *)(areq_ctx->tail + ctx->reqoff);
        unsigned int authsize = crypto_aead_authsize(authenc_esn);
        unsigned int assoclen = req->assoclen;
@@ -224,8 +220,7 @@ static int crypto_authenc_esn_decrypt_tail(struct aead_request *req,
        struct skcipher_request *skreq = (void *)(areq_ctx->tail +
                                                  ctx->reqoff);
        struct crypto_ahash *auth = ctx->auth;
-       u8 *ohash = PTR_ALIGN((u8 *)areq_ctx->tail,
-                             crypto_ahash_alignmask(auth) + 1);
+       u8 *ohash = areq_ctx->tail;
        unsigned int cryptlen = req->cryptlen - authsize;
        unsigned int assoclen = req->assoclen;
        struct scatterlist *dst = req->dst;
@@ -272,8 +267,7 @@ static int crypto_authenc_esn_decrypt(struct aead_request *req)
        struct ahash_request *ahreq = (void *)(areq_ctx->tail + ctx->reqoff);
        unsigned int authsize = crypto_aead_authsize(authenc_esn);
        struct crypto_ahash *auth = ctx->auth;
-       u8 *ohash = PTR_ALIGN((u8 *)areq_ctx->tail,
-                             crypto_ahash_alignmask(auth) + 1);
+       u8 *ohash = areq_ctx->tail;
        unsigned int assoclen = req->assoclen;
        unsigned int cryptlen = req->cryptlen;
        u8 *ihash = ohash + crypto_ahash_digestsize(auth);
@@ -344,8 +338,7 @@ static int crypto_authenc_esn_init_tfm(struct crypto_aead *tfm)
        ctx->enc = enc;
        ctx->null = null;
 
-       ctx->reqoff = ALIGN(2 * crypto_ahash_digestsize(auth),
-                           crypto_ahash_alignmask(auth) + 1);
+       ctx->reqoff = 2 * crypto_ahash_digestsize(auth);
 
        crypto_aead_set_reqsize(
                tfm,
@@ -431,8 +424,7 @@ static int crypto_authenc_esn_create(struct crypto_template *tmpl,
        inst->alg.base.cra_priority = enc->base.cra_priority * 10 +
                                      auth_base->cra_priority;
        inst->alg.base.cra_blocksize = enc->base.cra_blocksize;
-       inst->alg.base.cra_alignmask = auth_base->cra_alignmask |
-                                      enc->base.cra_alignmask;
+       inst->alg.base.cra_alignmask = enc->base.cra_alignmask;
        inst->alg.base.cra_ctxsize = sizeof(struct crypto_authenc_esn_ctx);
 
        inst->alg.ivsize = enc->ivsize;