mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-07 07:44:13 +00:00
ChiperBlock XOR
This commit is contained in:
parent
9372b33c2c
commit
37c3a9dcf1
6
aes.cpp
6
aes.cpp
@ -165,8 +165,7 @@ namespace crypto
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < numBlocks; i++)
|
for (int i = 0; i < numBlocks; i++)
|
||||||
{
|
{
|
||||||
m_LastBlock.ll[0] ^= in[i].ll[0];
|
m_LastBlock ^= in[i];
|
||||||
m_LastBlock.ll[1] ^= in[i].ll[1];
|
|
||||||
m_ECBEncryption.Encrypt (&m_LastBlock, &m_LastBlock);
|
m_ECBEncryption.Encrypt (&m_LastBlock, &m_LastBlock);
|
||||||
out[i] = m_LastBlock;
|
out[i] = m_LastBlock;
|
||||||
}
|
}
|
||||||
@ -186,8 +185,7 @@ namespace crypto
|
|||||||
{
|
{
|
||||||
ChipherBlock tmp = in[i];
|
ChipherBlock tmp = in[i];
|
||||||
m_ECBDecryption.Decrypt (in + i, out + i);
|
m_ECBDecryption.Decrypt (in + i, out + i);
|
||||||
out[i].ll[0] ^= m_IV.ll[0];
|
out[i] ^= m_IV;
|
||||||
out[i].ll[1] ^= m_IV.ll[1];
|
|
||||||
m_IV = tmp;
|
m_IV = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
aes.h
5
aes.h
@ -14,13 +14,14 @@ namespace crypto
|
|||||||
uint8_t buf[16];
|
uint8_t buf[16];
|
||||||
uint64_t ll[2];
|
uint64_t ll[2];
|
||||||
|
|
||||||
void operator^(const ChipherBlock& other) // XOR
|
void operator^=(const ChipherBlock& other) // XOR
|
||||||
{
|
{
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
__asm__
|
__asm__
|
||||||
(
|
(
|
||||||
"movups (%[b1]), %%xmm0 \n"
|
"movups (%[b1]), %%xmm0 \n"
|
||||||
"pxor (%[b2]), %%xmm0 \n"
|
"movups (%[b2]), %%xmm1 \n" // b2 might not be 16-bytes aligned
|
||||||
|
"pxor %%xmm1, %%xmm0 \n"
|
||||||
"movups %%xmm0, (%[b1]) \n"
|
"movups %%xmm0, (%[b1]) \n"
|
||||||
: : [b1]"r"(buf), [b2]"r"(other.buf): "memory", "%xmm0"
|
: : [b1]"r"(buf), [b2]"r"(other.buf): "memory", "%xmm0"
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user