aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/shash.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-07-09 08:30:57 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2009-07-11 06:23:32 -0400
commit99d27e1c59e34869605de625b033c52163f5bfa7 (patch)
treed7e6477e8a61630fc23088e795730a7fcda60873 /crypto/shash.c
parent7ede5a5ba55a696a6e1d8456526e44635e966a81 (diff)
crypto: shash - Export/import hash state only
This patch replaces the full descriptor export with an export of the partial hash state. This allows the use of a consistent export format across all implementations of a given algorithm. This is useful because a number of cases require the use of the partial hash state, e.g., PadLock can use the SHA1 hash state to get around the fact that it can only hash contiguous data chunks. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/shash.c')
-rw-r--r--crypto/shash.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/crypto/shash.c b/crypto/shash.c
index 23e05a1e9038..14a3b707a31f 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -172,19 +172,15 @@ int crypto_shash_digest(struct shash_desc *desc, const u8 *data,
172} 172}
173EXPORT_SYMBOL_GPL(crypto_shash_digest); 173EXPORT_SYMBOL_GPL(crypto_shash_digest);
174 174
175int crypto_shash_import(struct shash_desc *desc, const u8 *in) 175static int shash_no_export(struct shash_desc *desc, void *out)
176{ 176{
177 struct crypto_shash *tfm = desc->tfm; 177 return -ENOSYS;
178 struct shash_alg *alg = crypto_shash_alg(tfm); 178}
179
180 memcpy(shash_desc_ctx(desc), in, crypto_shash_descsize(tfm));
181
182 if (alg->reinit)
183 return alg->reinit(desc);
184 179
185 return 0; 180static int shash_no_import(struct shash_desc *desc, const void *in)
181{
182 return -ENOSYS;
186} 183}
187EXPORT_SYMBOL_GPL(crypto_shash_import);
188 184
189static int shash_async_setkey(struct crypto_ahash *tfm, const u8 *key, 185static int shash_async_setkey(struct crypto_ahash *tfm, const u8 *key,
190 unsigned int keylen) 186 unsigned int keylen)
@@ -484,12 +480,19 @@ static int shash_prepare_alg(struct shash_alg *alg)
484 struct crypto_alg *base = &alg->base; 480 struct crypto_alg *base = &alg->base;
485 481
486 if (alg->digestsize > PAGE_SIZE / 8 || 482 if (alg->digestsize > PAGE_SIZE / 8 ||
487 alg->descsize > PAGE_SIZE / 8) 483 alg->descsize > PAGE_SIZE / 8 ||
484 alg->statesize > PAGE_SIZE / 8)
488 return -EINVAL; 485 return -EINVAL;
489 486
490 base->cra_type = &crypto_shash_type; 487 base->cra_type = &crypto_shash_type;
491 base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK; 488 base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
492 base->cra_flags |= CRYPTO_ALG_TYPE_SHASH; 489 base->cra_flags |= CRYPTO_ALG_TYPE_SHASH;
490
491 if (!alg->import)
492 alg->import = shash_no_import;
493 if (!alg->export)
494 alg->export = shash_no_export;
495
493 return 0; 496 return 0;
494} 497}
495 498