aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/ahash.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/ahash.c')
-rw-r--r--crypto/ahash.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/crypto/ahash.c b/crypto/ahash.c
index 27128f2c687a..ba5292d69ebd 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -112,6 +112,22 @@ int crypto_hash_walk_first(struct ahash_request *req,
112} 112}
113EXPORT_SYMBOL_GPL(crypto_hash_walk_first); 113EXPORT_SYMBOL_GPL(crypto_hash_walk_first);
114 114
115int crypto_hash_walk_first_compat(struct hash_desc *hdesc,
116 struct crypto_hash_walk *walk,
117 struct scatterlist *sg, unsigned int len)
118{
119 walk->total = len;
120
121 if (!walk->total)
122 return 0;
123
124 walk->alignmask = crypto_hash_alignmask(hdesc->tfm);
125 walk->sg = sg;
126 walk->flags = hdesc->flags;
127
128 return hash_walk_new_entry(walk);
129}
130
115static int ahash_setkey_unaligned(struct crypto_ahash *tfm, const u8 *key, 131static int ahash_setkey_unaligned(struct crypto_ahash *tfm, const u8 *key,
116 unsigned int keylen) 132 unsigned int keylen)
117{ 133{
@@ -146,6 +162,26 @@ static int ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
146 return ahash->setkey(tfm, key, keylen); 162 return ahash->setkey(tfm, key, keylen);
147} 163}
148 164
165static int ahash_nosetkey(struct crypto_ahash *tfm, const u8 *key,
166 unsigned int keylen)
167{
168 return -ENOSYS;
169}
170
171int crypto_ahash_import(struct ahash_request *req, const u8 *in)
172{
173 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
174 struct ahash_alg *alg = crypto_ahash_alg(tfm);
175
176 memcpy(ahash_request_ctx(req), in, crypto_ahash_reqsize(tfm));
177
178 if (alg->reinit)
179 alg->reinit(req);
180
181 return 0;
182}
183EXPORT_SYMBOL_GPL(crypto_ahash_import);
184
149static unsigned int crypto_ahash_ctxsize(struct crypto_alg *alg, u32 type, 185static unsigned int crypto_ahash_ctxsize(struct crypto_alg *alg, u32 type,
150 u32 mask) 186 u32 mask)
151{ 187{
@@ -164,7 +200,7 @@ static int crypto_init_ahash_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
164 crt->update = alg->update; 200 crt->update = alg->update;
165 crt->final = alg->final; 201 crt->final = alg->final;
166 crt->digest = alg->digest; 202 crt->digest = alg->digest;
167 crt->setkey = ahash_setkey; 203 crt->setkey = alg->setkey ? ahash_setkey : ahash_nosetkey;
168 crt->digestsize = alg->digestsize; 204 crt->digestsize = alg->digestsize;
169 205
170 return 0; 206 return 0;