aboutsummaryrefslogtreecommitdiffstats
path: root/include/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-07-15 00:40:40 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2009-07-15 00:40:40 -0400
commit66f6ce5e52f2f209d5bf1f06167cec888f4f4c13 (patch)
treeaa7b21af00649d2f458b72ebfba071816cb340c3 /include/crypto
parent093900c2b964da73daf234374225b5ce5d49f941 (diff)
crypto: ahash - Add unaligned handling and default operations
This patch exports the finup operation where available and adds a default finup operation for ahash. The operations final, finup and digest also will now deal with unaligned result pointers by copying it. Finally export/import operations are will now be exported too. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto')
-rw-r--r--include/crypto/hash.h23
-rw-r--r--include/crypto/internal/hash.h6
2 files changed, 14 insertions, 15 deletions
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index 45c2bddfdf32..3e89ce16b59c 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -31,6 +31,9 @@ struct ahash_request {
31 struct scatterlist *src; 31 struct scatterlist *src;
32 u8 *result; 32 u8 *result;
33 33
34 /* This field may only be used by the ahash API code. */
35 void *priv;
36
34 void *__ctx[] CRYPTO_MINALIGN_ATTR; 37 void *__ctx[] CRYPTO_MINALIGN_ATTR;
35}; 38};
36 39
@@ -175,16 +178,11 @@ static inline void *ahash_request_ctx(struct ahash_request *req)
175 return req->__ctx; 178 return req->__ctx;
176} 179}
177 180
178static inline int crypto_ahash_setkey(struct crypto_ahash *tfm, 181int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
179 const u8 *key, unsigned int keylen) 182 unsigned int keylen);
180{ 183int crypto_ahash_finup(struct ahash_request *req);
181 return tfm->setkey(tfm, key, keylen); 184int crypto_ahash_final(struct ahash_request *req);
182} 185int crypto_ahash_digest(struct ahash_request *req);
183
184static inline int crypto_ahash_digest(struct ahash_request *req)
185{
186 return crypto_ahash_reqtfm(req)->digest(req);
187}
188 186
189static inline int crypto_ahash_export(struct ahash_request *req, void *out) 187static inline int crypto_ahash_export(struct ahash_request *req, void *out)
190{ 188{
@@ -206,11 +204,6 @@ static inline int crypto_ahash_update(struct ahash_request *req)
206 return crypto_ahash_reqtfm(req)->update(req); 204 return crypto_ahash_reqtfm(req)->update(req);
207} 205}
208 206
209static inline int crypto_ahash_final(struct ahash_request *req)
210{
211 return crypto_ahash_reqtfm(req)->final(req);
212}
213
214static inline void ahash_request_set_tfm(struct ahash_request *req, 207static inline void ahash_request_set_tfm(struct ahash_request *req,
215 struct crypto_ahash *tfm) 208 struct crypto_ahash *tfm)
216{ 209{
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h
index 179dd8fdfa14..5bfad8c80595 100644
--- a/include/crypto/internal/hash.h
+++ b/include/crypto/internal/hash.h
@@ -59,6 +59,11 @@ int crypto_hash_walk_first_compat(struct hash_desc *hdesc,
59 struct crypto_hash_walk *walk, 59 struct crypto_hash_walk *walk,
60 struct scatterlist *sg, unsigned int len); 60 struct scatterlist *sg, unsigned int len);
61 61
62static inline int crypto_hash_walk_last(struct crypto_hash_walk *walk)
63{
64 return !(walk->entrylen | walk->total);
65}
66
62int crypto_register_ahash(struct ahash_alg *alg); 67int crypto_register_ahash(struct ahash_alg *alg);
63int crypto_unregister_ahash(struct ahash_alg *alg); 68int crypto_unregister_ahash(struct ahash_alg *alg);
64int ahash_register_instance(struct crypto_template *tmpl, 69int ahash_register_instance(struct crypto_template *tmpl,
@@ -94,6 +99,7 @@ static inline void crypto_drop_shash(struct crypto_shash_spawn *spawn)
94struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask); 99struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask);
95 100
96int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc); 101int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc);
102int shash_ahash_finup(struct ahash_request *req, struct shash_desc *desc);
97int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc); 103int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc);
98 104
99int crypto_init_shash_ops_async(struct crypto_tfm *tfm); 105int crypto_init_shash_ops_async(struct crypto_tfm *tfm);