當我嘗試加載使用內在函數生成的某些密文時,出現段錯誤。我根本不明白這個錯誤。代碼示例:SSE segfault on _mm_store_si128
unsigned char c[177];
unsigned char m[161];
auth = _mm_setzero_si128();
unsigned char M_star[BLOCKSIZE];
__m128i tag = auth;
for(i=0;i<numblocks_mes;++i)
{
M = _mm_load_si128(m+i*BLOCKSIZE);
idx = _mm_set_epi64x(zero,i); // both inputs are unsigned long long
tmp = encrypt_block(M,idx);
tag = _mm_xor_si128(tag,tmp);
}
if(fin_mes)
{
memcpy(M_star,m+numblocks_mes*BLOCKSIZE,fin_mes);
A_star[fin_mes] = 0x80;
memset(M_star+fin_mes+1,0,BLOCKSIZE-(fin_mes+1));
M = _mm_load_si128(M_star);
idx = _mm_set_epi64x(tag_fin,numblocks_mes); // both inputs are unsigned long long
tmp = encrypt_block(M,idx); // Contains calls to AES
tag = _mm_xor_si128(tag,tmp);
}
// print128_asint(tag);
tag = encrypt_block(tag,nonce);
// Following line causes segfault
_mm_store_si128((__m128i *)&c[numblocks_mes*BLOCKSIZE+fin_mes], tag); // numblocks_mes*BLOCKSIZE+fin_mes = 161
我曾嘗試過其他類似的問題之前尋找,並試圖出來,但我沒有發現任何東西爲我工作。
我忘了寫fin_mes是一個整數,它是1,BLOCKSIZE是16,numblocks_mes是10. –
它可能是一個對齊問題? – unwind