crypto: introduce crypto_shash_tfm_digest()
Subsystems (27)
Eric Biggers
maintainercover crypto: introduce crypto_shash_tfm_digest()
This series introduces a helper function crypto_shash_tfm_digest() which replaces the following common pattern:
{
SHASH_DESC_ON_STACK(desc, tfm);
int err;
desc->tfm = tfm;
err = crypto_shash_digest(desc, data, len, out);
shash_desc_zero(desc);
}with:
err = crypto_shash_tfm_digest(tfm, data, len, out);
Patch 1 introduces this helper function, and patches 2-20 convert all relevant users to use it.
IMO, it would be easiest to take all these patches through the crypto tree. But taking just the "crypto:" ones and then me trying to get the rest merged later via subsystem trees is also an option.
Eric Biggers (20):
crypto: hash - introduce crypto_shash_tfm_digest()
crypto: arm64/aes-glue - use crypto_shash_tfm_digest()
crypto: essiv - use crypto_shash_tfm_digest()
crypto: artpec6 - use crypto_shash_tfm_digest()
crypto: ccp - use crypto_shash_tfm_digest()
crypto: ccree - use crypto_shash_tfm_digest()
crypto: hisilicon/sec2 - use crypto_shash_tfm_digest()
crypto: mediatek - use crypto_shash_tfm_digest()
crypto: n2 - use crypto_shash_tfm_digest()
crypto: omap-sham - use crypto_shash_tfm_digest()
crypto: s5p-sss - use crypto_shash_tfm_digest()
nfc: s3fwrn5: use crypto_shash_tfm_digest()
fscrypt: use crypto_shash_tfm_digest()
ecryptfs: use crypto_shash_tfm_digest()
nfsd: use crypto_shash_tfm_digest()
ubifs: use crypto_shash_tfm_digest()
Bluetooth: use crypto_shash_tfm_digest()
sctp: use crypto_shash_tfm_digest()
KEYS: encrypted: use crypto_shash_tfm_digest()
ASoC: cros_ec_codec: use crypto_shash_tfm_digest()
arch/arm64/crypto/aes-glue.c | 4 +-- crypto/essiv.c | 4 +-- crypto/shash.c | 16 +++++++++ drivers/crypto/axis/artpec6_crypto.c | 10 ++---- drivers/crypto/ccp/ccp-crypto-sha.c | 9 ++--- drivers/crypto/ccree/cc_cipher.c | 9 ++--- drivers/crypto/hisilicon/sec2/sec_crypto.c | 5 ++- drivers/crypto/mediatek/mtk-sha.c | 7 ++-- drivers/crypto/n2_core.c | 7 ++-- drivers/crypto/omap-sham.c | 20 +++-------- drivers/crypto/s5p-sss.c | 39 ++++------------------ drivers/nfc/s3fwrn5/firmware.c | 10 +----- fs/crypto/fname.c | 7 +--- fs/crypto/hkdf.c | 6 +--- fs/ecryptfs/crypto.c | 17 +--------- fs/nfsd/nfs4recover.c | 26 ++++----------- fs/ubifs/auth.c | 20 ++--------- fs/ubifs/master.c | 9 ++--- fs/ubifs/replay.c | 14 ++------ include/crypto/hash.h | 19 +++++++++++ net/bluetooth/smp.c | 6 +--- net/sctp/auth.c | 10 ++---- net/sctp/sm_make_chunk.c | 23 +++++-------- security/keys/encrypted-keys/encrypted.c | 18 ++-------- sound/soc/codecs/cros_ec_codec.c | 9 +---- 25 files changed, 95 insertions(+), 229 deletions(-)
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 1/20 crypto: hash - introduce crypto_shash_tfm_digest()
From: Eric Biggers <[email protected]>
Currently the simplest use of the shash API is to use crypto_shash_digest() to digest a whole buffer. However, this still requires allocating a hash descriptor (struct shash_desc). Many users don't really want to preallocate one and instead just use a one-off descriptor on the stack like the following:
{
SHASH_DESC_ON_STACK(desc, tfm);
int err;
desc->tfm = tfm;
err = crypto_shash_digest(desc, data, len, out);
shash_desc_zero(desc);
}Wrap this in a new helper function crypto_shash_tfm_digest() that can be used instead of the above.
--- crypto/shash.c | 16 ++++++++++++++++ include/crypto/hash.h | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+)
crypto/shash.c +16 -0
@@ -206,6 +206,22 @@ int crypto_shash_digest(struct shash_desc *desc, const u8 *data, }EXPORT_SYMBOL_GPL (crypto_shash_digest); +int crypto_shash_tfm_digest (struct crypto_shash *tfm,const u8 *data, +unsigned int len,u8 *out) +{ +SHASH_DESC_ON_STACK (desc, tfm); +int err; + + desc->tfm = tfm; + + err =crypto_shash_digest (desc, data, len, out); + +shash_desc_zero (desc); + +return err; +} +EXPORT_SYMBOL_GPL (crypto_shash_tfm_digest); +static int shash_default_export (struct shash_desc *desc,void *out) {memcpy (out,shash_desc_ctx (desc),crypto_shash_descsize (desc->tfm));
include/crypto/hash.h +19 -0
@@ -855,6 +855,25 @@ int crypto_shash_setkey(struct crypto_shash *tfm, const u8 *key,int crypto_shash_digest (struct shash_desc *desc,const u8 *data,unsigned int len,u8 *out); +/** +* crypto_shash_tfm_digest() - calculate message digest for buffer +* @tfm: hash transformation object +* @data: see crypto_shash_update() +* @len: see crypto_shash_update() +* @out: see crypto_shash_final() +* +* This is a simplified version of crypto_shash_digest() for users who don't +* want to allocate their own hash descriptor (shash_desc). Instead, +* crypto_shash_tfm_digest() takes a hash transformation object (crypto_shash) +* directly, and it allocates a hash descriptor on the stack internally. +* Note that this stack allocation may be fairly large. +* +* Context: Any context. +* Return: 0 on success; < 0 if an error occurred. +*/ +int crypto_shash_tfm_digest (struct crypto_shash *tfm,const u8 *data, +unsigned int len,u8 *out); +/** * crypto_shash_export() - extract operational state for message digest * @desc: reference to the operational state handle whose state is exported
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 2/20 crypto: arm64/aes-glue - use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- arch/arm64/crypto/aes-glue.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/arm64/crypto/aes-glue.c +1 -3
@@ -158,7 +158,6 @@ static int __maybe_unused essiv_cbc_set_key(struct crypto_skcipher *tfm, unsigned int key_len) {struct crypto_aes_essiv_cbc_ctx *ctx =crypto_skcipher_ctx (tfm); -SHASH_DESC_ON_STACK (desc, ctx->hash);u8 digest[SHA256_DIGEST_SIZE ];int ret;
@@ -166,8 +165,7 @@ static int __maybe_unused essiv_cbc_set_key(struct crypto_skcipher *tfm,if (ret)return ret; - desc->tfm = ctx->hash; -crypto_shash_digest (desc, in_key, key_len, digest); +crypto_shash_tfm_digest (ctx->hash, in_key, key_len, digest);return aes_expandkey (&ctx->key2, digest,sizeof (digest)); }
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 3/20 crypto: essiv - use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- crypto/essiv.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
crypto/essiv.c +1 -3
@@ -66,7 +66,6 @@ static int essiv_skcipher_setkey(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) {struct essiv_tfm_ctx *tctx =crypto_skcipher_ctx (tfm); -SHASH_DESC_ON_STACK (desc, tctx->hash);u8 salt[HASH_MAX_DIGESTSIZE ];int err;
@@ -78,8 +77,7 @@ static int essiv_skcipher_setkey(struct crypto_skcipher *tfm,if (err)return err; - desc->tfm = tctx->hash; - err =crypto_shash_digest (desc, key, keylen, salt); + err =crypto_shash_tfm_digest (tctx->hash, key, keylen, salt);if (err)return err;
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 4/20 crypto: artpec6 - use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- drivers/crypto/axis/artpec6_crypto.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/crypto/axis/artpec6_crypto.c +3 -7
@@ -2239,16 +2239,12 @@ artpec6_crypto_hash_set_key(struct crypto_ahash *tfm, blocksize =crypto_tfm_alg_blocksize (crypto_ahash_tfm (tfm));if (keylen > blocksize) { -SHASH_DESC_ON_STACK (hdesc, tfm_ctx->child_hash); - - hdesc->tfm = tfm_ctx->child_hash; - tfm_ctx->hmac_key_length = blocksize; - ret =crypto_shash_digest (hdesc, key, keylen, - tfm_ctx->hmac_key); + + ret =crypto_shash_tfm_digest (tfm_ctx->child_hash, key, keylen, + tfm_ctx->hmac_key);if (ret)return ret; - }else {memcpy (tfm_ctx->hmac_key, key, keylen); tfm_ctx->hmac_key_length = keylen;
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 5/20 crypto: ccp - use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- drivers/crypto/ccp/ccp-crypto-sha.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/crypto/ccp/ccp-crypto-sha.c +2 -7
@@ -272,9 +272,6 @@ static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key, {struct ccp_ctx *ctx =crypto_tfm_ctx (crypto_ahash_tfm (tfm));struct crypto_shash *shash = ctx->u.sha.hmac_tfm; - -SHASH_DESC_ON_STACK (sdesc, shash); -unsigned int block_size =crypto_shash_blocksize (shash);unsigned int digest_size =crypto_shash_digestsize (shash);int i, ret;
@@ -289,10 +286,8 @@ static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key,if (key_len > block_size) {/* Must hash the input key */ - sdesc->tfm = shash; - - ret =crypto_shash_digest (sdesc, key, key_len, - ctx->u.sha.key); + ret =crypto_shash_tfm_digest (shash, key, key_len, + ctx->u.sha.key);if (ret)return -EINVAL ;
Signature · 1 line
2.26.2
Re: [PATCH 05/20] crypto: ccp - use crypto_shash_tfm_digest()
Quoted 8 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct
shash_desc' on the stack and callingcrypto_shash_digest(), switch to using the new helper functioncrypto_shash_tfm_digest()which does this for us.Cc Tom Lendacky <[email protected]>Signed-off-by Eric Biggers <[email protected]>
Quoted 32 lines
--- drivers/crypto/ccp/ccp-crypto-sha.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)drivers/crypto/ccp/ccp-crypto-sha.c +2
-7@@ -272,9 +272,6 @@ static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key, {struct ccp_ctx *ctx =crypto_tfm_ctx (crypto_ahash_tfm (tfm));struct crypto_shash *shash = ctx->u.sha.hmac_tfm; - -SHASH_DESC_ON_STACK (sdesc, shash); -unsigned int block_size =crypto_shash_blocksize (shash);unsigned int digest_size =crypto_shash_digestsize (shash);int i, ret;@@ -289,10 +286,8 @@ static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key,if (key_len > block_size) {/* Must hash the input key */ - sdesc->tfm = shash; - - ret =crypto_shash_digest (sdesc, key, key_len, - ctx->u.sha.key); + ret =crypto_shash_tfm_digest (shash, key, key_len, + ctx->u.sha.key);if (ret)return -EINVAL ;
Eric Biggers
maintainerPATCH 6/20 crypto: ccree - use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- drivers/crypto/ccree/cc_cipher.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/crypto/ccree/cc_cipher.c +3 -6
@@ -427,12 +427,9 @@ static int cc_cipher_setkey(struct crypto_skcipher *sktfm, const u8 *key,int key_len = keylen >>1 ;int err; -SHASH_DESC_ON_STACK (desc, ctx_p->shash_tfm); - - desc->tfm = ctx_p->shash_tfm; - - err =crypto_shash_digest (desc, ctx_p->user.key, key_len, - ctx_p->user.key + key_len); + err =crypto_shash_tfm_digest (ctx_p->shash_tfm, + ctx_p->user.key, key_len, + ctx_p->user.key + key_len);if (err) {dev_err (dev,"Failed to hash ESSIV key.\n" );return err;
Signature · 1 line
2.26.2
Re: [PATCH 06/20] crypto: ccree - use crypto_shash_tfm_digest()
Quoted 34 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct
shash_desc' on the stack and callingcrypto_shash_digest(), switch to using the new helper functioncrypto_shash_tfm_digest()which does this for us.Cc Gilad Ben-Yossef <[email protected]>Signed-off-by Eric Biggers <[email protected]>--- drivers/crypto/ccree/cc_cipher.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/crypto/ccree/cc_cipher.c +3
-7@@ -427,12 +427,9 @@ static int cc_cipher_setkey(struct crypto_skcipher *sktfm, const u8 *key,int key_len = keylen >>1 ;int err; -SHASH_DESC_ON_STACK (desc, ctx_p->shash_tfm); - - desc->tfm = ctx_p->shash_tfm; - - err =crypto_shash_digest (desc, ctx_p->user.key, key_len, - ctx_p->user.key + key_len); + err =crypto_shash_tfm_digest (ctx_p->shash_tfm, + ctx_p->user.key, key_len, + ctx_p->user.key + key_len);if (err) {dev_err (dev,"Failed to hash ESSIV key.\n" );return err; --
Quoted 2 lines
2.26.2
Thanks,
Gilad
Signature · 4 lines
Gilad Ben-Yossef Chief Coffee Drinker values of β will give rise to dom!
Eric Biggers
maintainerPATCH 7/20 crypto: hisilicon/sec2 - use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- drivers/crypto/hisilicon/sec2/sec_crypto.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/crypto/hisilicon/sec2/sec_crypto.c +2 -3
@@ -832,7 +832,6 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx, struct crypto_authenc_keys *keys) {struct crypto_shash *hash_tfm = ctx->hash_tfm; -SHASH_DESC_ON_STACK (shash, hash_tfm);int blocksize, ret;if (!keys->authkeylen) {
@@ -842,8 +841,8 @@ static int sec_aead_auth_set_key(struct sec_auth_ctx *ctx, blocksize =crypto_shash_blocksize (hash_tfm);if (keys->authkeylen > blocksize) { - ret =crypto_shash_digest (shash, keys->authkey, - keys->authkeylen, ctx->a_key); + ret =crypto_shash_tfm_digest (hash_tfm, keys->authkey, + keys->authkeylen, ctx->a_key);if (ret) {pr_err ("hisi_sec2: aead auth digest error!\n" );return -EINVAL ;
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 8/20 crypto: mediatek - use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- drivers/crypto/mediatek/mtk-sha.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/crypto/mediatek/mtk-sha.c +2 -5
@@ -805,12 +805,9 @@ static int mtk_sha_setkey(struct crypto_ahash *tfm, const u8 *key,size_t ds =crypto_shash_digestsize (bctx->shash);int err, i; -SHASH_DESC_ON_STACK (shash, bctx->shash); - - shash->tfm = bctx->shash; -if (keylen > bs) { - err =crypto_shash_digest (shash, key, keylen, bctx->ipad); + err =crypto_shash_tfm_digest (bctx->shash, key, keylen, + bctx->ipad);if (err)return err; keylen = ds;
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 9/20 crypto: n2 - use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- drivers/crypto/n2_core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/crypto/n2_core.c +2 -5
@@ -462,7 +462,6 @@ static int n2_hmac_async_setkey(struct crypto_ahash *tfm, const u8 *key,struct n2_hmac_ctx *ctx =crypto_ahash_ctx (tfm);struct crypto_shash *child_shash = ctx->child_shash;struct crypto_ahash *fallback_tfm; -SHASH_DESC_ON_STACK (shash, child_shash);int err, bs, ds; fallback_tfm = ctx->base.fallback_tfm;
@@ -470,14 +469,12 @@ static int n2_hmac_async_setkey(struct crypto_ahash *tfm, const u8 *key,if (err)return err; - shash->tfm = child_shash; - bs =crypto_shash_blocksize (child_shash); ds =crypto_shash_digestsize (child_shash);BUG_ON (ds >N2_HASH_KEY_MAX );if (keylen > bs) { - err =crypto_shash_digest (shash, key, keylen, - ctx->hash_key); + err =crypto_shash_tfm_digest (child_shash, key, keylen, + ctx->hash_key);if (err)return err; keylen = ds;
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 10/20 crypto: omap-sham - use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- drivers/crypto/omap-sham.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/crypto/omap-sham.c +4 -16
@@ -1245,16 +1245,6 @@ static int omap_sham_update(struct ahash_request *req)return omap_sham_enqueue (req,OP_UPDATE ); } -static int omap_sham_shash_digest (struct crypto_shash *tfm,u32 flags, -const u8 *data,unsigned int len,u8 *out) -{ -SHASH_DESC_ON_STACK (shash, tfm); - - shash->tfm = tfm; - -return crypto_shash_digest (shash, data, len, out); -} -static int omap_sham_final_shash (struct ahash_request *req) {struct omap_sham_ctx *tctx =crypto_tfm_ctx (req->base.tfm);
@@ -1270,9 +1260,8 @@ static int omap_sham_final_shash(struct ahash_request *req) !test_bit(FLAGS_AUTO_XOR, &ctx->dd->flags)) offset =get_block_size (ctx); -return omap_sham_shash_digest (tctx->fallback, req->base.flags, - ctx->buffer + offset, - ctx->bufcnt - offset, req->result); +return crypto_shash_tfm_digest (tctx->fallback, ctx->buffer + offset, + ctx->bufcnt - offset, req->result); }static int omap_sham_final (struct ahash_request *req)
@@ -1351,9 +1340,8 @@ static int omap_sham_setkey(struct crypto_ahash *tfm, const u8 *key,return err;if (keylen > bs) { - err =omap_sham_shash_digest (bctx->shash, -crypto_shash_get_flags (bctx->shash), - key, keylen, bctx->ipad); + err =crypto_shash_tfm_digest (bctx->shash, key, keylen, + bctx->ipad);if (err)return err; keylen = ds;
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 11/20 crypto: s5p-sss - use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- drivers/crypto/s5p-sss.c | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-)
drivers/crypto/s5p-sss.c +6 -33
@@ -1520,37 +1520,6 @@ static int s5p_hash_update(struct ahash_request *req)return s5p_hash_enqueue (req, true);/* HASH_OP_UPDATE */ } -/** -* s5p_hash_shash_digest() - calculate shash digest -* @tfm: crypto transformation -* @flags: tfm flags -* @data: input data -* @len: length of data -* @out: output buffer -*/ -static int s5p_hash_shash_digest (struct crypto_shash *tfm,u32 flags, -const u8 *data,unsigned int len,u8 *out) -{ -SHASH_DESC_ON_STACK (shash, tfm); - - shash->tfm = tfm; - -return crypto_shash_digest (shash, data, len, out); -} - -/** -* s5p_hash_final_shash() - calculate shash digest -* @req: AHASH request -*/ -static int s5p_hash_final_shash (struct ahash_request *req) -{ -struct s5p_hash_ctx *tctx =crypto_tfm_ctx (req->base.tfm); -struct s5p_hash_reqctx *ctx =ahash_request_ctx (req); - -return s5p_hash_shash_digest (tctx->fallback, req->base.flags, - ctx->buffer, ctx->bufcnt, req->result); -} -/** * s5p_hash_final() - close up hash and calculate digest * @req: AHASH request
@@ -1582,8 +1551,12 @@ static int s5p_hash_final(struct ahash_request *req)if (ctx->error)return -EINVAL ;/* uncompleted hash is not needed */ -if (!ctx->digcnt && ctx->bufcnt <BUFLEN ) -return s5p_hash_final_shash (req); +if (!ctx->digcnt && ctx->bufcnt <BUFLEN ) { +struct s5p_hash_ctx *tctx =crypto_tfm_ctx (req->base.tfm); + +return crypto_shash_tfm_digest (tctx->fallback, ctx->buffer, + ctx->bufcnt, req->result); + }return s5p_hash_enqueue (req, false);/* HASH_OP_FINAL */ }
Signature · 1 line
2.26.2
Re: [PATCH 11/20] crypto: s5p-sss - use crypto_shash_tfm_digest()
Quoted 6 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct
shash_desc' on the stack and callingcrypto_shash_digest(), switch to using the new helper functioncrypto_shash_tfm_digest()which does this for us.
Quoted 7 lines
Cc Krzysztof Kozlowski <[email protected]>Cc Vladimir Zapolskiy <[email protected]>Cc Kamil Konieczny <[email protected]>Signed-off-by Eric Biggers <[email protected]>--- drivers/crypto/s5p-sss.c | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-)
Best regards,
Krzysztof
Eric Biggers
maintainerPATCH 12/20 nfc: s3fwrn5: use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- drivers/nfc/s3fwrn5/firmware.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/nfc/s3fwrn5/firmware.c +1 -9
@@ -434,15 +434,7 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info) goto out; } - { -SHASH_DESC_ON_STACK (desc, tfm); - - desc->tfm = tfm; - - ret =crypto_shash_digest (desc, fw->image, image_size, - hash_data); -shash_desc_zero (desc); - } + ret =crypto_shash_tfm_digest (tfm, fw->image, image_size, hash_data);crypto_free_shash (tfm);if (ret) {
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 13/20 fscrypt: use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- fs/crypto/fname.c | 7 +------ fs/crypto/hkdf.c | 6 +----- 2 files changed, 2 insertions(+), 11 deletions(-)
fs/crypto/fname.c +1 -6
@@ -83,13 +83,8 @@ static int fscrypt_do_sha256(const u8 *data, unsigned int data_len, u8 *result) tfm = prev_tfm; } } - { -SHASH_DESC_ON_STACK (desc, tfm); - desc->tfm = tfm; - -return crypto_shash_digest (desc, data, data_len, result); - } +return crypto_shash_tfm_digest (tfm, data, data_len, result); }static inline bool fscrypt_is_dot_dotdot (const struct qstr *str)
fs/crypto/hkdf.c +1 -5
@@ -44,17 +44,13 @@ static int hkdf_extract(struct crypto_shash *hmac_tfm, const u8 *ikm, unsigned int ikmlen, u8 prk[HKDF_HASHLEN]) {static const u8 default_salt[HKDF_HASHLEN ]; -SHASH_DESC_ON_STACK (desc, hmac_tfm);int err; err =crypto_shash_setkey (hmac_tfm, default_salt,HKDF_HASHLEN );if (err)return err; - desc->tfm = hmac_tfm; - err =crypto_shash_digest (desc, ikm, ikmlen, prk); -shash_desc_zero (desc); -return err; +return crypto_shash_tfm_digest (hmac_tfm, ikm, ikmlen, prk); }/*
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 14/20 ecryptfs: use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- fs/ecryptfs/crypto.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
fs/ecryptfs/crypto.c +1 -16
@@ -48,18 +48,6 @@ void ecryptfs_from_hex(char *dst, char *src, int dst_size) } } -static int ecryptfs_hash_digest (struct crypto_shash *tfm, -char *src,int len,char *dst) -{ -SHASH_DESC_ON_STACK (desc, tfm); -int err; - - desc->tfm = tfm; - err =crypto_shash_digest (desc, src, len, dst); -shash_desc_zero (desc); -return err; -} -/** * ecryptfs_calculate_md5 - calculates the md5 of @src * @dst: Pointer to 16 bytes of allocated memory
@@ -74,11 +62,8 @@ static int ecryptfs_calculate_md5(char *dst,struct ecryptfs_crypt_stat *crypt_stat, char *src, int len) { - struct crypto_shash *tfm; -int rc =0 ; + int rc = crypto_shash_tfm_digest(crypt_stat->hash_tfm, src, len, dst); - tfm = crypt_stat->hash_tfm; - rc =ecryptfs_hash_digest (tfm, src, len, dst);if (rc) { printk(KERN_ERR "%s: Error computing crypto hash; rc = [%d]\n",
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 15/20 nfsd: use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- fs/nfsd/nfs4recover.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)
fs/nfsd/nfs4recover.c +6 -20
@@ -127,16 +127,8 @@ nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname) goto out; } - { -SHASH_DESC_ON_STACK (desc, tfm); - - desc->tfm = tfm; - - status =crypto_shash_digest (desc, clname->data, clname->len, - cksum.data); -shash_desc_zero (desc); - } - + status =crypto_shash_tfm_digest (tfm, clname->data, clname->len, + cksum.data);if (status) goto out;
@@ -1148,7 +1140,6 @@ nfsd4_cld_create_v2(struct nfs4_client *clp)struct crypto_shash *tfm = cn->cn_tfm;struct xdr_netobj cksum;char *principal =NULL ; -SHASH_DESC_ON_STACK (desc, tfm);/* Don't upcall if it's already stored */ if (test_bit (NFSD4_CLIENT_STABLE , &clp->cl_flags))
@@ -1170,16 +1161,14 @@ nfsd4_cld_create_v2(struct nfs4_client *clp)else if (clp->cl_cred.cr_principal) principal = clp->cl_cred.cr_principal;if (principal) { - desc->tfm = tfm; cksum.len =crypto_shash_digestsize (tfm); cksum.data =kmalloc (cksum.len,GFP_KERNEL );if (cksum.data ==NULL ) { ret = -ENOMEM ; goto out; } - ret =crypto_shash_digest (desc, principal,strlen (principal), - cksum.data); -shash_desc_zero (desc); + ret =crypto_shash_tfm_digest (tfm, principal,strlen (principal), + cksum.data);if (ret) {kfree (cksum.data); goto out;
@@ -1343,7 +1332,6 @@ nfsd4_cld_check_v2(struct nfs4_client *clp)struct crypto_shash *tfm = cn->cn_tfm;struct xdr_netobj cksum;char *principal =NULL ; -SHASH_DESC_ON_STACK (desc, tfm);/* did we already find that this client is stable? */ if (test_bit (NFSD4_CLIENT_STABLE , &clp->cl_flags))
@@ -1381,14 +1369,12 @@ nfsd4_cld_check_v2(struct nfs4_client *clp) principal = clp->cl_cred.cr_principal;if (principal ==NULL )return -ENOENT ; - desc->tfm = tfm; cksum.len =crypto_shash_digestsize (tfm); cksum.data =kmalloc (cksum.len,GFP_KERNEL );if (cksum.data ==NULL )return -ENOENT ; - status =crypto_shash_digest (desc, principal,strlen (principal), - cksum.data); -shash_desc_zero (desc); + status =crypto_shash_tfm_digest (tfm, principal, +strlen (principal), cksum.data);if (status) {kfree (cksum.data);return -ENOENT ;
Signature · 1 line
2.26.2
Re: [PATCH 15/20] nfsd: use crypto_shash_tfm_digest()
Quoted 8 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct
shash_desc' on the stack and callingcrypto_shash_digest(), switch to using the new helper functioncrypto_shash_tfm_digest()which does this for us.Signed-off-by Eric Biggers <[email protected]>
if you need it.
--b.
Quoted 81 lines
--- fs/nfsd/nfs4recover.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)fs/nfsd/nfs4recover.c +6
-20@@ -127,16 +127,8 @@ nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname) goto out; } - { -SHASH_DESC_ON_STACK (desc, tfm); - - desc->tfm = tfm; - - status =crypto_shash_digest (desc, clname->data, clname->len, - cksum.data); -shash_desc_zero (desc); - } - + status =crypto_shash_tfm_digest (tfm, clname->data, clname->len, + cksum.data);if (status) goto out;@@ -1148,7 +1140,6 @@ nfsd4_cld_create_v2(struct nfs4_client *clp)struct crypto_shash *tfm = cn->cn_tfm;struct xdr_netobj cksum;char *principal =NULL ; -SHASH_DESC_ON_STACK (desc, tfm);/* Don't upcall if it's already stored */ if (test_bit (NFSD4_CLIENT_STABLE , &clp->cl_flags))@@ -1170,16 +1161,14 @@ nfsd4_cld_create_v2(struct nfs4_client *clp)else if (clp->cl_cred.cr_principal) principal = clp->cl_cred.cr_principal;if (principal) { - desc->tfm = tfm; cksum.len =crypto_shash_digestsize (tfm); cksum.data =kmalloc (cksum.len,GFP_KERNEL );if (cksum.data ==NULL ) { ret = -ENOMEM ; goto out; } - ret =crypto_shash_digest (desc, principal,strlen (principal), - cksum.data); -shash_desc_zero (desc); + ret =crypto_shash_tfm_digest (tfm, principal,strlen (principal), + cksum.data);if (ret) {kfree (cksum.data); goto out;@@ -1343,7 +1332,6 @@ nfsd4_cld_check_v2(struct nfs4_client *clp)struct crypto_shash *tfm = cn->cn_tfm;struct xdr_netobj cksum;char *principal =NULL ; -SHASH_DESC_ON_STACK (desc, tfm);/* did we already find that this client is stable? */ if (test_bit (NFSD4_CLIENT_STABLE , &clp->cl_flags))@@ -1381,14 +1369,12 @@ nfsd4_cld_check_v2(struct nfs4_client *clp) principal = clp->cl_cred.cr_principal;if (principal ==NULL )return -ENOENT ; - desc->tfm = tfm; cksum.len =crypto_shash_digestsize (tfm); cksum.data =kmalloc (cksum.len,GFP_KERNEL );if (cksum.data ==NULL )return -ENOENT ; - status =crypto_shash_digest (desc, principal,strlen (principal), - cksum.data); -shash_desc_zero (desc); + status =crypto_shash_tfm_digest (tfm, principal, +strlen (principal), cksum.data);if (status) {kfree (cksum.data);return -ENOENT ;Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 16/20 ubifs: use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- fs/ubifs/auth.c | 20 +++----------------- fs/ubifs/master.c | 9 +++------ fs/ubifs/replay.c | 14 +++----------- 3 files changed, 9 insertions(+), 34 deletions(-)
fs/ubifs/auth.c +3 -17
@@ -31,15 +31,9 @@ int __ubifs_node_calc_hash(const struct ubifs_info *c, const void *node, u8 *hash) {const struct ubifs_ch *ch = node; -SHASH_DESC_ON_STACK (shash, c->hash_tfm); -int err; - - shash->tfm = c->hash_tfm; - err =crypto_shash_digest (shash, node,le32_to_cpu (ch->len), hash); -if (err <0 ) -return err; -return 0 ; +return crypto_shash_tfm_digest (c->hash_tfm, node,le32_to_cpu (ch->len), + hash); }/**
@@ -53,15 +47,7 @@ int __ubifs_node_calc_hash(const struct ubifs_info *c, const void *node,static int ubifs_hash_calc_hmac (const struct ubifs_info *c,const u8 *hash,u8 *hmac) { -SHASH_DESC_ON_STACK (shash, c->hmac_tfm); -int err; - - shash->tfm = c->hmac_tfm; - - err =crypto_shash_digest (shash, hash, c->hash_len, hmac); -if (err <0 ) -return err; -return 0 ; +return crypto_shash_tfm_digest (c->hmac_tfm, hash, c->hash_len, hmac); }/**
fs/ubifs/master.c +3 -6
@@ -68,12 +68,9 @@ static int mst_node_check_hash(const struct ubifs_info *c,u8 calc[UBIFS_MAX_HASH_LEN ];const void *node = mst; -SHASH_DESC_ON_STACK (shash, c->hash_tfm); - - shash->tfm = c->hash_tfm; - -crypto_shash_digest (shash, node +sizeof (struct ubifs_ch ), -UBIFS_MST_NODE_SZ -sizeof (struct ubifs_ch ), calc); +crypto_shash_tfm_digest (c->hash_tfm, node +sizeof (struct ubifs_ch ), +UBIFS_MST_NODE_SZ -sizeof (struct ubifs_ch ), + calc);if (ubifs_check_hash (c, expected, calc))return -EPERM ;
fs/ubifs/replay.c +3 -11
@@ -558,7 +558,7 @@ static int is_last_bud(struct ubifs_info *c, struct ubifs_bud *bud)return data ==0xFFFFFFFF ; } -/* authenticate_sleb_hash and authenticate_sleb_hmac are split out for stack usage */ +/* authenticate_sleb_hash is split out for stack usage */ static int authenticate_sleb_hash (struct ubifs_info *c,struct shash_desc *log_hash,u8 *hash) {SHASH_DESC_ON_STACK (hash_desc, c->hash_tfm);
@@ -569,15 +569,6 @@ static int authenticate_sleb_hash(struct ubifs_info *c, struct shash_desc *log_hreturn crypto_shash_final (hash_desc, hash); } -static int authenticate_sleb_hmac (struct ubifs_info *c,u8 *hash,u8 *hmac) -{ -SHASH_DESC_ON_STACK (hmac_desc, c->hmac_tfm); - - hmac_desc->tfm = c->hmac_tfm; - -return crypto_shash_digest (hmac_desc, hash, c->hash_len, hmac); -} -/** * authenticate_sleb - authenticate one scan LEB * @c: UBIFS file-system description object
@@ -624,7 +615,8 @@ static int authenticate_sleb(struct ubifs_info *c, struct ubifs_scan_leb *sleb,if (err) goto out; - err =authenticate_sleb_hmac (c, hash, hmac); + err =crypto_shash_tfm_digest (c->hmac_tfm, hash, + c->hash_len, hmac);if (err) goto out;
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 17/20 Bluetooth: use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- net/bluetooth/smp.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
net/bluetooth/smp.c +1 -5
@@ -170,7 +170,6 @@ static int aes_cmac(struct crypto_shash *tfm, const u8 k[16], const u8 *m, size_t len, u8 mac[16]) { uint8_t tmp[16], mac_msb[16], msg_msb[CMAC_MSG_MAX]; -SHASH_DESC_ON_STACK (desc, tfm);int err;if (len >CMAC_MSG_MAX )
@@ -181,8 +180,6 @@ static int aes_cmac(struct crypto_shash *tfm, const u8 k[16], const u8 *m,return -EINVAL ; } - desc->tfm = tfm; -/* Swap key and message from LSB to MSB */ swap_buf (k, tmp,16 );swap_buf (m, msg_msb, len);
@@ -196,8 +193,7 @@ static int aes_cmac(struct crypto_shash *tfm, const u8 k[16], const u8 *m,return err; } - err =crypto_shash_digest (desc, msg_msb, len, mac_msb); -shash_desc_zero (desc); + err =crypto_shash_tfm_digest (tfm, msg_msb, len, mac_msb);if (err) {BT_ERR ("Hash computation error %d" , err);return err;
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 18/20 sctp: use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- net/sctp/auth.c | 10 ++-------- net/sctp/sm_make_chunk.c | 23 ++++++++--------------- 2 files changed, 10 insertions(+), 23 deletions(-)
net/sctp/auth.c +2 -8
@@ -741,14 +741,8 @@ void sctp_auth_calculate_hmac(const struct sctp_association *asoc,if (crypto_shash_setkey (tfm, &asoc_key->data[0 ], asoc_key->len)) goto free; - { -SHASH_DESC_ON_STACK (desc, tfm); - - desc->tfm = tfm; -crypto_shash_digest (desc, (u8 *)auth, - end - (unsigned char *)auth, digest); -shash_desc_zero (desc); - } +crypto_shash_tfm_digest (tfm, (u8 *)auth, end - (unsigned char *)auth, + digest); free:if (free_key)
net/sctp/sm_make_chunk.c +8 -15
@@ -1666,17 +1666,14 @@ static struct sctp_cookie_param *sctp_pack_cookie( ntohs(init_chunk->chunk_hdr->length), raw_addrs, addrs_len);if (sctp_sk (ep->base.sk)->hmac) { -SHASH_DESC_ON_STACK (desc,sctp_sk (ep->base.sk)->hmac); +struct crypto_shash *tfm =sctp_sk (ep->base.sk)->hmac;int err;/* Sign the message. */ - desc->tfm =sctp_sk (ep->base.sk)->hmac; - - err =crypto_shash_setkey (desc->tfm, ep->secret_key, + err =crypto_shash_setkey (tfm, ep->secret_key,sizeof (ep->secret_key)) ?: -crypto_shash_digest (desc, (u8 *)&cookie->c, bodysize, - cookie->signature); -shash_desc_zero (desc); +crypto_shash_tfm_digest (tfm, (u8 *)&cookie->c, bodysize, + cookie->signature);if (err) goto free_cookie; }
@@ -1737,17 +1734,13 @@ struct sctp_association *sctp_unpack_cookie(/* Check the signature. */ { -SHASH_DESC_ON_STACK (desc,sctp_sk (ep->base.sk)->hmac); +struct crypto_shash *tfm =sctp_sk (ep->base.sk)->hmac;int err; - desc->tfm =sctp_sk (ep->base.sk)->hmac; - - err =crypto_shash_setkey (desc->tfm, ep->secret_key, + err =crypto_shash_setkey (tfm, ep->secret_key,sizeof (ep->secret_key)) ?: -crypto_shash_digest (desc, (u8 *)bear_cookie, bodysize, - digest); -shash_desc_zero (desc); - +crypto_shash_tfm_digest (tfm, (u8 *)bear_cookie, bodysize, + digest);if (err) { *error = -SCTP_IERROR_NOMEM ; goto fail;
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 19/20 KEYS: encrypted: use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- security/keys/encrypted-keys/encrypted.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
security/keys/encrypted-keys/encrypted.c +3 -15
@@ -323,19 +323,6 @@ static struct key *request_user_key(const char *master_desc, const u8 **master_kreturn ukey; } -static int calc_hash (struct crypto_shash *tfm,u8 *digest, -const u8 *buf,unsigned int buflen) -{ -SHASH_DESC_ON_STACK (desc, tfm); -int err; - - desc->tfm = tfm; - - err =crypto_shash_digest (desc, buf, buflen, digest); -shash_desc_zero (desc); -return err; -} -static int calc_hmac (u8 *digest,const u8 *key,unsigned int keylen,const u8 *buf,unsigned int buflen) {
@@ -351,7 +338,7 @@ static int calc_hmac(u8 *digest, const u8 *key, unsigned int keylen, err =crypto_shash_setkey (tfm, key, keylen);if (!err) - err =calc_hash (tfm, digest, buf, buflen); + err =crypto_shash_tfm_digest (tfm, buf, buflen, digest);crypto_free_shash (tfm);return err; }
@@ -381,7 +368,8 @@ static int get_derived_key(u8 *derived_key, enum derived_key_type key_type,memcpy (derived_buf +strlen (derived_buf) +1 , master_key, master_keylen); - ret =calc_hash (hash_tfm, derived_key, derived_buf, derived_buf_len); + ret =crypto_shash_tfm_digest (hash_tfm, derived_buf, derived_buf_len, + derived_key);kzfree (derived_buf);return ret; }
Signature · 1 line
2.26.2
Eric Biggers
maintainerPATCH 20/20 ASoC: cros_ec_codec: use crypto_shash_tfm_digest()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Instead of manually allocating a 'struct shash_desc' on the stack and calling crypto_shash_digest(), switch to using the new helper function crypto_shash_tfm_digest() which does this for us.
--- sound/soc/codecs/cros_ec_codec.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
sound/soc/codecs/cros_ec_codec.c +1 -8
@@ -115,14 +115,7 @@ static int calculate_sha256(struct cros_ec_codec_priv *priv,return PTR_ERR (tfm); } - { -SHASH_DESC_ON_STACK (desc, tfm); - - desc->tfm = tfm; - -crypto_shash_digest (desc, buf, size, digest); -shash_desc_zero (desc); - } +crypto_shash_tfm_digest (tfm, buf, size, digest);crypto_free_shash (tfm);
Signature · 1 line
2.26.2
Hi Eric,
Quoted 16 lines
This series introduces a helper function
crypto_shash_tfm_digest()which replaces the following common pattern:{ SHASH_DESC_ON_STACK(desc, tfm); int err; desc->tfm = tfm; err = crypto_shash_digest(desc, data, len, out); shash_desc_zero(desc); }with:
Quoted 8 lines
err = crypto_shash_tfm_digest(tfm, data, len, out);Patch 1 introduces this helper function, and patches 2-20 convert all relevant users to use it.
IMO, it would be easiest to take all these patches through the crypto tree. But taking just the "crypto:" ones and then me trying to get the rest merged later via subsystem trees is also an option.
I am fine if you take the net/bluetooth/smp.c change through the crypto tree.
Regards
Marcel
Quoted 39 lines · Eric Biggers
This series introduces a helper function
crypto_shash_tfm_digest()which replaces the following common pattern:{ SHASH_DESC_ON_STACK(desc, tfm); int err; desc->tfm = tfm; err = crypto_shash_digest(desc, data, len, out); shash_desc_zero(desc); }with:
err = crypto_shash_tfm_digest(tfm, data, len, out);Patch 1 introduces this helper function, and patches 2-20 convert all relevant users to use it.
IMO, it would be easiest to take all these patches through the crypto tree. But taking just the "crypto:" ones and then me trying to get the rest merged later via subsystem trees is also an option.
Eric Biggers (20):
crypto: hash - introducecrypto_shash_tfm_digest()
crypto: arm64/aes-glue - usecrypto_shash_tfm_digest()
crypto: essiv - usecrypto_shash_tfm_digest()
crypto: artpec6 - usecrypto_shash_tfm_digest()
crypto: ccp - usecrypto_shash_tfm_digest()
crypto: ccree - usecrypto_shash_tfm_digest()
crypto: hisilicon/sec2 - usecrypto_shash_tfm_digest()
crypto: mediatek - usecrypto_shash_tfm_digest()
crypto: n2 - usecrypto_shash_tfm_digest()
crypto: omap-sham - usecrypto_shash_tfm_digest()
crypto: s5p-sss - usecrypto_shash_tfm_digest()
nfc: s3fwrn5: usecrypto_shash_tfm_digest()
Quoted 9 lines
fscrypt: use
crypto_shash_tfm_digest()
ecryptfs: usecrypto_shash_tfm_digest()
nfsd: usecrypto_shash_tfm_digest()
ubifs: usecrypto_shash_tfm_digest()
Bluetooth: usecrypto_shash_tfm_digest()
sctp: usecrypto_shash_tfm_digest()
KEYS: encrypted: usecrypto_shash_tfm_digest()
ASoC:cros_ec_codec: usecrypto_shash_tfm_digest()
For the series,
Quoted 30 lines
arch/arm64/crypto/aes-glue.c | 4 +-- crypto/essiv.c | 4 +-- crypto/shash.c | 16 +++++++++ drivers/crypto/axis/artpec6_crypto.c | 10 ++---- drivers/crypto/ccp/ccp-crypto-sha.c | 9 ++--- drivers/crypto/ccree/cc_cipher.c | 9 ++--- drivers/crypto/hisilicon/sec2/sec_crypto.c | 5 ++- drivers/crypto/mediatek/mtk-sha.c | 7 ++-- drivers/crypto/n2_core.c | 7 ++-- drivers/crypto/omap-sham.c | 20 +++-------- drivers/crypto/s5p-sss.c | 39 ++++------------------ drivers/nfc/s3fwrn5/firmware.c | 10 +----- fs/crypto/fname.c | 7 +--- fs/crypto/hkdf.c | 6 +--- fs/ecryptfs/crypto.c | 17 +--------- fs/nfsd/nfs4recover.c | 26 ++++----------- fs/ubifs/auth.c | 20 ++--------- fs/ubifs/master.c | 9 ++--- fs/ubifs/replay.c | 14 ++------ include/crypto/hash.h | 19 +++++++++++ net/bluetooth/smp.c | 6 +--- net/sctp/auth.c | 10 ++---- net/sctp/sm_make_chunk.c | 23 +++++-------- security/keys/encrypted-keys/encrypted.c | 18 ++-------- sound/soc/codecs/cros_ec_codec.c | 9 +---- 25 files changed, 95 insertions(+), 229 deletions(-)--
2.26.2
Herbert Xu
maintainerQuoted 65 lines · Eric Biggers
This series introduces a helper function
crypto_shash_tfm_digest()which replaces the following common pattern:{ SHASH_DESC_ON_STACK(desc, tfm); int err; desc->tfm = tfm; err = crypto_shash_digest(desc, data, len, out); shash_desc_zero(desc); }with:
err = crypto_shash_tfm_digest(tfm, data, len, out);Patch 1 introduces this helper function, and patches 2-20 convert all relevant users to use it.
IMO, it would be easiest to take all these patches through the crypto tree. But taking just the "crypto:" ones and then me trying to get the rest merged later via subsystem trees is also an option.
Eric Biggers (20):
crypto: hash - introducecrypto_shash_tfm_digest()
crypto: arm64/aes-glue - usecrypto_shash_tfm_digest()
crypto: essiv - usecrypto_shash_tfm_digest()
crypto: artpec6 - usecrypto_shash_tfm_digest()
crypto: ccp - usecrypto_shash_tfm_digest()
crypto: ccree - usecrypto_shash_tfm_digest()
crypto: hisilicon/sec2 - usecrypto_shash_tfm_digest()
crypto: mediatek - usecrypto_shash_tfm_digest()
crypto: n2 - usecrypto_shash_tfm_digest()
crypto: omap-sham - usecrypto_shash_tfm_digest()
crypto: s5p-sss - usecrypto_shash_tfm_digest()
nfc: s3fwrn5: usecrypto_shash_tfm_digest()
fscrypt: usecrypto_shash_tfm_digest()
ecryptfs: usecrypto_shash_tfm_digest()
nfsd: usecrypto_shash_tfm_digest()
ubifs: usecrypto_shash_tfm_digest()
Bluetooth: usecrypto_shash_tfm_digest()
sctp: usecrypto_shash_tfm_digest()
KEYS: encrypted: usecrypto_shash_tfm_digest()
ASoC:cros_ec_codec: usecrypto_shash_tfm_digest()arch/arm64/crypto/aes-glue.c | 4 +-- crypto/essiv.c | 4 +-- crypto/shash.c | 16 +++++++++ drivers/crypto/axis/artpec6_crypto.c | 10 ++---- drivers/crypto/ccp/ccp-crypto-sha.c | 9 ++--- drivers/crypto/ccree/cc_cipher.c | 9 ++--- drivers/crypto/hisilicon/sec2/sec_crypto.c | 5 ++- drivers/crypto/mediatek/mtk-sha.c | 7 ++-- drivers/crypto/n2_core.c | 7 ++-- drivers/crypto/omap-sham.c | 20 +++-------- drivers/crypto/s5p-sss.c | 39 ++++------------------ drivers/nfc/s3fwrn5/firmware.c | 10 +----- fs/crypto/fname.c | 7 +--- fs/crypto/hkdf.c | 6 +--- fs/ecryptfs/crypto.c | 17 +--------- fs/nfsd/nfs4recover.c | 26 ++++----------- fs/ubifs/auth.c | 20 ++--------- fs/ubifs/master.c | 9 ++---
Quoted 8 lines
fs/ubifs/replay.c | 14 ++------ include/crypto/hash.h | 19 +++++++++++ net/bluetooth/smp.c | 6 +--- net/sctp/auth.c | 10 ++---- net/sctp/sm_make_chunk.c | 23 +++++-------- security/keys/encrypted-keys/encrypted.c | 18 ++-------- sound/soc/codecs/cros_ec_codec.c | 9 +---- 25 files changed, 95 insertions(+), 229 deletions(-)
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