Changeset View
Changeset View
Standalone View
Standalone View
sys/crypto/aesni/aesni_ghash.c
Show First 20 Lines • Show All 784 Lines • ▼ Show 20 Lines | for (k=i*8; k<nbytes/16; k++) { | ||||||||
} | } | ||||||||
tmp1 = _mm_aesenc_si128(tmp1, KEY[nr-1]); | tmp1 = _mm_aesenc_si128(tmp1, KEY[nr-1]); | ||||||||
tmp1 = _mm_aesenclast_si128(tmp1, KEY[nr]); | tmp1 = _mm_aesenclast_si128(tmp1, KEY[nr]); | ||||||||
tmp1 = _mm_xor_si128(tmp1, | tmp1 = _mm_xor_si128(tmp1, | ||||||||
_mm_loadu_si128(&((const __m128i *)in)[k])); | _mm_loadu_si128(&((const __m128i *)in)[k])); | ||||||||
_mm_storeu_si128(&((__m128i*)out)[k], tmp1); | _mm_storeu_si128(&((__m128i*)out)[k], tmp1); | ||||||||
} | } | ||||||||
//If remains one incomplete block | //If remains one incomplete block | ||||||||
if (nbytes%16) { | if (nbytes%16) { | ||||||||
cem: Is this correct if `nbytes` was > 2GB? nbytes is a `uint32` but `resid` is (signed) integer. | |||||||||
Done Inline ActionsI think it still happens to work. Note that OCF itself can only describe buffers up to 2GB anyway (crp_payload_length is an int I think?) jhb: I think it still happens to work. Note that OCF itself can only describe buffers up to 2GB… | |||||||||
tmp1 = _mm_shuffle_epi8(ctr1, BSWAP_EPI64); | tmp1 = _mm_shuffle_epi8(ctr1, BSWAP_EPI64); | ||||||||
tmp1 = _mm_xor_si128(tmp1, KEY[0]); | tmp1 = _mm_xor_si128(tmp1, KEY[0]); | ||||||||
for (j=1; j<nr-1; j+=2) { | for (j=1; j<nr-1; j+=2) { | ||||||||
tmp1 = _mm_aesenc_si128(tmp1, KEY[j]); | tmp1 = _mm_aesenc_si128(tmp1, KEY[j]); | ||||||||
tmp1 = _mm_aesenc_si128(tmp1, KEY[j+1]); | tmp1 = _mm_aesenc_si128(tmp1, KEY[j+1]); | ||||||||
} | } | ||||||||
tmp1 = _mm_aesenc_si128(tmp1, KEY[nr-1]); | tmp1 = _mm_aesenc_si128(tmp1, KEY[nr-1]); | ||||||||
tmp1 = _mm_aesenclast_si128(tmp1, KEY[nr]); | tmp1 = _mm_aesenclast_si128(tmp1, KEY[nr]); | ||||||||
tmp1 = _mm_xor_si128(tmp1, | last_block = _mm_setzero_si128(); | ||||||||
_mm_loadu_si128(&((const __m128i *)in)[k])); | memcpy(&last_block, &((const __m128i *)in)[k], nbytes%16); | ||||||||
tmp1 = _mm_xor_si128(tmp1, last_block); | |||||||||
last_block = tmp1; | last_block = tmp1; | ||||||||
for (j=0; j<nbytes%16; j++) | for (j=0; j<nbytes%16; j++) | ||||||||
Done Inline Actions
typo cem: typo | |||||||||
out[k*16+j] = ((unsigned char*)&last_block)[j]; | out[k*16+j] = ((unsigned char*)&last_block)[j]; | ||||||||
} | } | ||||||||
return 1; //when sucessfull returns 1 | return 1; //when sucessfull returns 1 | ||||||||
} | } |
Is this correct if nbytes was > 2GB? nbytes is a uint32 but resid is (signed) integer.