Signed-off-by: contextswap <ctxswp@proton.me>
This commit is contained in:
contextswap 2023-05-04 06:24:14 +09:00
parent 97e45216fc
commit 93ec3d31b9
No known key found for this signature in database
GPG key ID: 06A0B660A90A787B

View file

@ -806,7 +806,7 @@ namespace crypto
#ifdef __AES__ #ifdef __AES__
if(i2p::cpu::aesni) if(i2p::cpu::aesni)
{ {
__m128 xmm_1 = _mm_loadu_ps((float const*)&m_IV); __m128 xmm_1 = _mm_loadu_ps((float const*)(uint8_t const*)m_IV);
__m128 xmm_0, xmm_2; __m128 xmm_0, xmm_2;
uint8_t *sched = m_ECBDecryption.GetKeySchedule(); uint8_t *sched = m_ECBDecryption.GetKeySchedule();
for (int i = 0; i < numBlocks; i++) { for (int i = 0; i < numBlocks; i++) {
@ -819,7 +819,7 @@ namespace crypto
in = (ChipherBlock const*)((uint8_t const*)in + 16); in = (ChipherBlock const*)((uint8_t const*)in + 16);
out = (ChipherBlock *)((uint8_t *)out + 16); out = (ChipherBlock *)((uint8_t *)out + 16);
} }
_mm_storeu_ps((float*)&m_IV, xmm_1); _mm_storeu_ps((float*)(uint8_t*)m_IV, xmm_1);
} }
else else
#endif #endif
@ -846,9 +846,9 @@ namespace crypto
#ifdef __AES__ #ifdef __AES__
if(i2p::cpu::aesni) if(i2p::cpu::aesni)
{ {
__m128 xmm_1 = _mm_load_ps((float const*)&m_IV); __m128 xmm_1 = _mm_load_ps((float const*)(uint8_t const*)m_IV);
__m128 xmm_0 = _mm_load_ps((float const*)in); __m128 xmm_0 = _mm_load_ps((float const*)in);
_mm_store_ps((float*)&m_IV, xmm_0); _mm_store_ps((float*)(uint8_t*)m_IV, xmm_0);
uint8_t *sched = m_ECBDecryption.GetKeySchedule(); uint8_t *sched = m_ECBDecryption.GetKeySchedule();
DecryptAES256(sched) DecryptAES256(sched)
xmm_0 = (__m128)_mm_xor_si128((__m128i)xmm_0, (__m128i)xmm_1); xmm_0 = (__m128)_mm_xor_si128((__m128i)xmm_0, (__m128i)xmm_1);
@ -906,7 +906,7 @@ namespace crypto
for (int i = 0; i < 63/*blocks = 1008 bytes*/; i++) { for (int i = 0; i < 63/*blocks = 1008 bytes*/; i++) {
in += 16, out += 16; in += 16, out += 16;
xmm_0 = _mm_loadu_ps((float const*)in); xmm_0 = _mm_loadu_ps((float const*)in);
_mm_store_ps((float*)&xmm_2, xmm_0); xmm_2 = _mm_load_ps((float const*)&xmm_0);
DecryptAES256(sched_l) DecryptAES256(sched_l)
xmm_0 = (__m128)_mm_xor_si128((__m128i)xmm_0, (__m128i)xmm_1); xmm_0 = (__m128)_mm_xor_si128((__m128i)xmm_0, (__m128i)xmm_1);
_mm_storeu_ps((float*)out, xmm_0); _mm_storeu_ps((float*)out, xmm_0);