summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-07-09 20:30:57 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2009-07-11 18:23:32 +0800
commitda057835dd53d0e7b8f0db3ab4d1a2f487ca90cc (patch)
treeedbe7e05373df1a11773a5c2e0d07648a34cd4f8
parentd0bb12bd15294af5acaff3c34bd1a9144a8cc93f (diff)
downloadlinux-crypto-da057835dd53d0e7b8f0db3ab4d1a2f487ca90cc.tar.gz
linux-crypto-da057835dd53d0e7b8f0db3ab4d1a2f487ca90cc.zip
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 '')
-rw-r--r--crypto/shash.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/crypto/shash.c b/crypto/shash.c
index 23e05a1e..14a3b707 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -172,19 +172,15 @@ int crypto_shash_digest(struct shash_desc *desc, const u8 *data,
}
EXPORT_SYMBOL_GPL(crypto_shash_digest);
-int crypto_shash_import(struct shash_desc *desc, const u8 *in)
+static int shash_no_export(struct shash_desc *desc, void *out)
{
- struct crypto_shash *tfm = desc->tfm;
- struct shash_alg *alg = crypto_shash_alg(tfm);
-
- memcpy(shash_desc_ctx(desc), in, crypto_shash_descsize(tfm));
-
- if (alg->reinit)
- return alg->reinit(desc);
+ return -ENOSYS;
+}
- return 0;
+static int shash_no_import(struct shash_desc *desc, const void *in)
+{
+ return -ENOSYS;
}
-EXPORT_SYMBOL_GPL(crypto_shash_import);
static int shash_async_setkey(struct crypto_ahash *tfm, const u8 *key,
unsigned int keylen)
@@ -484,12 +480,19 @@ static int shash_prepare_alg(struct shash_alg *alg)
struct crypto_alg *base = &alg->base;
if (alg->digestsize > PAGE_SIZE / 8 ||
- alg->descsize > PAGE_SIZE / 8)
+ alg->descsize > PAGE_SIZE / 8 ||
+ alg->statesize > PAGE_SIZE / 8)
return -EINVAL;
base->cra_type = &crypto_shash_type;
base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
base->cra_flags |= CRYPTO_ALG_TYPE_SHASH;
+
+ if (!alg->import)
+ alg->import = shash_no_import;
+ if (!alg->export)
+ alg->export = shash_no_export;
+
return 0;
}