]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: lib/chacha - remove unused arch-specific init support
authorEric Biggers <ebiggers@google.com>
Sun, 16 Mar 2025 04:57:47 +0000 (21:57 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 21 Mar 2025 09:39:06 +0000 (17:39 +0800)
All implementations of chacha_init_arch() just call
chacha_init_generic(), so it is pointless.  Just delete it, and replace
chacha_init() with what was previously chacha_init_generic().

Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/arm/crypto/chacha-glue.c
arch/arm64/crypto/chacha-neon-glue.c
arch/mips/crypto/chacha-glue.c
arch/powerpc/crypto/chacha-p10-glue.c
arch/s390/crypto/chacha-glue.c
arch/x86/crypto/chacha_glue.c
crypto/chacha_generic.c
include/crypto/chacha.h
tools/testing/crypto/chacha20-s390/test-cipher.c

index cdde8fd01f8f9b167e9ab7a7da1d8fff595197bc..50e635512046e808dd0114a1b8edd6f3d1cbfe46 100644 (file)
@@ -76,12 +76,6 @@ void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds)
 }
 EXPORT_SYMBOL(hchacha_block_arch);
 
-void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv)
-{
-       chacha_init_generic(state, key, iv);
-}
-EXPORT_SYMBOL(chacha_init_arch);
-
 void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src, unsigned int bytes,
                       int nrounds)
 {
@@ -116,7 +110,7 @@ static int chacha_stream_xor(struct skcipher_request *req,
 
        err = skcipher_walk_virt(&walk, req, false);
 
-       chacha_init_generic(state, ctx->key, iv);
+       chacha_init(state, ctx->key, iv);
 
        while (walk.nbytes > 0) {
                unsigned int nbytes = walk.nbytes;
@@ -166,7 +160,7 @@ static int do_xchacha(struct skcipher_request *req, bool neon)
        u32 state[16];
        u8 real_iv[16];
 
-       chacha_init_generic(state, ctx->key, req->iv);
+       chacha_init(state, ctx->key, req->iv);
 
        if (!IS_ENABLED(CONFIG_KERNEL_MODE_NEON) || !neon) {
                hchacha_block_arm(state, subctx.key, ctx->nrounds);
index af2bbca38e70fb3514bf594cafffbf907c8eeffa..229876acfc581d45036741d985293add0fda19cd 100644 (file)
@@ -74,12 +74,6 @@ void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds)
 }
 EXPORT_SYMBOL(hchacha_block_arch);
 
-void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv)
-{
-       chacha_init_generic(state, key, iv);
-}
-EXPORT_SYMBOL(chacha_init_arch);
-
 void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src, unsigned int bytes,
                       int nrounds)
 {
@@ -110,7 +104,7 @@ static int chacha_neon_stream_xor(struct skcipher_request *req,
 
        err = skcipher_walk_virt(&walk, req, false);
 
-       chacha_init_generic(state, ctx->key, iv);
+       chacha_init(state, ctx->key, iv);
 
        while (walk.nbytes > 0) {
                unsigned int nbytes = walk.nbytes;
@@ -151,7 +145,7 @@ static int xchacha_neon(struct skcipher_request *req)
        u32 state[16];
        u8 real_iv[16];
 
-       chacha_init_generic(state, ctx->key, req->iv);
+       chacha_init(state, ctx->key, req->iv);
        hchacha_block_arch(state, subctx.key, ctx->nrounds);
        subctx.nrounds = ctx->nrounds;
 
index d1fd23e6ef844d13282af3f5731366642bd4a456..f6fc2e1079a19798b608565a9e1ad1ccb9573f56 100644 (file)
@@ -20,12 +20,6 @@ EXPORT_SYMBOL(chacha_crypt_arch);
 asmlinkage void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds);
 EXPORT_SYMBOL(hchacha_block_arch);
 
-void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv)
-{
-       chacha_init_generic(state, key, iv);
-}
-EXPORT_SYMBOL(chacha_init_arch);
-
 static int chacha_mips_stream_xor(struct skcipher_request *req,
                                  const struct chacha_ctx *ctx, const u8 *iv)
 {
@@ -35,7 +29,7 @@ static int chacha_mips_stream_xor(struct skcipher_request *req,
 
        err = skcipher_walk_virt(&walk, req, false);
 
-       chacha_init_generic(state, ctx->key, iv);
+       chacha_init(state, ctx->key, iv);
 
        while (walk.nbytes > 0) {
                unsigned int nbytes = walk.nbytes;
@@ -67,7 +61,7 @@ static int xchacha_mips(struct skcipher_request *req)
        u32 state[16];
        u8 real_iv[16];
 
-       chacha_init_generic(state, ctx->key, req->iv);
+       chacha_init(state, ctx->key, req->iv);
 
        hchacha_block(state, subctx.key, ctx->nrounds);
        subctx.nrounds = ctx->nrounds;
index 7c728755852e1a2cfe06f46cca29eb339be8f4b8..d8796decc1fb723e224a046eb7e9dd5ee18f2088 100644 (file)
@@ -57,12 +57,6 @@ void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds)
 }
 EXPORT_SYMBOL(hchacha_block_arch);
 
-void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv)
-{
-       chacha_init_generic(state, key, iv);
-}
-EXPORT_SYMBOL(chacha_init_arch);
-
 void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src, unsigned int bytes,
                       int nrounds)
 {
@@ -95,7 +89,7 @@ static int chacha_p10_stream_xor(struct skcipher_request *req,
        if (err)
                return err;
 
-       chacha_init_generic(state, ctx->key, iv);
+       chacha_init(state, ctx->key, iv);
 
        while (walk.nbytes > 0) {
                unsigned int nbytes = walk.nbytes;
@@ -137,7 +131,7 @@ static int xchacha_p10(struct skcipher_request *req)
        u32 state[16];
        u8 real_iv[16];
 
-       chacha_init_generic(state, ctx->key, req->iv);
+       chacha_init(state, ctx->key, req->iv);
        hchacha_block_arch(state, subctx.key, ctx->nrounds);
        subctx.nrounds = ctx->nrounds;
 
index f8b0c52e77a4fab95de18f8cda80e098b4fe5ee1..920e9f0941e75c4a0f8f55114b1f4e8908710b23 100644 (file)
@@ -41,7 +41,7 @@ static int chacha20_s390(struct skcipher_request *req)
        int rc;
 
        rc = skcipher_walk_virt(&walk, req, false);
-       chacha_init_generic(state, ctx->key, req->iv);
+       chacha_init(state, ctx->key, req->iv);
 
        while (walk.nbytes > 0) {
                nbytes = walk.nbytes;
@@ -69,12 +69,6 @@ void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds)
 }
 EXPORT_SYMBOL(hchacha_block_arch);
 
-void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv)
-{
-       chacha_init_generic(state, key, iv);
-}
-EXPORT_SYMBOL(chacha_init_arch);
-
 void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src,
                       unsigned int bytes, int nrounds)
 {
index 7b3a1cf0984be3149ad9ec57b166aa9f4233a671..8bb74a2728798b04fe1a4890ac02a905509d670a 100644 (file)
@@ -133,12 +133,6 @@ void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds)
 }
 EXPORT_SYMBOL(hchacha_block_arch);
 
-void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv)
-{
-       chacha_init_generic(state, key, iv);
-}
-EXPORT_SYMBOL(chacha_init_arch);
-
 void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src, unsigned int bytes,
                       int nrounds)
 {
@@ -169,7 +163,7 @@ static int chacha_simd_stream_xor(struct skcipher_request *req,
 
        err = skcipher_walk_virt(&walk, req, false);
 
-       chacha_init_generic(state, ctx->key, iv);
+       chacha_init(state, ctx->key, iv);
 
        while (walk.nbytes > 0) {
                unsigned int nbytes = walk.nbytes;
@@ -211,7 +205,7 @@ static int xchacha_simd(struct skcipher_request *req)
        struct chacha_ctx subctx;
        u8 real_iv[16];
 
-       chacha_init_generic(state, ctx->key, req->iv);
+       chacha_init(state, ctx->key, req->iv);
 
        if (req->cryptlen > CHACHA_BLOCK_SIZE && crypto_simd_usable()) {
                kernel_fpu_begin();
index ba7fcb47f9aa02e7afbd2035922aeabc2d35e7f0..1fb9fbd302c6f75bf4104ec86c4475b1bd98f1c4 100644 (file)
@@ -21,7 +21,7 @@ static int chacha_stream_xor(struct skcipher_request *req,
 
        err = skcipher_walk_virt(&walk, req, false);
 
-       chacha_init_generic(state, ctx->key, iv);
+       chacha_init(state, ctx->key, iv);
 
        while (walk.nbytes > 0) {
                unsigned int nbytes = walk.nbytes;
@@ -54,7 +54,7 @@ static int crypto_xchacha_crypt(struct skcipher_request *req)
        u8 real_iv[16];
 
        /* Compute the subkey given the original key and first 128 nonce bits */
-       chacha_init_generic(state, ctx->key, req->iv);
+       chacha_init(state, ctx->key, req->iv);
        hchacha_block_generic(state, subctx.key, ctx->nrounds);
        subctx.nrounds = ctx->nrounds;
 
index 5bae6a55b3337966da4927e30b546747fc05164c..f8cc073bba41be3cfec5ac9a33f813988cce6c91 100644 (file)
@@ -62,8 +62,7 @@ static inline void chacha_init_consts(u32 *state)
        state[3]  = CHACHA_CONSTANT_TE_K;
 }
 
-void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv);
-static inline void chacha_init_generic(u32 *state, const u32 *key, const u8 *iv)
+static inline void chacha_init(u32 *state, const u32 *key, const u8 *iv)
 {
        chacha_init_consts(state);
        state[4]  = key[0];
@@ -80,14 +79,6 @@ static inline void chacha_init_generic(u32 *state, const u32 *key, const u8 *iv)
        state[15] = get_unaligned_le32(iv + 12);
 }
 
-static inline void chacha_init(u32 *state, const u32 *key, const u8 *iv)
-{
-       if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_CHACHA))
-               chacha_init_arch(state, key, iv);
-       else
-               chacha_init_generic(state, key, iv);
-}
-
 void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src,
                       unsigned int bytes, int nrounds);
 void chacha_crypt_generic(u32 *state, u8 *dst, const u8 *src,
index 8141d45df51aa56e0789be6b31c13a8742cd1030..35ea65c54ffa529f587768c1171f0de2bfc48da5 100644 (file)
@@ -66,7 +66,7 @@ static int test_lib_chacha(u8 *revert, u8 *cipher, u8 *plain)
        }
 
        /* Encrypt */
-       chacha_init_arch(chacha_state, (u32*)key, iv);
+       chacha_init(chacha_state, (u32 *)key, iv);
 
        start = ktime_get_ns();
        chacha_crypt_arch(chacha_state, cipher, plain, data_size, 20);
@@ -81,7 +81,7 @@ static int test_lib_chacha(u8 *revert, u8 *cipher, u8 *plain)
        pr_info("lib encryption took: %lld nsec", end - start);
 
        /* Decrypt */
-       chacha_init_arch(chacha_state, (u32 *)key, iv);
+       chacha_init(chacha_state, (u32 *)key, iv);
 
        start = ktime_get_ns();
        chacha_crypt_arch(chacha_state, revert, cipher, data_size, 20);