aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2010-01-31 17:17:56 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2010-02-01 14:50:25 -0500
commita8d7ac279743077965afeca0c9ed748507b68e89 (patch)
treed5bf192117944ba3c461fcd586c470c0713f3191 /drivers/crypto
parenta996996dd75a9086b12d1cb4010f26e1748993f0 (diff)
crypto: padlock-sha - Add import/export support
As the padlock driver for SHA uses a software fallback to perform partial hashing, it must implement custom import/export functions. Otherwise hmac which depends on import/export for prehashing will not work with padlock-sha. Reported-by: Wolfgang Walter <wolfgang.walter@stwm.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/padlock-sha.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/crypto/padlock-sha.c b/drivers/crypto/padlock-sha.c
index 0af80577dc7b..d3a27e0119bc 100644
--- a/drivers/crypto/padlock-sha.c
+++ b/drivers/crypto/padlock-sha.c
@@ -57,6 +57,23 @@ static int padlock_sha_update(struct shash_desc *desc,
57 return crypto_shash_update(&dctx->fallback, data, length); 57 return crypto_shash_update(&dctx->fallback, data, length);
58} 58}
59 59
60static int padlock_sha_export(struct shash_desc *desc, void *out)
61{
62 struct padlock_sha_desc *dctx = shash_desc_ctx(desc);
63
64 return crypto_shash_export(&dctx->fallback, out);
65}
66
67static int padlock_sha_import(struct shash_desc *desc, const void *in)
68{
69 struct padlock_sha_desc *dctx = shash_desc_ctx(desc);
70 struct padlock_sha_ctx *ctx = crypto_shash_ctx(desc->tfm);
71
72 dctx->fallback.tfm = ctx->fallback;
73 dctx->fallback.flags = desc->flags & CRYPTO_TFM_REQ_MAY_SLEEP;
74 return crypto_shash_import(&dctx->fallback, in);
75}
76
60static inline void padlock_output_block(uint32_t *src, 77static inline void padlock_output_block(uint32_t *src,
61 uint32_t *dst, size_t count) 78 uint32_t *dst, size_t count)
62{ 79{
@@ -235,7 +252,10 @@ static struct shash_alg sha1_alg = {
235 .update = padlock_sha_update, 252 .update = padlock_sha_update,
236 .finup = padlock_sha1_finup, 253 .finup = padlock_sha1_finup,
237 .final = padlock_sha1_final, 254 .final = padlock_sha1_final,
255 .export = padlock_sha_export,
256 .import = padlock_sha_import,
238 .descsize = sizeof(struct padlock_sha_desc), 257 .descsize = sizeof(struct padlock_sha_desc),
258 .statesize = sizeof(struct sha1_state),
239 .base = { 259 .base = {
240 .cra_name = "sha1", 260 .cra_name = "sha1",
241 .cra_driver_name = "sha1-padlock", 261 .cra_driver_name = "sha1-padlock",
@@ -256,7 +276,10 @@ static struct shash_alg sha256_alg = {
256 .update = padlock_sha_update, 276 .update = padlock_sha_update,
257 .finup = padlock_sha256_finup, 277 .finup = padlock_sha256_finup,
258 .final = padlock_sha256_final, 278 .final = padlock_sha256_final,
279 .export = padlock_sha_export,
280 .import = padlock_sha_import,
259 .descsize = sizeof(struct padlock_sha_desc), 281 .descsize = sizeof(struct padlock_sha_desc),
282 .statesize = sizeof(struct sha256_state),
260 .base = { 283 .base = {
261 .cra_name = "sha256", 284 .cra_name = "sha256",
262 .cra_driver_name = "sha256-padlock", 285 .cra_driver_name = "sha256-padlock",