Skip to contentSkip to conversation

crypto: chacha_generic - remove unnecessary setkey() functions

PATCH In review Eric Biggers 3 participants 3 messages Nov 18, 2019 – Nov 22, 2019 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: chacha_generic - remove unnecessary setkey() functions

From: Eric Biggers <[email protected]>

Use chacha20_setkey() and chacha12_setkey() from <crypto/internal/chacha.h> instead of defining them again in chacha_generic.c.

---
 crypto/chacha_generic.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)
crypto/chacha_generic.c +3 -15
index c1b147318393..8beea79ab117 100644
@@ -37,18 +37,6 @@ static int chacha_stream_xor(struct skcipher_request *req,
 	return err;
 }
 
-static int crypto_chacha20_setkey(struct crypto_skcipher *tfm, const u8 *key,
-				  unsigned int keysize)
-{
-	return chacha_setkey(tfm, key, keysize, 20);
-}
-
-static int crypto_chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
-				 unsigned int keysize)
-{
-	return chacha_setkey(tfm, key, keysize, 12);
-}
-
 static int crypto_chacha_crypt(struct skcipher_request *req)
 {
 	struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
@@ -91,7 +79,7 @@ static struct skcipher_alg algs[] = {
 		.max_keysize		= CHACHA_KEY_SIZE,
 		.ivsize			= CHACHA_IV_SIZE,
 		.chunksize		= CHACHA_BLOCK_SIZE,
-		.setkey			= crypto_chacha20_setkey,
+		.setkey			= chacha20_setkey,
 		.encrypt		= crypto_chacha_crypt,
 		.decrypt		= crypto_chacha_crypt,
 	}, {
@@ -106,7 +94,7 @@ static struct skcipher_alg algs[] = {
 		.max_keysize		= CHACHA_KEY_SIZE,
 		.ivsize			= XCHACHA_IV_SIZE,
 		.chunksize		= CHACHA_BLOCK_SIZE,
-		.setkey			= crypto_chacha20_setkey,
+		.setkey			= chacha20_setkey,
 		.encrypt		= crypto_xchacha_crypt,
 		.decrypt		= crypto_xchacha_crypt,
 	}, {
@@ -121,7 +109,7 @@ static struct skcipher_alg algs[] = {
 		.max_keysize		= CHACHA_KEY_SIZE,
 		.ivsize			= XCHACHA_IV_SIZE,
 		.chunksize		= CHACHA_BLOCK_SIZE,
-		.setkey			= crypto_chacha12_setkey,
+		.setkey			= chacha12_setkey,
 		.encrypt		= crypto_xchacha_crypt,
 		.decrypt		= crypto_xchacha_crypt,
 	}
Signature · 1 line
2.24.0
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Eric Biggers

From: Eric Biggers <[email protected]>

Use chacha20_setkey() and chacha12_setkey() from <crypto/internal/chacha.h> instead of defining them again in chacha_generic.c.

Quoted 57 lines
---
 crypto/chacha_generic.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)
crypto/chacha_generic.c +3 -16
index c1b147318393..8beea79ab117 100644
@@ -37,18 +37,6 @@ static int chacha_stream_xor(struct skcipher_request *req,
        return err;
 }
 
-static int crypto_chacha20_setkey(struct crypto_skcipher *tfm, const u8 *key,
-                                 unsigned int keysize)
-{
-       return chacha_setkey(tfm, key, keysize, 20);
-}
-
-static int crypto_chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
-                                unsigned int keysize)
-{
-       return chacha_setkey(tfm, key, keysize, 12);
-}
-
 static int crypto_chacha_crypt(struct skcipher_request *req)
 {
        struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
@@ -91,7 +79,7 @@ static struct skcipher_alg algs[] = {
                .max_keysize            = CHACHA_KEY_SIZE,
                .ivsize                 = CHACHA_IV_SIZE,
                .chunksize              = CHACHA_BLOCK_SIZE,
-               .setkey                 = crypto_chacha20_setkey,
+               .setkey                 = chacha20_setkey,
                .encrypt                = crypto_chacha_crypt,
                .decrypt                = crypto_chacha_crypt,
        }, {
@@ -106,7 +94,7 @@ static struct skcipher_alg algs[] = {
                .max_keysize            = CHACHA_KEY_SIZE,
                .ivsize                 = XCHACHA_IV_SIZE,
                .chunksize              = CHACHA_BLOCK_SIZE,
-               .setkey                 = crypto_chacha20_setkey,
+               .setkey                 = chacha20_setkey,
                .encrypt                = crypto_xchacha_crypt,
                .decrypt                = crypto_xchacha_crypt,
        }, {
@@ -121,7 +109,7 @@ static struct skcipher_alg algs[] = {
                .max_keysize            = CHACHA_KEY_SIZE,
                .ivsize                 = XCHACHA_IV_SIZE,
                .chunksize              = CHACHA_BLOCK_SIZE,
-               .setkey                 = crypto_chacha12_setkey,
+               .setkey                 = chacha12_setkey,
                .encrypt                = crypto_xchacha_crypt,
                .decrypt                = crypto_xchacha_crypt,
        }
--

2.24.0

maintainer
#2 lore raw
In reply to Eric Biggers
Quoted 10 lines · Eric Biggers

From: Eric Biggers <[email protected]>

Use chacha20_setkey() and chacha12_setkey() from <crypto/internal/chacha.h> instead of defining them again in chacha_generic.c.

---
 crypto/chacha_generic.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt