crypto: use memcpy_sglist() instead of null skcipher
cover crypto: use memcpy_sglist() instead of null skcipher
For copying data between two scatterlists, just use memcpy_sglist() instead of the so-called "null skcipher". This is much simpler.
Eric Biggers (8):
crypto: algif_aead - use memcpy_sglist() instead of null skcipher
crypto: authenc - use memcpy_sglist() instead of null skcipher
crypto: gcm - use memcpy_sglist() instead of null skcipher
crypto: geniv - use memcpy_sglist() instead of null skcipher
crypto: krb5enc - do not select CRYPTO_NULL
crypto: null - remove the default null skcipher
crypto: null - merge CRYPTO_NULL2 into CRYPTO_NULL
crypto: null - use memcpy_sglist()
crypto/Kconfig | 15 +---- crypto/Makefile | 2 +- crypto/algif_aead.c | 101 ++++++-------------------------- crypto/authenc.c | 32 +--------- crypto/authencesn.c | 38 +----------- crypto/crypto_null.c | 70 ++-------------------- crypto/echainiv.c | 18 +----- crypto/gcm.c | 41 ++----------- crypto/geniv.c | 13 +--- crypto/seqiv.c | 17 +----- include/crypto/internal/geniv.h | 1 - include/crypto/null.h | 3 - 12 files changed, 41 insertions(+), 310 deletions(-)
base-commit: 64745a9ca890ed60d78162ec511e1983e1946d73
Signature · 1 line
2.49.0
PATCH 1/8 crypto: algif_aead - use memcpy_sglist() instead of null skcipher
From: Eric Biggers <[email protected]>
For copying data between two scatterlists, just use memcpy_sglist() instead of the so-called "null skcipher". This is much simpler.
--- crypto/Kconfig | 1 - crypto/algif_aead.c | 101 ++++++++------------------------------------ 2 files changed, 18 insertions(+), 84 deletions(-)
crypto/Kconfig +0 -1
@@ -1390,11 +1390,10 @@ config CRYPTO_USER_API_RNG_CAVP config CRYPTO_USER_API_AEAD tristate "AEAD cipher algorithms" depends on NET select CRYPTO_AEAD select CRYPTO_SKCIPHER - select CRYPTO_NULL select CRYPTO_USER_API help Enable the userspace interface for AEAD cipher algorithms. See Documentation/crypto/userspace-if.rst and
crypto/algif_aead.c +18 -83
240 lines not on this page · raw message
Signature · 1 line
2.49.0
PATCH 2/8 crypto: authenc - use memcpy_sglist() instead of null skcipher
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
For copying data between two scatterlists, just use memcpy_sglist() instead of the so-called "null skcipher". This is much simpler.
--- crypto/Kconfig | 1 - crypto/authenc.c | 32 +------------------------------- crypto/authencesn.c | 38 +++----------------------------------- 3 files changed, 4 insertions(+), 67 deletions(-)
crypto/Kconfig +0 -1
@@ -226,11 +226,10 @@ config CRYPTO_AUTHENC tristate "Authenc support" select CRYPTO_AEAD select CRYPTO_SKCIPHER select CRYPTO_MANAGER select CRYPTO_HASH - select CRYPTO_NULL help Authenc: Combined mode wrapper for IPsec. This is required for IPSec ESP (XFRM_ESP).
crypto/authenc.c +1 -31
@@ -7,11 +7,10 @@#include <crypto/internal/aead.h> #include <crypto/internal/hash.h> #include <crypto/internal/skcipher.h> #include <crypto/authenc.h> -#include <crypto/null.h> #include <crypto/scatterwalk.h> #include <linux/err.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h>
@@ -26,11 +25,10 @@ struct authenc_instance_ctx { };struct crypto_authenc_ctx {struct crypto_ahash *auth;struct crypto_skcipher *enc; -struct crypto_sync_skcipher *null; };struct authenc_request_ctx {struct scatterlist src[2 ];struct scatterlist dst[2 ];
@@ -168,25 +166,10 @@ static void crypto_authenc_encrypt_done(void *data, int err) out:authenc_request_complete (areq, err); } -static int crypto_authenc_copy_assoc (struct aead_request *req) -{ -struct crypto_aead *authenc =crypto_aead_reqtfm (req); -struct crypto_authenc_ctx *ctx =crypto_aead_ctx (authenc); -SYNC_SKCIPHER_REQUEST_ON_STACK (skreq, ctx->null); - -skcipher_request_set_sync_tfm (skreq, ctx->null); -skcipher_request_set_callback (skreq,aead_request_flags (req), -NULL ,NULL ); -skcipher_request_set_crypt (skreq, req->src, req->dst, req->assoclen, -NULL ); - -return crypto_skcipher_encrypt (skreq); -} -static int crypto_authenc_encrypt (struct aead_request *req) {struct crypto_aead *authenc =crypto_aead_reqtfm (req);struct aead_instance *inst =aead_alg_instance (authenc);struct crypto_authenc_ctx *ctx =crypto_aead_ctx (authenc);
@@ -201,14 +184,11 @@ static int crypto_authenc_encrypt(struct aead_request *req) src =scatterwalk_ffwd (areq_ctx->src, req->src, req->assoclen); dst = src;if (req->src != req->dst) { - err =crypto_authenc_copy_assoc (req); -if (err) -return err; - +memcpy_sglist (req->dst, req->src, req->assoclen); dst =scatterwalk_ffwd (areq_ctx->dst, req->dst, req->assoclen); }skcipher_request_set_tfm (skreq, enc); skcipher_request_set_callback(skreq, aead_request_flags(req),
@@ -301,11 +281,10 @@ static int crypto_authenc_init_tfm(struct crypto_aead *tfm)struct aead_instance *inst =aead_alg_instance (tfm);struct authenc_instance_ctx *ictx =aead_instance_ctx (inst);struct crypto_authenc_ctx *ctx =crypto_aead_ctx (tfm);struct crypto_ahash *auth;struct crypto_skcipher *enc; -struct crypto_sync_skcipher *null;int err; auth =crypto_spawn_ahash (&ictx->auth);if (IS_ERR (auth))return PTR_ERR (auth);
@@ -313,18 +292,12 @@ static int crypto_authenc_init_tfm(struct crypto_aead *tfm) enc =crypto_spawn_skcipher (&ictx->enc); err =PTR_ERR (enc);if (IS_ERR (enc)) goto err_free_ahash; - null =crypto_get_default_null_skcipher (); - err =PTR_ERR (null); -if (IS_ERR (null)) - goto err_free_skcipher; - ctx->auth = auth; ctx->enc = enc; - ctx->null = null; crypto_aead_set_reqsize( tfm, sizeof(struct authenc_request_ctx) + ictx->reqoff +
@@ -334,12 +307,10 @@ static int crypto_authenc_init_tfm(struct crypto_aead *tfm)sizeof (struct skcipher_request ) + crypto_skcipher_reqsize(enc)));return 0 ; -err_free_skcipher: -crypto_free_skcipher (enc); err_free_ahash:crypto_free_ahash (auth);return err; }
@@ -347,11 +318,10 @@ static void crypto_authenc_exit_tfm(struct crypto_aead *tfm) {struct crypto_authenc_ctx *ctx =crypto_aead_ctx (tfm);crypto_free_ahash (ctx->auth);crypto_free_skcipher (ctx->enc); -crypto_put_default_null_skcipher (); }static void crypto_authenc_free (struct aead_instance *inst) {struct authenc_instance_ctx *ctx =aead_instance_ctx (inst);
crypto/authencesn.c +3 -35
@@ -10,11 +10,10 @@#include <crypto/internal/aead.h> #include <crypto/internal/hash.h> #include <crypto/internal/skcipher.h> #include <crypto/authenc.h> -#include <crypto/null.h> #include <crypto/scatterwalk.h> #include <linux/err.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/module.h>
@@ -29,11 +28,10 @@ struct authenc_esn_instance_ctx {struct crypto_authenc_esn_ctx {unsigned int reqoff;struct crypto_ahash *auth;struct crypto_skcipher *enc; -struct crypto_sync_skcipher *null; };struct authenc_esn_request_ctx {struct scatterlist src[2 ];struct scatterlist dst[2 ];
@@ -156,24 +154,10 @@ static void crypto_authenc_esn_encrypt_done(void *data, int err) err =crypto_authenc_esn_genicv (areq,0 );authenc_esn_request_complete (areq, err); } -static int crypto_authenc_esn_copy (struct aead_request *req,unsigned int len) -{ -struct crypto_aead *authenc_esn =crypto_aead_reqtfm (req); -struct crypto_authenc_esn_ctx *ctx =crypto_aead_ctx (authenc_esn); -SYNC_SKCIPHER_REQUEST_ON_STACK (skreq, ctx->null); - -skcipher_request_set_sync_tfm (skreq, ctx->null); -skcipher_request_set_callback (skreq,aead_request_flags (req), -NULL ,NULL ); -skcipher_request_set_crypt (skreq, req->src, req->dst, len,NULL ); - -return crypto_skcipher_encrypt (skreq); -} -static int crypto_authenc_esn_encrypt (struct aead_request *req) {struct crypto_aead *authenc_esn =crypto_aead_reqtfm (req);struct authenc_esn_request_ctx *areq_ctx =aead_request_ctx (req);struct crypto_authenc_esn_ctx *ctx =crypto_aead_ctx (authenc_esn);
@@ -188,14 +172,11 @@ static int crypto_authenc_esn_encrypt(struct aead_request *req)sg_init_table (areq_ctx->src,2 ); src =scatterwalk_ffwd (areq_ctx->src, req->src, assoclen); dst = src;if (req->src != req->dst) { - err =crypto_authenc_esn_copy (req, assoclen); -if (err) -return err; - +memcpy_sglist (req->dst, req->src, assoclen);sg_init_table (areq_ctx->dst,2 ); dst =scatterwalk_ffwd (areq_ctx->dst, req->dst, assoclen); }skcipher_request_set_tfm (skreq, enc);
@@ -275,15 +256,12 @@ static int crypto_authenc_esn_decrypt(struct aead_request *req)u32 tmp[2 ];int err; cryptlen -= authsize; -if (req->src != dst) { - err =crypto_authenc_esn_copy (req, assoclen + cryptlen); -if (err) -return err; - } +if (req->src != dst) +memcpy_sglist (dst, req->src, assoclen + cryptlen);scatterwalk_map_and_copy (ihash, req->src, assoclen + cryptlen, authsize,0 );if (!authsize)
@@ -315,11 +293,10 @@ static int crypto_authenc_esn_init_tfm(struct crypto_aead *tfm)struct aead_instance *inst =aead_alg_instance (tfm);struct authenc_esn_instance_ctx *ictx =aead_instance_ctx (inst);struct crypto_authenc_esn_ctx *ctx =crypto_aead_ctx (tfm);struct crypto_ahash *auth;struct crypto_skcipher *enc; -struct crypto_sync_skcipher *null;int err; auth =crypto_spawn_ahash (&ictx->auth);if (IS_ERR (auth))return PTR_ERR (auth);
@@ -327,18 +304,12 @@ static int crypto_authenc_esn_init_tfm(struct crypto_aead *tfm) enc =crypto_spawn_skcipher (&ictx->enc); err =PTR_ERR (enc);if (IS_ERR (enc)) goto err_free_ahash; - null =crypto_get_default_null_skcipher (); - err =PTR_ERR (null); -if (IS_ERR (null)) - goto err_free_skcipher; - ctx->auth = auth; ctx->enc = enc; - ctx->null = null; ctx->reqoff =2 *crypto_ahash_digestsize (auth); crypto_aead_set_reqsize( tfm,
@@ -350,12 +321,10 @@ static int crypto_authenc_esn_init_tfm(struct crypto_aead *tfm)sizeof (struct skcipher_request ) + crypto_skcipher_reqsize(enc)));return 0 ; -err_free_skcipher: -crypto_free_skcipher (enc); err_free_ahash:crypto_free_ahash (auth);return err; }
@@ -363,11 +332,10 @@ static void crypto_authenc_esn_exit_tfm(struct crypto_aead *tfm) {struct crypto_authenc_esn_ctx *ctx =crypto_aead_ctx (tfm);crypto_free_ahash (ctx->auth);crypto_free_skcipher (ctx->enc); -crypto_put_default_null_skcipher (); }static void crypto_authenc_esn_free (struct aead_instance *inst) {struct authenc_esn_instance_ctx *ctx =aead_instance_ctx (inst);
Signature · 1 line
2.49.0
PATCH 3/8 crypto: gcm - use memcpy_sglist() instead of null skcipher
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
For copying data between two scatterlists, just use memcpy_sglist() instead of the so-called "null skcipher". This is much simpler.
--- crypto/Kconfig | 1 - crypto/gcm.c | 41 ++++------------------------------------- 2 files changed, 4 insertions(+), 38 deletions(-)
crypto/Kconfig +0 -1
@@ -803,11 +803,10 @@ config CRYPTO_CCM config CRYPTO_GCM tristate "GCM (Galois/Counter Mode) and GMAC (GCM MAC)" select CRYPTO_CTR select CRYPTO_AEAD select CRYPTO_GHASH - select CRYPTO_NULL select CRYPTO_MANAGER help GCM (Galois/Counter Mode) authenticated encryption mode and GMAC (GCM Message Authentication Code) (NIST SP800-38D)
crypto/gcm.c +4 -37
127 lines not on this page · raw message
Signature · 1 line
2.49.0
PATCH 4/8 crypto: geniv - use memcpy_sglist() instead of null skcipher
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
For copying data between two scatterlists, just use memcpy_sglist() instead of the so-called "null skcipher". This is much simpler.
--- crypto/Kconfig | 1 - crypto/echainiv.c | 18 +++--------------- crypto/geniv.c | 13 +------------ crypto/seqiv.c | 17 +++-------------- include/crypto/internal/geniv.h | 1 - 5 files changed, 7 insertions(+), 43 deletions(-)
crypto/Kconfig +0 -1
@@ -813,11 +813,10 @@ config CRYPTO_GCM This is required for IPSec ESP (XFRM_ESP). config CRYPTO_GENIV tristate select CRYPTO_AEAD - select CRYPTO_NULL select CRYPTO_MANAGER select CRYPTO_RNG_DEFAULT config CRYPTO_SEQIV tristate "Sequence Number IV Generator"
crypto/echainiv.c +3 -15
@@ -30,33 +30,21 @@ static int echainiv_encrypt(struct aead_request *req)struct aead_request *subreq =aead_request_ctx (req);__be64 nseqno;u64 seqno;u8 *info;unsigned int ivsize =crypto_aead_ivsize (geniv); -int err;if (req->cryptlen < ivsize)return -EINVAL ;aead_request_set_tfm (subreq, ctx->child); info = req->iv; -if (req->src != req->dst) { -SYNC_SKCIPHER_REQUEST_ON_STACK (nreq, ctx->sknull); - -skcipher_request_set_sync_tfm (nreq, ctx->sknull); -skcipher_request_set_callback (nreq, req->base.flags, -NULL ,NULL ); -skcipher_request_set_crypt (nreq, req->src, req->dst, - req->assoclen + req->cryptlen, -NULL ); - - err =crypto_skcipher_encrypt (nreq); -if (err) -return err; - } +if (req->src != req->dst) +memcpy_sglist (req->dst, req->src, + req->assoclen + req->cryptlen);aead_request_set_callback (subreq, req->base.flags, req->base.complete, req->base.data);aead_request_set_crypt (subreq, req->dst, req->dst, req->cryptlen, info);
crypto/geniv.c +1 -12
@@ -7,11 +7,10 @@* Copyright (c) 2007-2019 Herbert Xu <[email protected]> */ #include <crypto/internal/geniv.h> #include <crypto/internal/rng.h> -#include <crypto/null.h> #include <linux/err.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/rtnetlink.h> #include <linux/slab.h>
@@ -123,41 +122,31 @@ int aead_init_geniv(struct crypto_aead *aead) crypto_aead_ivsize(aead));crypto_put_default_rng ();if (err) goto out; - ctx->sknull =crypto_get_default_null_skcipher (); - err =PTR_ERR (ctx->sknull); -if (IS_ERR (ctx->sknull)) - goto out; - child =crypto_spawn_aead (aead_instance_ctx (inst)); err =PTR_ERR (child);if (IS_ERR (child)) - goto drop_null; + goto out; ctx->child = child;crypto_aead_set_reqsize (aead,crypto_aead_reqsize (child) +sizeof (struct aead_request )); err =0 ; out:return err; - -drop_null: -crypto_put_default_null_skcipher (); - goto out; }EXPORT_SYMBOL_GPL (aead_init_geniv);void aead_exit_geniv (struct crypto_aead *tfm) {struct aead_geniv_ctx *ctx =crypto_aead_ctx (tfm);crypto_free_aead (ctx->child); -crypto_put_default_null_skcipher (); }EXPORT_SYMBOL_GPL (aead_exit_geniv);MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Shared IV generator code" );
crypto/seqiv.c +3 -14
@@ -62,24 +62,13 @@ static int seqiv_aead_encrypt(struct aead_request *req) compl = req->base.complete; data = req->base.data; info = req->iv; -if (req->src != req->dst) { -SYNC_SKCIPHER_REQUEST_ON_STACK (nreq, ctx->sknull); - -skcipher_request_set_sync_tfm (nreq, ctx->sknull); -skcipher_request_set_callback (nreq, req->base.flags, -NULL ,NULL ); -skcipher_request_set_crypt (nreq, req->src, req->dst, - req->assoclen + req->cryptlen, -NULL ); - - err =crypto_skcipher_encrypt (nreq); -if (err) -return err; - } +if (req->src != req->dst) +memcpy_sglist (req->dst, req->src, + req->assoclen + req->cryptlen);if (unlikely (!IS_ALIGNED ((unsigned long )info,crypto_aead_alignmask (geniv) +1 ))) { info = kmemdup(req->iv, ivsize, req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
include/crypto/internal/geniv.h +0 -1
@@ -13,11 +13,10 @@#include <linux/types.h> struct aead_geniv_ctx {spinlock_t lock;struct crypto_aead *child; -struct crypto_sync_skcipher *sknull;u8 salt[] __attribute__ ((aligned (__alignof__(u32 )))); };struct aead_instance *aead_geniv_alloc (struct crypto_template *tmpl,struct rtattr **tb);
Signature · 1 line
2.49.0
PATCH 5/8 crypto: krb5enc - do not select CRYPTO_NULL
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
The krb5enc code does not use any of the so-called "null algorithms", so it does not need to select CRYPTO_NULL. Presumably this unused dependency got copied from one of the other kconfig options.
--- crypto/Kconfig | 1 - 1 file changed, 1 deletion(-)
crypto/Kconfig +0 -1
@@ -237,11 +237,10 @@ config CRYPTO_KRB5ENC tristate "Kerberos 5 combined hash+cipher support" select CRYPTO_AEAD select CRYPTO_SKCIPHER select CRYPTO_MANAGER select CRYPTO_HASH - select CRYPTO_NULL help Combined hash and cipher support for Kerberos 5 RFC3961 simplified profile. This is required for Kerberos 5-style encryption, used by sunrpc/NFS and rxrpc/AFS.
Signature · 1 line
2.49.0
PATCH 6/8 crypto: null - remove the default null skcipher
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
crypto_get_default_null_skcipher() and crypto_put_default_null_skcipher() are no longer used, so remove them.
--- crypto/crypto_null.c | 53 ------------------------------------------- include/crypto/null.h | 3 --- 2 files changed, 56 deletions(-)
crypto/crypto_null.c +0 -53
@@ -15,17 +15,12 @@#include <crypto/null.h> #include <crypto/internal/hash.h> #include <crypto/internal/skcipher.h> #include <linux/init.h> #include <linux/module.h> -#include <linux/spinlock.h> #include <linux/string.h> -static DEFINE_SPINLOCK (crypto_default_null_skcipher_lock); -static struct crypto_sync_skcipher *crypto_default_null_skcipher; -static int crypto_default_null_skcipher_refcnt; -static int null_init (struct shash_desc *desc) {return 0 ; }
@@ -127,58 +122,10 @@ static struct crypto_alg cipher_null = { };MODULE_ALIAS_CRYPTO ("digest_null" );MODULE_ALIAS_CRYPTO ("cipher_null" ); -struct crypto_sync_skcipher *crypto_get_default_null_skcipher (void ) -{ -struct crypto_sync_skcipher *ntfm =NULL ; -struct crypto_sync_skcipher *tfm; - -spin_lock_bh (&crypto_default_null_skcipher_lock); - tfm = crypto_default_null_skcipher; - -if (!tfm) { -spin_unlock_bh (&crypto_default_null_skcipher_lock); - - ntfm =crypto_alloc_sync_skcipher ("ecb(cipher_null)" ,0 ,0 ); -if (IS_ERR (ntfm)) -return ntfm; - -spin_lock_bh (&crypto_default_null_skcipher_lock); - tfm = crypto_default_null_skcipher; -if (!tfm) { - tfm = ntfm; - ntfm =NULL ; - crypto_default_null_skcipher = tfm; - } - } - - crypto_default_null_skcipher_refcnt++; -spin_unlock_bh (&crypto_default_null_skcipher_lock); - -crypto_free_sync_skcipher (ntfm); - -return tfm; -} -EXPORT_SYMBOL_GPL (crypto_get_default_null_skcipher); - -void crypto_put_default_null_skcipher (void ) -{ -struct crypto_sync_skcipher *tfm =NULL ; - -spin_lock_bh (&crypto_default_null_skcipher_lock); -if (!--crypto_default_null_skcipher_refcnt) { - tfm = crypto_default_null_skcipher; - crypto_default_null_skcipher =NULL ; - } -spin_unlock_bh (&crypto_default_null_skcipher_lock); - -crypto_free_sync_skcipher (tfm); -} -EXPORT_SYMBOL_GPL (crypto_put_default_null_skcipher); -static int __init crypto_null_mod_init (void ) {int ret =0 ; ret =crypto_register_alg (&cipher_null);
include/crypto/null.h +0 -3
@@ -7,9 +7,6 @@#define NULL_KEY_SIZE 0#define NULL_BLOCK_SIZE 1#define NULL_DIGEST_SIZE 0#define NULL_IV_SIZE 0 -struct crypto_sync_skcipher *crypto_get_default_null_skcipher (void ); -void crypto_put_default_null_skcipher (void ); -#endif
Signature · 1 line
2.49.0
PATCH 7/8 crypto: null - merge CRYPTO_NULL2 into CRYPTO_NULL
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
There is no reason to have separate CRYPTO_NULL2 and CRYPTO_NULL options. Just merge them into CRYPTO_NULL.
--- crypto/Kconfig | 10 +++------- crypto/Makefile | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-)
crypto/Kconfig +3 -7
@@ -190,20 +190,16 @@ config CRYPTO_MANAGER_EXTRA_TESTS This is intended for developer use only, as these tests take much longer to run than the normal self tests. config CRYPTO_NULL tristate "Null algorithms" - select CRYPTO_NULL2 + select CRYPTO_ALGAPI + select CRYPTO_SKCIPHER + select CRYPTO_HASH help These are 'Null' algorithms, used by IPsec, which do nothing. -config CRYPTO_NULL2 - tristate - select CRYPTO_ALGAPI2 - select CRYPTO_SKCIPHER2 - select CRYPTO_HASH2 - config CRYPTO_PCRYPT tristate "Parallel crypto engine" depends on SMP select PADATA select CRYPTO_MANAGER
crypto/Makefile +1 -1
@@ -69,11 +69,11 @@ cryptomgr-y := algboss.o testmgr.o obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o obj-$(CONFIG_CRYPTO_USER) += crypto_user.o obj-$(CONFIG_CRYPTO_CMAC) += cmac.o obj-$(CONFIG_CRYPTO_HMAC) += hmac.o obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o -obj-$(CONFIG_CRYPTO_NULL2) += crypto_null.o +obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o obj-$(CONFIG_CRYPTO_MD4) += md4.o obj-$(CONFIG_CRYPTO_MD5) += md5.o obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o obj-$(CONFIG_CRYPTO_SHA1) += sha1_generic.o obj-$(CONFIG_CRYPTO_SHA256) += sha256.o
Signature · 1 line
2.49.0
PATCH 8/8 crypto: null - use memcpy_sglist()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Make null_skcipher_crypt() use memcpy_sglist() instead of the skcipher_walk API, as this is simpler.
--- crypto/crypto_null.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
crypto/crypto_null.c +4 -13
@@ -13,10 +13,11 @@*/ #include <crypto/null.h> #include <crypto/internal/hash.h> #include <crypto/internal/skcipher.h> +#include <crypto/scatterwalk.h> #include <linux/init.h> #include <linux/module.h> #include <linux/string.h> static int null_init (struct shash_desc *desc)
@@ -58,23 +59,13 @@ static void null_crypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)memcpy (dst, src,NULL_BLOCK_SIZE ); }static int null_skcipher_crypt (struct skcipher_request *req) { -struct skcipher_walk walk; -int err; - - err =skcipher_walk_virt (&walk, req, false); - -while (walk.nbytes) { -if (walk.src.virt.addr != walk.dst.virt.addr) -memcpy (walk.dst.virt.addr, walk.src.virt.addr, - walk.nbytes); - err =skcipher_walk_done (&walk,0 ); - } - -return err; +if (req->src != req->dst) +memcpy_sglist (req->dst, req->src, req->cryptlen); +return 0 ; }static struct shash_alg digest_null = { .digestsize =NULL_DIGEST_SIZE , .setkey = null_hash_setkey,
Signature · 1 line
2.49.0
Herbert Xu
maintainerQuoted 28 lines · Eric Biggers
For copying data between two scatterlists, just use
memcpy_sglist()instead of the so-called "null skcipher". This is much simpler.Eric Biggers (8):
crypto:algif_aead- usememcpy_sglist()instead of null skcipher
crypto: authenc - usememcpy_sglist()instead of null skcipher
crypto: gcm - usememcpy_sglist()instead of null skcipher
crypto: geniv - usememcpy_sglist()instead of null skcipher
crypto: krb5enc - do not selectCRYPTO_NULL
crypto: null - remove the default null skcipher
crypto: null - mergeCRYPTO_NULL2intoCRYPTO_NULL
crypto: null - usememcpy_sglist()crypto/Kconfig | 15 +---- crypto/Makefile | 2 +- crypto/algif_aead.c | 101 ++++++-------------------------- crypto/authenc.c | 32 +--------- crypto/authencesn.c | 38 +----------- crypto/crypto_null.c | 70 ++-------------------- crypto/echainiv.c | 18 +----- crypto/gcm.c | 41 ++----------- crypto/geniv.c | 13 +--- crypto/seqiv.c | 17 +----- include/crypto/internal/geniv.h | 1 - include/crypto/null.h | 3 - 12 files changed, 41 insertions(+), 310 deletions(-)
Quoted 1 line
base-commit:
64745a9ca890ed60d78162ec511e1983e1946d73
All 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