我正在尝试自己编码 SHA3-512。我坚持 theta 并且我无法根据这个测试向量从中获得正确的输出。消息只有 200 个字节的空字节,我填充了消息。
输入数组是:
[0, 0] = 0000000000000006
[1, 0] = 0000000000000000
[2, 0] = 0000000000000000
[3, 0] = 0000000000000000
[4, 0] = 0000000000000000
[0, 1] = 0000000000000000
[1, 1] = 0000000000000000
[2, 1] = 0000000000000000
[3, 1] = 8000000000000000
[4, 1] = 0000000000000000
[0, 2] = 0000000000000000
[1, 2] = 0000000000000000
[2, 2] = 0000000000000000
[3, 2] = 0000000000000000
[4, 2] = 0000000000000000
[0, 3] = 0000000000000000
[1, 3] = 0000000000000000
[2, 3] = 0000000000000000
[3, 3] = 0000000000000000
[4, 3] = 0000000000000000
[0, 4] = 0000000000000000
[1, 4] = 0000000000000000
[2, 4] = 0000000000000000
[3, 4] = 0000000000000000
[4, 4] = 0000000000000000
我在 C 中的 theta 代码:
/* θ */
uint64_t A[5] = {0x00};
uint64_t B[5] = {0x00};
for (i = 0; i < 5; i++){
A[i] = square[i][0] ^ square[i][1] ^ square[i][2] ^ square[i][3] ^ square[i][4];
}
for (i = 0; i < 5; i++){
B[i] = A[(i + 4) % 5] ^ rotate_left_64(A[(i + 1) % 5], 1);
for (j = 0; j < 5; j++){
square[i][j] = square[i][j] ^ B[i];
}
}
函数 rotate_left_64 :
uint64_t rotate_left_64(uint64_t i, int c){
uint64_t j = 0;
j = i << c;
j = j ^ (i >> (64 - c));
return j;
}
现在工作了几个小时......我的错误是什么?
提前致谢