【发布时间】:2017-04-04 10:32:15
【问题描述】:
当我尝试加载一些使用内在函数生成的密文时,我遇到了段错误。我根本不明白这个错误。代码示例:
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。
-
会不会是对齐问题?
标签: c x86 sse simd intrinsics