咨询:sha256 中digest用mmcau和其他软件库运行结果不一样问题

cancel
Showing results for 
Search instead for 
Did you mean: 

咨询:sha256 中digest用mmcau和其他软件库运行结果不一样问题

471 Views
yunyang
Contributor I

sha256 中digest用mmcau和其他软件库运行结果不一样问题。

首先,我使用mmcau用算sha256:

/* SHA test string: "The quick brown fox jumps over the lazy dog"
* with padding bits included
*/
static uint8_t g_testSha[64] = {0x54, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x20, 0x62, 0x72, 0x6f,0x77, 0x6e, 0x20, 0x66, 0x6f, 0x78, 0x20, 0x6a, 0x75, 0x6d, 0x70, 0x73, 0x20,
0x6f, 0x76, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x61, 0x7a, 0x79,
0x20, 0x64, 0x6f, 0x66, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x58};

绿色的是“The quick brown fox jumps over the lazy dog”,红色的那一段是运算中干什么的?

用软件实现sha256,输入的是“The quick brown fox jumps over the lazy dog”,共43个字符,digest is:d7a8fbb37d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592

但是,若“The quick brown fox jumps over the lazy dog€.................. X”,这个是64个字符,软件digest is:66092d3c2467b3373e11bb0d2618f935213348ab61e115895402a133e6c5631e

mmcau  digest is: d7a8fbb37d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592.

 

这,是怎么回事????运算“The quick brown fox jumps over the lazy dog”硬件mmcau为何还要后面一段“€.................. X”

0 Kudos
4 Replies

367 Views
yunyang
Contributor I

Thanks. have been solven by myself

0 Kudos

367 Views
yunyang
Contributor I

0x80 in the first byte and the length is the last 8 bytes.

so, 0x158 = 334,334/8bit = 43字节。前面的“The quick brown fox jumps over the lazy dog”正好43字节。

额。。。。。。

0 Kudos

367 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, 聚财 任,

I have asked the expert on the encryption, the 0x80 is the delimiter, which tells the the following data are the padding, the last byte 0x0158 is the bit size of the valid data.

Hope it can help you

BR

Xiangjun Rong

0 Kudos

367 Views
yunyang
Contributor I

红色的填充位 是怎么来的?mmcau计算为何用到这些填充位?

0 Kudos