mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
crypto: sha1 - export sha1_update for reuse
Export the update function as crypto_sha1_update() to not have the need to reimplement the same algorithm for each SHA-1 implementation. This way the generic SHA-1 implementation can be used as fallback for other implementations that fail to run under certain circumstances, like the need for an FPU context while executing in IRQ context. Signed-off-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
b64dc04beb
commit
7c390170b4
2 changed files with 8 additions and 4 deletions
|
@ -36,7 +36,7 @@ static int sha1_init(struct shash_desc *desc)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sha1_update(struct shash_desc *desc, const u8 *data,
|
int crypto_sha1_update(struct shash_desc *desc, const u8 *data,
|
||||||
unsigned int len)
|
unsigned int len)
|
||||||
{
|
{
|
||||||
struct sha1_state *sctx = shash_desc_ctx(desc);
|
struct sha1_state *sctx = shash_desc_ctx(desc);
|
||||||
|
@ -71,6 +71,7 @@ static int sha1_update(struct shash_desc *desc, const u8 *data,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(crypto_sha1_update);
|
||||||
|
|
||||||
|
|
||||||
/* Add padding and return the message digest. */
|
/* Add padding and return the message digest. */
|
||||||
|
@ -87,10 +88,10 @@ static int sha1_final(struct shash_desc *desc, u8 *out)
|
||||||
/* Pad out to 56 mod 64 */
|
/* Pad out to 56 mod 64 */
|
||||||
index = sctx->count & 0x3f;
|
index = sctx->count & 0x3f;
|
||||||
padlen = (index < 56) ? (56 - index) : ((64+56) - index);
|
padlen = (index < 56) ? (56 - index) : ((64+56) - index);
|
||||||
sha1_update(desc, padding, padlen);
|
crypto_sha1_update(desc, padding, padlen);
|
||||||
|
|
||||||
/* Append length */
|
/* Append length */
|
||||||
sha1_update(desc, (const u8 *)&bits, sizeof(bits));
|
crypto_sha1_update(desc, (const u8 *)&bits, sizeof(bits));
|
||||||
|
|
||||||
/* Store state in digest */
|
/* Store state in digest */
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < 5; i++)
|
||||||
|
@ -121,7 +122,7 @@ static int sha1_import(struct shash_desc *desc, const void *in)
|
||||||
static struct shash_alg alg = {
|
static struct shash_alg alg = {
|
||||||
.digestsize = SHA1_DIGEST_SIZE,
|
.digestsize = SHA1_DIGEST_SIZE,
|
||||||
.init = sha1_init,
|
.init = sha1_init,
|
||||||
.update = sha1_update,
|
.update = crypto_sha1_update,
|
||||||
.final = sha1_final,
|
.final = sha1_final,
|
||||||
.export = sha1_export,
|
.export = sha1_export,
|
||||||
.import = sha1_import,
|
.import = sha1_import,
|
||||||
|
|
|
@ -82,4 +82,7 @@ struct sha512_state {
|
||||||
u8 buf[SHA512_BLOCK_SIZE];
|
u8 buf[SHA512_BLOCK_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern int crypto_sha1_update(struct shash_desc *desc, const u8 *data,
|
||||||
|
unsigned int len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue