mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
fixed misalignment
This commit is contained in:
parent
69cbd71fe0
commit
c3e329e406
21
aes.h
21
aes.h
|
@ -10,15 +10,28 @@ namespace i2p
|
|||
{
|
||||
namespace crypto
|
||||
{
|
||||
union ChipherBlock
|
||||
struct ChipherBlock
|
||||
{
|
||||
uint8_t buf[16];
|
||||
uint64_t ll[2];
|
||||
|
||||
void operator^=(const ChipherBlock& other) // XOR
|
||||
{
|
||||
ll[0] ^= other.ll[0];
|
||||
ll[1] ^= other.ll[1];
|
||||
#if defined(__x86_64__) // for Intel x64
|
||||
__asm__
|
||||
(
|
||||
"movups (%[buf]), %%xmm0 \n"
|
||||
"movups (%[other]), %%xmm1 \n"
|
||||
"pxor %%xmm1, %%xmm0 \n"
|
||||
"movups %%xmm0, (%[buf]) \n"
|
||||
:
|
||||
: [buf]"r"(buf), [other]"r"(other.buf)
|
||||
: "%xmm0", "%xmm1", "memory"
|
||||
);
|
||||
#else
|
||||
// TODO: implement it better
|
||||
for (int i = 0; i < 16; i++)
|
||||
buf[i] ^= other.buf[i];
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue