]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
dm crypt: use crypto_shash_digest() in crypt_iv_tcw_whitening()
authorEric Biggers <ebiggers@google.com>
Sun, 29 Oct 2023 04:59:23 +0000 (21:59 -0700)
committerMike Snitzer <snitzer@kernel.org>
Tue, 31 Oct 2023 15:06:21 +0000 (11:06 -0400)
Simplify crypt_iv_tcw_whitening() by using crypto_shash_digest() instead
of an init+update+final sequence.  This should also improve performance.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-crypt.c

index 8a03b359073327b3268bbf9b2ba63bc3657b6c3c..4b5c54d0c51a6bbf5319c520a929613b16e2eeee 100644 (file)
@@ -652,13 +652,7 @@ static int crypt_iv_tcw_whitening(struct crypt_config *cc,
        /* calculate crc32 for every 32bit part and xor it */
        desc->tfm = tcw->crc32_tfm;
        for (i = 0; i < 4; i++) {
-               r = crypto_shash_init(desc);
-               if (r)
-                       goto out;
-               r = crypto_shash_update(desc, &buf[i * 4], 4);
-               if (r)
-                       goto out;
-               r = crypto_shash_final(desc, &buf[i * 4]);
+               r = crypto_shash_digest(desc, &buf[i * 4], 4, &buf[i * 4]);
                if (r)
                        goto out;
        }