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

SM3计算结果和pdf文档不一致呢? #6

Open
tan00 opened this issue Dec 17, 2019 · 3 comments
Open

SM3计算结果和pdf文档不一致呢? #6

tan00 opened this issue Dec 17, 2019 · 3 comments

Comments

@tan00
Copy link

tan00 commented Dec 17, 2019

SM3文档示例1

输入消息为“abc”,其ASCII码表示为616263 ... 杂凑值
66c7f0f4 62eeedd9 d1f2d46b dc10e4e2 4167c487 5cf2f7a2 297da02b 8f4ba8e0

在linux下编译输出结果为

Message:
abc
Hash:
37bc43d1 1cab393d 7899ef62 24f568ec 18a8fd85 1d165c50 0c375402 0f466a04

代码粗略看了下, 至少位移的宏看起来有问题

#define  SHL(x,n) (((x) & 0xFFFFFFFF) << n)
#define ROTL(x,n) (SHL((x),n) | ((x) >> (32 - n)))

GMSSL里面的SM3代码, 位移宏为

#define ROTL(x,n)  (((x)<<(n)) | ((x)>>(32-(n))))

GMSSL SM3输出没有问题。

@zhang-kt
Copy link

zhang-kt commented Nov 4, 2020

1.问题:64的linux系统下编译会出现SM3计算结果和pdf文档不一致
解决方案:在编译的时候加 -m32 即可

2.衍生问题:添加 -m32 后ubuntu下报错/usr/include/features.h:367:25: fatal error: sys/cdefs.h: No such file or directory
解决方案:sudo apt-get install libc6-dev-i386

@halloayu
Copy link

halloayu commented Mar 3, 2022

sm2那边有个sm3,输出是正常的

@NEWPLAN
Copy link
Owner

NEWPLAN commented Feb 11, 2023

fixed. Thanks for your attentions!

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

4 participants