Skip to contentSkip to conversation

crypto: sahara: Fill the statesize field

PATCH In review Fabio Estevam 2 participants 4 messages Jan 13, 2016 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: sahara: Fill the statesize field

From: Fabio Estevam <[email protected]>

Currently the sahara driver fails to probe:

sahara: probe of 63ff8000.crypto failed with error -22

This happens since commit 8996eafdcbad ("crypto: ahash - ensure statesize is non-zero"), which requires statesize to be filled.

Pass the statesize members for sha1 and sha256, so we can probe the driver successfully again.

---
Hi Steffen,

Only 'probe' tested. Haven't run any crypto operations yet.

 drivers/crypto/sahara.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/crypto/sahara.c +2 -0
index f68c24a..d05d849 100644
@@ -1260,6 +1260,7 @@ static struct ahash_alg sha_v3_algs[] = {
 	.export		= sahara_sha_export,
 	.import		= sahara_sha_import,
 	.halg.digestsize	= SHA1_DIGEST_SIZE,
+	.halg.statesize		= sizeof(struct sahara_ctx),
 	.halg.base	= {
 		.cra_name		= "sha1",
 		.cra_driver_name	= "sahara-sha1",
@@ -1287,6 +1288,7 @@ static struct ahash_alg sha_v4_algs[] = {
 	.export		= sahara_sha_export,
 	.import		= sahara_sha_import,
 	.halg.digestsize	= SHA256_DIGEST_SIZE,
+	.halg.statesize		= sizeof(struct sahara_ctx),
 	.halg.base	= {
 		.cra_name		= "sha256",
 		.cra_driver_name	= "sahara-sha256",
Signature · 1 line
1.9.1
#1 lore raw

drivers/crypto/sahara.c static struct ahash_alg sha_v3_algs[] = { · line 1263

Quoted 9 lines · Fabio Estevam
drivers/crypto/sahara.c +1 -0
index f68c24a..d05d849 100644
@@ -1260,6 +1260,7 @@ static struct ahash_alg sha_v3_algs[] = {
        .export         = sahara_sha_export,
        .import         = sahara_sha_import,
        .halg.digestsize        = SHA1_DIGEST_SIZE,
+       .halg.statesize         = sizeof(struct sahara_ctx),

Or should this be sizeof(struct sha1_state) instead?

drivers/crypto/sahara.c static struct ahash_alg sha_v4_algs[] = { · line 1291

Quoted 8 lines
drivers/crypto/sahara.c +1 -0
        .halg.base      = {
                .cra_name               = "sha1",
                .cra_driver_name        = "sahara-sha1",
@@ -1287,6 +1288,7 @@ static struct ahash_alg sha_v4_algs[] = {
        .export         = sahara_sha_export,
        .import         = sahara_sha_import,
        .halg.digestsize        = SHA256_DIGEST_SIZE,
+       .halg.statesize         = sizeof(struct sahara_ctx),

Or should this be sizeof(struct sha256_state) instead?

Thanks

#2 lore raw
Quoted 13 lines · Fabio Estevam

drivers/crypto/sahara.c static struct ahash_alg sha_v3_algs[] = { · line 1263

Quoted 9 lines · Fabio Estevam
drivers/crypto/sahara.c +1 -0
index f68c24a..d05d849 100644
@@ -1260,6 +1260,7 @@ static struct ahash_alg sha_v3_algs[] = {
        .export         = sahara_sha_export,
        .import         = sahara_sha_import,
        .halg.digestsize        = SHA1_DIGEST_SIZE,
+       .halg.statesize         = sizeof(struct sahara_ctx),

Or should this be sizeof(struct sha1_state) instead?

It should actually be the size of the data that your import and export routines copy. Looking at those it should be sizeof(struct sahara_ctx) + sizeof(struct sahara_sha_reqctx).

Should the struct sahara_ctx be part of the import and export data, though?

Tom

Quoted 18 lines

drivers/crypto/sahara.c static struct ahash_alg sha_v4_algs[] = { · line 1291

Quoted 9 lines
drivers/crypto/sahara.c +1 -0
        .halg.base      = {
                .cra_name               = "sha1",
                .cra_driver_name        = "sahara-sha1",
@@ -1287,6 +1288,7 @@ static struct ahash_alg sha_v4_algs[] = {
        .export         = sahara_sha_export,
        .import         = sahara_sha_import,
        .halg.digestsize        = SHA256_DIGEST_SIZE,
+       .halg.statesize         = sizeof(struct sahara_ctx),

Or should this be sizeof(struct sha256_state) instead?

Thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 6 lines · Tom Lendacky

It should actually be the size of the data that your import and export routines copy. Looking at those it should be sizeof(struct sahara_ctx) + sizeof(struct sahara_sha_reqctx).

Should the struct sahara_ctx be part of the import and export data, though?

Thanks, Tom. Will send a v2.