fix sm3 padding bug

This commit is contained in:
zhaoxincheng
2018-08-30 16:37:25 +08:00
parent 940c98d5d7
commit 41049aa0cd
2 changed files with 3 additions and 3 deletions

4
crypto/sm3/sm3.c Normal file → Executable file
View File

@@ -110,8 +110,8 @@ void sm3_final(sm3_ctx_t *ctx, unsigned char *digest)
memset(ctx->block, 0, SM3_BLOCK_SIZE - 8);
}
count[0] = cpu_to_be32((ctx->nblocks) >> 23);
count[1] = cpu_to_be32((ctx->nblocks << 9) + (ctx->num << 3));
count[0] = cpu_to_be32((uint32_t)(ctx->nblocks >> 23));
count[1] = cpu_to_be32((uint32_t)(ctx->nblocks << 9) + (ctx->num << 3));
sm3_compress(ctx->digest, ctx->block);
for (i = 0; i < sizeof(ctx->digest)/sizeof(ctx->digest[0]); i++) {