aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/ahash.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2008-11-02 08:38:11 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2008-12-24 19:01:30 -0500
commitdec8b78606ebd5f309c38f2fb10196ce996dd18d (patch)
tree005ef526f1b0e953a3a57e6c991e0921fcd5234b /crypto/ahash.c
parent3b2f6df08258e2875f42bd630eece7e7241a053b (diff)
crypto: hash - Add import/export interface
It is often useful to save the partial state of a hash function so that it can be used as a base for two or more computations. The most prominent example is HMAC where all hashes start from a base determined by the key. Having an import/export interface means that we only have to compute that base once rather than for each message. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/ahash.c')
-rw-r--r--crypto/ahash.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/ahash.c b/crypto/ahash.c
index 27128f2c687..7d4e33dfe21 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -146,6 +146,20 @@ static int ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
146 return ahash->setkey(tfm, key, keylen); 146 return ahash->setkey(tfm, key, keylen);
147} 147}
148 148
149int crypto_ahash_import(struct ahash_request *req, const u8 *in)
150{
151 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
152 struct ahash_alg *alg = crypto_ahash_alg(tfm);
153
154 memcpy(ahash_request_ctx(req), in, crypto_ahash_reqsize(tfm));
155
156 if (alg->reinit)
157 alg->reinit(req);
158
159 return 0;
160}
161EXPORT_SYMBOL_GPL(crypto_ahash_import);
162
149static unsigned int crypto_ahash_ctxsize(struct crypto_alg *alg, u32 type, 163static unsigned int crypto_ahash_ctxsize(struct crypto_alg *alg, u32 type,
150 u32 mask) 164 u32 mask)
151{ 165{