Commit c78c3376 authored by Wang, Rui Y's avatar Wang, Rui Y Committed by Greg Kroah-Hartman

crypto: ghash-clmulni - Fix load failure

commit 3a020a72 upstream.

ghash_clmulni_intel fails to load on Linux 4.3+ with the following message:
"modprobe: ERROR: could not insert 'ghash_clmulni_intel': Invalid argument"

After 8996eafd ("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.
Signed-off-by: default avatarRui Wang <rui.y.wang@intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 45d95588
...@@ -219,6 +219,29 @@ static int ghash_async_final(struct ahash_request *req) ...@@ -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) static int ghash_async_digest(struct ahash_request *req)
{ {
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
...@@ -288,8 +311,11 @@ static struct ahash_alg ghash_async_alg = { ...@@ -288,8 +311,11 @@ static struct ahash_alg ghash_async_alg = {
.final = ghash_async_final, .final = ghash_async_final,
.setkey = ghash_async_setkey, .setkey = ghash_async_setkey,
.digest = ghash_async_digest, .digest = ghash_async_digest,
.export = ghash_async_export,
.import = ghash_async_import,
.halg = { .halg = {
.digestsize = GHASH_DIGEST_SIZE, .digestsize = GHASH_DIGEST_SIZE,
.statesize = sizeof(struct ghash_desc_ctx),
.base = { .base = {
.cra_name = "ghash", .cra_name = "ghash",
.cra_driver_name = "ghash-clmulni", .cra_driver_name = "ghash-clmulni",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment