mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
crypto: sha256 - Expose SHA256 generic routine to be callable externally.
Other SHA256 routine may need to use the generic routine when
FPU is not available.
Change-Id: I9301e29ef34cd2597d9e418f43a07c2ce9d6eafa
Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Git-commit: 35d2c9d0c3
Git-repo: https://android.googlesource.com/kernel/common/
Signed-off-by: Samir Mehta <samirn@codeaurora.org>
This commit is contained in:
parent
1de79682ea
commit
1c5309bc7f
2 changed files with 8 additions and 5 deletions
|
@ -246,7 +246,7 @@ static int sha256_init(struct shash_desc *desc)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sha256_update(struct shash_desc *desc, const u8 *data,
|
int crypto_sha256_update(struct shash_desc *desc, const u8 *data,
|
||||||
unsigned int len)
|
unsigned int len)
|
||||||
{
|
{
|
||||||
struct sha256_state *sctx = shash_desc_ctx(desc);
|
struct sha256_state *sctx = shash_desc_ctx(desc);
|
||||||
|
@ -277,6 +277,7 @@ static int sha256_update(struct shash_desc *desc, const u8 *data,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL(crypto_sha256_update);
|
||||||
|
|
||||||
static int sha256_final(struct shash_desc *desc, u8 *out)
|
static int sha256_final(struct shash_desc *desc, u8 *out)
|
||||||
{
|
{
|
||||||
|
@ -293,10 +294,10 @@ static int sha256_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;
|
||||||
pad_len = (index < 56) ? (56 - index) : ((64+56) - index);
|
pad_len = (index < 56) ? (56 - index) : ((64+56) - index);
|
||||||
sha256_update(desc, padding, pad_len);
|
crypto_sha256_update(desc, padding, pad_len);
|
||||||
|
|
||||||
/* Append length (before padding) */
|
/* Append length (before padding) */
|
||||||
sha256_update(desc, (const u8 *)&bits, sizeof(bits));
|
crypto_sha256_update(desc, (const u8 *)&bits, sizeof(bits));
|
||||||
|
|
||||||
/* Store state in digest */
|
/* Store state in digest */
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
|
@ -339,7 +340,7 @@ static int sha256_import(struct shash_desc *desc, const void *in)
|
||||||
static struct shash_alg sha256 = {
|
static struct shash_alg sha256 = {
|
||||||
.digestsize = SHA256_DIGEST_SIZE,
|
.digestsize = SHA256_DIGEST_SIZE,
|
||||||
.init = sha256_init,
|
.init = sha256_init,
|
||||||
.update = sha256_update,
|
.update = crypto_sha256_update,
|
||||||
.final = sha256_final,
|
.final = sha256_final,
|
||||||
.export = sha256_export,
|
.export = sha256_export,
|
||||||
.import = sha256_import,
|
.import = sha256_import,
|
||||||
|
@ -357,7 +358,7 @@ static struct shash_alg sha256 = {
|
||||||
static struct shash_alg sha224 = {
|
static struct shash_alg sha224 = {
|
||||||
.digestsize = SHA224_DIGEST_SIZE,
|
.digestsize = SHA224_DIGEST_SIZE,
|
||||||
.init = sha224_init,
|
.init = sha224_init,
|
||||||
.update = sha256_update,
|
.update = crypto_sha256_update,
|
||||||
.final = sha224_final,
|
.final = sha224_final,
|
||||||
.descsize = sizeof(struct sha256_state),
|
.descsize = sizeof(struct sha256_state),
|
||||||
.base = {
|
.base = {
|
||||||
|
|
|
@ -87,4 +87,6 @@ struct shash_desc;
|
||||||
extern int crypto_sha1_update(struct shash_desc *desc, const u8 *data,
|
extern int crypto_sha1_update(struct shash_desc *desc, const u8 *data,
|
||||||
unsigned int len);
|
unsigned int len);
|
||||||
|
|
||||||
|
extern int crypto_sha256_update(struct shash_desc *desc, const u8 *data,
|
||||||
|
unsigned int len);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue