crypto: Fix driver load failure
Subsystems (2)
PATCH 1/2 crypto: ghash-clmulni - Fix load failure
In reply to Rui Wangghash_clmulni_intel fails to load on Linux 4.3+ with the following message:
"modprobe: ERROR: could not insert 'ghash_clmulni_intel': Invalid argument"
After 8996eafdc ("crypto: ahash - ensure statesize is non-zero") all ahash drivers are required to implement import()/export(), and must have a non- zero statesize.
This patch has been tested with the algif_hash interface. The calculated digest values, after several rounds of import()s and export()s, match those calculated by tcrypt.
--- arch/x86/crypto/ghash-clmulni-intel_glue.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
arch/x86/crypto/ghash-clmulni-intel_glue.c +26 -0
@@ -219,6 +219,29 @@ static int ghash_async_final(struct ahash_request *req) } } +static int ghash_async_import (struct ahash_request *req,const void *in) +{ +struct ahash_request *cryptd_req =ahash_request_ctx (req); +struct shash_desc *desc =cryptd_shash_desc (cryptd_req); +struct ghash_desc_ctx *dctx =shash_desc_ctx (desc); + +ghash_async_init (req); +memcpy (dctx, in,sizeof (*dctx)); +return 0 ; + +} + +static int ghash_async_export (struct ahash_request *req,void *out) +{ +struct ahash_request *cryptd_req =ahash_request_ctx (req); +struct shash_desc *desc =cryptd_shash_desc (cryptd_req); +struct ghash_desc_ctx *dctx =shash_desc_ctx (desc); + +memcpy (out, dctx,sizeof (*dctx)); +return 0 ; + +} +static int ghash_async_digest (struct ahash_request *req) {struct crypto_ahash *tfm =crypto_ahash_reqtfm (req);
@@ -288,8 +311,11 @@ static struct ahash_alg ghash_async_alg = { .final = ghash_async_final, .setkey = ghash_async_setkey, .digest = ghash_async_digest, + .export = ghash_async_export, + .import = ghash_async_import, .halg = { .digestsize = GHASH_DIGEST_SIZE, + .statesize = sizeof(struct ghash_desc_ctx), .base = { .cra_name = "ghash", .cra_driver_name = "ghash-clmulni",
Signature · 1 line
1.8.5.2
PATCH 2/2 crypto: cryptd - Assign statesize properly
In reply to Rui Wangcryptd_create_hash() fails by returning -EINVAL. It is because after 8996eafdc ("crypto: ahash - ensure statesize is non-zero") all ahash drivers must have a non-zero statesize.
This patch fixes the problem by properly assigning the statesize.
--- crypto/cryptd.c | 1 + 1 file changed, 1 insertion(+)
crypto/cryptd.c +1 -0
@@ -637,6 +637,7 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb, inst->alg.halg.base.cra_flags = type; inst->alg.halg.digestsize = salg->digestsize; + inst->alg.halg.statesize = salg->statesize; inst->alg.halg.base.cra_ctxsize =sizeof (struct cryptd_hash_ctx ); inst->alg.halg.base.cra_init = cryptd_hash_init_tfm;
Signature · 1 line
1.8.5.2
cover crypto: Fix driver load failure
ghash_clmulni_intel fails to load on Linux 4.3+ with the following message:
"modprobe: ERROR: could not insert 'ghash_clmulni_intel': Invalid argument"
These two patches need to go together, for the driver to load correctly.
Rui Wang (2):
crypto: ghash-clmulni - Fix load failure
crypto: cryptd - Assign statesize properly
arch/x86/crypto/ghash-clmulni-intel_glue.c | 26 ++++++++++++++++++++++++++ crypto/cryptd.c | 1 + 2 files changed, 27 insertions(+)
Signature · 1 line
1.8.5.2
Herbert Xu
maintainerQuoted 8 lines · Rui Wang
ghash_clmulni_intelfails to load on Linux 4.3+ with the following message:
"modprobe: ERROR: could not insert 'ghash_clmulni_intel': Invalid argument"These two patches need to go together, for the driver to load correctly.
Rui Wang (2):
crypto: ghash-clmulni - Fix load failure
crypto: cryptd - Assign statesize properly
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