Skip to content

Commit 35d2c9d

Browse files
pdxChenherbertx
authored andcommitted
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. Signed-off-by: Tim Chen <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 873b9ca commit 35d2c9d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

crypto/sha256_generic.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static int sha256_init(struct shash_desc *desc)
246246
return 0;
247247
}
248248

249-
static int sha256_update(struct shash_desc *desc, const u8 *data,
249+
int crypto_sha256_update(struct shash_desc *desc, const u8 *data,
250250
unsigned int len)
251251
{
252252
struct sha256_state *sctx = shash_desc_ctx(desc);
@@ -277,6 +277,7 @@ static int sha256_update(struct shash_desc *desc, const u8 *data,
277277

278278
return 0;
279279
}
280+
EXPORT_SYMBOL(crypto_sha256_update);
280281

281282
static int sha256_final(struct shash_desc *desc, u8 *out)
282283
{
@@ -293,10 +294,10 @@ static int sha256_final(struct shash_desc *desc, u8 *out)
293294
/* Pad out to 56 mod 64. */
294295
index = sctx->count & 0x3f;
295296
pad_len = (index < 56) ? (56 - index) : ((64+56) - index);
296-
sha256_update(desc, padding, pad_len);
297+
crypto_sha256_update(desc, padding, pad_len);
297298

298299
/* Append length (before padding) */
299-
sha256_update(desc, (const u8 *)&bits, sizeof(bits));
300+
crypto_sha256_update(desc, (const u8 *)&bits, sizeof(bits));
300301

301302
/* Store state in digest */
302303
for (i = 0; i < 8; i++)
@@ -339,7 +340,7 @@ static int sha256_import(struct shash_desc *desc, const void *in)
339340
static struct shash_alg sha256_algs[2] = { {
340341
.digestsize = SHA256_DIGEST_SIZE,
341342
.init = sha256_init,
342-
.update = sha256_update,
343+
.update = crypto_sha256_update,
343344
.final = sha256_final,
344345
.export = sha256_export,
345346
.import = sha256_import,
@@ -355,7 +356,7 @@ static struct shash_alg sha256_algs[2] = { {
355356
}, {
356357
.digestsize = SHA224_DIGEST_SIZE,
357358
.init = sha224_init,
358-
.update = sha256_update,
359+
.update = crypto_sha256_update,
359360
.final = sha224_final,
360361
.descsize = sizeof(struct sha256_state),
361362
.base = {

include/crypto/sha.h

+2
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,6 @@ struct shash_desc;
8787
extern int crypto_sha1_update(struct shash_desc *desc, const u8 *data,
8888
unsigned int len);
8989

90+
extern int crypto_sha256_update(struct shash_desc *desc, const u8 *data,
91+
unsigned int len);
9092
#endif

0 commit comments

Comments
 (0)