mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-08-08 06:03:47 +08:00
fix sm3 padding bug
This commit is contained in:
4
crypto/sm3/sm3.c
Normal file → Executable file
4
crypto/sm3/sm3.c
Normal file → Executable file
@@ -110,8 +110,8 @@ void sm3_final(sm3_ctx_t *ctx, unsigned char *digest)
|
|||||||
memset(ctx->block, 0, SM3_BLOCK_SIZE - 8);
|
memset(ctx->block, 0, SM3_BLOCK_SIZE - 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
count[0] = cpu_to_be32((ctx->nblocks) >> 23);
|
count[0] = cpu_to_be32((uint32_t)(ctx->nblocks >> 23));
|
||||||
count[1] = cpu_to_be32((ctx->nblocks << 9) + (ctx->num << 3));
|
count[1] = cpu_to_be32((uint32_t)(ctx->nblocks << 9) + (ctx->num << 3));
|
||||||
|
|
||||||
sm3_compress(ctx->digest, ctx->block);
|
sm3_compress(ctx->digest, ctx->block);
|
||||||
for (i = 0; i < sizeof(ctx->digest)/sizeof(ctx->digest[0]); i++) {
|
for (i = 0; i < sizeof(ctx->digest)/sizeof(ctx->digest[0]); i++) {
|
||||||
|
|||||||
2
include/openssl/sm3.h
Normal file → Executable file
2
include/openssl/sm3.h
Normal file → Executable file
@@ -70,7 +70,7 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t digest[8];
|
uint32_t digest[8];
|
||||||
int nblocks;
|
uint64_t nblocks;
|
||||||
unsigned char block[64];
|
unsigned char block[64];
|
||||||
int num;
|
int num;
|
||||||
} sm3_ctx_t;
|
} sm3_ctx_t;
|
||||||
|
|||||||
Reference in New Issue
Block a user