Skip to content

Commit f492828

Browse files
uudiinherbertx
authored andcommitted
crypto: sm3 - export crypto_sm3_final function
Both crypto_sm3_update and crypto_sm3_finup have been exported, exporting crypto_sm3_final, to avoid having to use crypto_sm3_finup(desc, NULL, 0, dgst) to calculate the hash in some cases. Signed-off-by: Tianjia Zhang <[email protected]> Tested-by: Xufeng Zhang <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent d8e8876 commit f492828

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

crypto/sm3_generic.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,25 +149,26 @@ int crypto_sm3_update(struct shash_desc *desc, const u8 *data,
149149
}
150150
EXPORT_SYMBOL(crypto_sm3_update);
151151

152-
static int sm3_final(struct shash_desc *desc, u8 *out)
152+
int crypto_sm3_final(struct shash_desc *desc, u8 *out)
153153
{
154154
sm3_base_do_finalize(desc, sm3_generic_block_fn);
155155
return sm3_base_finish(desc, out);
156156
}
157+
EXPORT_SYMBOL(crypto_sm3_final);
157158

158159
int crypto_sm3_finup(struct shash_desc *desc, const u8 *data,
159160
unsigned int len, u8 *hash)
160161
{
161162
sm3_base_do_update(desc, data, len, sm3_generic_block_fn);
162-
return sm3_final(desc, hash);
163+
return crypto_sm3_final(desc, hash);
163164
}
164165
EXPORT_SYMBOL(crypto_sm3_finup);
165166

166167
static struct shash_alg sm3_alg = {
167168
.digestsize = SM3_DIGEST_SIZE,
168169
.init = sm3_base_init,
169170
.update = crypto_sm3_update,
170-
.final = sm3_final,
171+
.final = crypto_sm3_final,
171172
.finup = crypto_sm3_finup,
172173
.descsize = sizeof(struct sm3_state),
173174
.base = {

include/crypto/sm3.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ struct shash_desc;
3535
extern int crypto_sm3_update(struct shash_desc *desc, const u8 *data,
3636
unsigned int len);
3737

38+
extern int crypto_sm3_final(struct shash_desc *desc, u8 *out);
39+
3840
extern int crypto_sm3_finup(struct shash_desc *desc, const u8 *data,
3941
unsigned int len, u8 *hash);
4042
#endif

0 commit comments

Comments
 (0)