Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sha512-224,sha512-256摘要算法计算错误 #1773

Open
fanzhiyu7410 opened this issue Dec 14, 2024 · 0 comments
Open

sha512-224,sha512-256摘要算法计算错误 #1773

fanzhiyu7410 opened this issue Dec 14, 2024 · 0 comments

Comments

@fanzhiyu7410
Copy link

sha512-224,sha512-256,sha512需要不同的初始化向量,目前代码使用的是sha512的向量导致计算错误。
void sha512_init(SHA512_CTX *ctx)
{
memset(ctx, 0, sizeof(*ctx));
ctx->state[0] = 0x6a09e667f3bcc908;
ctx->state[1] = 0xbb67ae8584caa73b;
ctx->state[2] = 0x3c6ef372fe94f82b;
ctx->state[3] = 0xa54ff53a5f1d36f1;
ctx->state[4] = 0x510e527fade682d1;
ctx->state[5] = 0x9b05688c2b3e6c1f;
ctx->state[6] = 0x1f83d9abfb41bd6b;
ctx->state[7] = 0x5be0cd19137e2179;
}

void sha512_224_init(SHA512_CTX* ctx)
{
memset(ctx, 0, sizeof(*ctx));
ctx->state[0] = 0x8c3d37c819544da2;
ctx->state[1] = 0x73e1996689dcd4d6;
ctx->state[2] = 0x1dfab7ae32ff9c82;
ctx->state[3] = 0x679dd514582f9fcf;
ctx->state[4] = 0x0f6d2b697bd44da8;
ctx->state[5] = 0x77e36f7304c48942;
ctx->state[6] = 0x3f9d85a86a1d36c8;
ctx->state[7] = 0x1112e6ad91d692a1;
}

void sha512_256_init(SHA512_CTX* ctx)
{
memset(ctx, 0, sizeof(*ctx));
ctx->state[0] = 0x22312194fc2bf72c;
ctx->state[1] = 0x9f555fa3c84c64c2;
ctx->state[2] = 0x2393b86b6f53b151;
ctx->state[3] = 0x963877195940eabd;
ctx->state[4] = 0x96283ee2a88effe3;
ctx->state[5] = 0xbe5e1e2553863992;
ctx->state[6] = 0x2b0199fc2c85b8aa;
ctx->state[7] = 0x0eb72ddc81c52ca2;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant