diff options
author | Wang, Rui Y <rui.y.wang@intel.com> | 2015-11-29 09:45:33 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-12-04 09:29:53 -0500 |
commit | 3a020a723c65eb8ffa7c237faca26521a024e582 (patch) | |
tree | db88bd0dd0b1fa2d2b02ed7e4dfb0c74ae05ab25 /arch | |
parent | ac7c8e6b6dc959d285382c7e9cdfe608205f0c68 (diff) |
crypto: ghash-clmulni - Fix 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"
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.
Signed-off-by: Rui Wang <rui.y.wang@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/crypto/ghash-clmulni-intel_glue.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/arch/x86/crypto/ghash-clmulni-intel_glue.c b/arch/x86/crypto/ghash-clmulni-intel_glue.c index 440df0c7a2ee..a69321a77783 100644 --- a/arch/x86/crypto/ghash-clmulni-intel_glue.c +++ b/arch/x86/crypto/ghash-clmulni-intel_glue.c | |||
@@ -219,6 +219,29 @@ static int ghash_async_final(struct ahash_request *req) | |||
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 | ||
222 | static int ghash_async_import(struct ahash_request *req, const void *in) | ||
223 | { | ||
224 | struct ahash_request *cryptd_req = ahash_request_ctx(req); | ||
225 | struct shash_desc *desc = cryptd_shash_desc(cryptd_req); | ||
226 | struct ghash_desc_ctx *dctx = shash_desc_ctx(desc); | ||
227 | |||
228 | ghash_async_init(req); | ||
229 | memcpy(dctx, in, sizeof(*dctx)); | ||
230 | return 0; | ||
231 | |||
232 | } | ||
233 | |||
234 | static int ghash_async_export(struct ahash_request *req, void *out) | ||
235 | { | ||
236 | struct ahash_request *cryptd_req = ahash_request_ctx(req); | ||
237 | struct shash_desc *desc = cryptd_shash_desc(cryptd_req); | ||
238 | struct ghash_desc_ctx *dctx = shash_desc_ctx(desc); | ||
239 | |||
240 | memcpy(out, dctx, sizeof(*dctx)); | ||
241 | return 0; | ||
242 | |||
243 | } | ||
244 | |||
222 | static int ghash_async_digest(struct ahash_request *req) | 245 | static int ghash_async_digest(struct ahash_request *req) |
223 | { | 246 | { |
224 | struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); | 247 | struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); |
@@ -288,8 +311,11 @@ static struct ahash_alg ghash_async_alg = { | |||
288 | .final = ghash_async_final, | 311 | .final = ghash_async_final, |
289 | .setkey = ghash_async_setkey, | 312 | .setkey = ghash_async_setkey, |
290 | .digest = ghash_async_digest, | 313 | .digest = ghash_async_digest, |
314 | .export = ghash_async_export, | ||
315 | .import = ghash_async_import, | ||
291 | .halg = { | 316 | .halg = { |
292 | .digestsize = GHASH_DIGEST_SIZE, | 317 | .digestsize = GHASH_DIGEST_SIZE, |
318 | .statesize = sizeof(struct ghash_desc_ctx), | ||
293 | .base = { | 319 | .base = { |
294 | .cra_name = "ghash", | 320 | .cra_name = "ghash", |
295 | .cra_driver_name = "ghash-clmulni", | 321 | .cra_driver_name = "ghash-clmulni", |