aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-07-12 09:25:20 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2009-07-14 00:58:08 -0400
commit7eddf95ec5440d60f10963f453e27f82f394044e (patch)
tree4b1ba4bbf01f381a45d5bd6d26811f51ab81a3ff /crypto
parent6941c3a0aabb6ad4167827360f384e9daed7dd7f (diff)
crypto: shash - Export async functions
This patch exports the async functions so that they can be reused by cryptd when it switches over to using shash. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/shash.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/crypto/shash.c b/crypto/shash.c
index d8e0f8f8d672..3b1b06b3dcf3 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -202,9 +202,8 @@ static int shash_async_init(struct ahash_request *req)
202 return crypto_shash_init(desc); 202 return crypto_shash_init(desc);
203} 203}
204 204
205static int shash_async_update(struct ahash_request *req) 205int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc)
206{ 206{
207 struct shash_desc *desc = ahash_request_ctx(req);
208 struct crypto_hash_walk walk; 207 struct crypto_hash_walk walk;
209 int nbytes; 208 int nbytes;
210 209
@@ -214,13 +213,19 @@ static int shash_async_update(struct ahash_request *req)
214 213
215 return nbytes; 214 return nbytes;
216} 215}
216EXPORT_SYMBOL_GPL(shash_ahash_update);
217
218static int shash_async_update(struct ahash_request *req)
219{
220 return shash_ahash_update(req, ahash_request_ctx(req));
221}
217 222
218static int shash_async_final(struct ahash_request *req) 223static int shash_async_final(struct ahash_request *req)
219{ 224{
220 return crypto_shash_final(ahash_request_ctx(req), req->result); 225 return crypto_shash_final(ahash_request_ctx(req), req->result);
221} 226}
222 227
223static int shash_async_digest(struct ahash_request *req) 228int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc)
224{ 229{
225 struct scatterlist *sg = req->src; 230 struct scatterlist *sg = req->src;
226 unsigned int offset = sg->offset; 231 unsigned int offset = sg->offset;
@@ -228,34 +233,31 @@ static int shash_async_digest(struct ahash_request *req)
228 int err; 233 int err;
229 234
230 if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) { 235 if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) {
231 struct crypto_shash **ctx =
232 crypto_ahash_ctx(crypto_ahash_reqtfm(req));
233 struct shash_desc *desc = ahash_request_ctx(req);
234 void *data; 236 void *data;
235 237
236 desc->tfm = *ctx;
237 desc->flags = req->base.flags;
238
239 data = crypto_kmap(sg_page(sg), 0); 238 data = crypto_kmap(sg_page(sg), 0);
240 err = crypto_shash_digest(desc, data + offset, nbytes, 239 err = crypto_shash_digest(desc, data + offset, nbytes,
241 req->result); 240 req->result);
242 crypto_kunmap(data, 0); 241 crypto_kunmap(data, 0);
243 crypto_yield(desc->flags); 242 crypto_yield(desc->flags);
244 goto out; 243 } else
245 } 244 err = crypto_shash_init(desc) ?:
245 shash_ahash_update(req, desc) ?:
246 crypto_shash_final(desc, req->result);
246 247
247 err = shash_async_init(req); 248 return err;
248 if (err) 249}
249 goto out; 250EXPORT_SYMBOL_GPL(shash_ahash_digest);
250 251
251 err = shash_async_update(req); 252static int shash_async_digest(struct ahash_request *req)
252 if (err) 253{
253 goto out; 254 struct crypto_shash **ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
255 struct shash_desc *desc = ahash_request_ctx(req);
254 256
255 err = shash_async_final(req); 257 desc->tfm = *ctx;
258 desc->flags = req->base.flags;
256 259
257out: 260 return shash_ahash_digest(req, desc);
258 return err;
259} 261}
260 262
261static void crypto_exit_shash_ops_async(struct crypto_tfm *tfm) 263static void crypto_exit_shash_ops_async(struct crypto_tfm *tfm)