我正在尝试用C实现带有SSE2指令的SHA1。初始化似乎是有效的,但是如果我尝试一下
round1(testhashe, testhasha, testhashb, testhashc, testhashd, loadConstant(b[z]));作为我的算法的第一轮,我得到了错误。检查之前的常量和值是正确的,但最后一个值将是错误的。我的宏是
#define rotthirty(val) (_mm_or_si128(_mm_slli_epi32(val,30),_mm_srli_epi32(val,2)))
#define f1(b,c,d) (_mm_xor_si128(d,_mm_and_si128(b, _mm_xor_si128(c, d))))
// Round functions
#define round1(A,B,C,D,E,w) \
temp = rotthirty(A);\
temp = _mm_add_epi32(temp,f1(B, C, D));\
temp = _mm_add_epi32(temp,k1);\
temp = _mm_add_epi32(temp,w);\
E = _mm_add_epi32(temp, E);\
B = rotthirty(B);\在我更改为SSE2函数之前,这些都是有效的,我只是将运算符更改为函数。我做错了什么?
此函数之后的输出,一次从with intrinsics和4 sha计算中获得
Vector: 67452301 67452301 67452301 67452301
Vector: 7bf36ae2 7bf36ae2 7bf36ae2 7bf36ae2
Vector: 98badcfe 98badcfe 98badcfe 98badcfe
Vector: 10325476 10325476 10325476 10325476
Vector: 734fe2b5 724fe2b5 8b4ee2b5 8a4ee2b5除了最后一行之外,都包含正确的值,这可以在Round1之后执行SSE2自由工作代码中看到
67452301
7bf36ae2
98badcfe
10325476
122fa21https://stackoverflow.com/questions/47600978
复制相似问题