diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2008-11-02 08:38:11 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2008-12-24 19:01:30 -0500 |
commit | dec8b78606ebd5f309c38f2fb10196ce996dd18d (patch) | |
tree | 005ef526f1b0e953a3a57e6c991e0921fcd5234b /crypto/shash.c | |
parent | 3b2f6df08258e2875f42bd630eece7e7241a053b (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/shash.c')
-rw-r--r-- | crypto/shash.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crypto/shash.c b/crypto/shash.c index 3f4c713a21ea..26aff3feefc0 100644 --- a/crypto/shash.c +++ b/crypto/shash.c | |||
@@ -172,6 +172,20 @@ int crypto_shash_digest(struct shash_desc *desc, const u8 *data, | |||
172 | } | 172 | } |
173 | EXPORT_SYMBOL_GPL(crypto_shash_digest); | 173 | EXPORT_SYMBOL_GPL(crypto_shash_digest); |
174 | 174 | ||
175 | int crypto_shash_import(struct shash_desc *desc, const u8 *in) | ||
176 | { | ||
177 | struct crypto_shash *tfm = desc->tfm; | ||
178 | struct shash_alg *alg = crypto_shash_alg(tfm); | ||
179 | |||
180 | memcpy(shash_desc_ctx(desc), in, crypto_shash_descsize(tfm)); | ||
181 | |||
182 | if (alg->reinit) | ||
183 | alg->reinit(desc); | ||
184 | |||
185 | return 0; | ||
186 | } | ||
187 | EXPORT_SYMBOL_GPL(crypto_shash_import); | ||
188 | |||
175 | static int shash_async_setkey(struct crypto_ahash *tfm, const u8 *key, | 189 | static int shash_async_setkey(struct crypto_ahash *tfm, const u8 *key, |
176 | unsigned int keylen) | 190 | unsigned int keylen) |
177 | { | 191 | { |