mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-04 07:31:11 +00:00
aesni: Avoid a potential out-of-bounds load in AES_GCM_encrypt()
Reported by: Jenkins (KASAN job)
Reviewed by: cem, jhb
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 4285655adb
)
This commit is contained in:
parent
f085bb0e62
commit
8c29b0eeb0
|
@ -504,9 +504,10 @@ AES_GCM_encrypt(const unsigned char *in, unsigned char *out,
|
|||
}
|
||||
tmp1 = _mm_aesenc_si128(tmp1, KEY[nr-1]);
|
||||
tmp1 = _mm_aesenclast_si128(tmp1, KEY[nr]);
|
||||
tmp1 = _mm_xor_si128(tmp1,
|
||||
_mm_loadu_si128(&((const __m128i *)in)[k]));
|
||||
last_block = tmp1;
|
||||
last_block = _mm_setzero_si128();
|
||||
memcpy(&last_block, &((const __m128i *)in)[k],
|
||||
nbytes % 16);
|
||||
last_block = _mm_xor_si128(last_block, tmp1);
|
||||
for (j=0; j<nbytes%16; j++)
|
||||
out[k*16+j] = ((unsigned char*)&last_block)[j];
|
||||
for ((void)j; j<16; j++)
|
||||
|
|
Loading…
Reference in a new issue