mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-05-18 05:11:48 +02:00
aes added
This commit is contained in:
parent
44bba19283
commit
d8d8c752b1
3 changed files with 86 additions and 1 deletions
30
aes.cpp
Normal file
30
aes.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "aes.h"
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace crypto
|
||||
{
|
||||
void CBCEncryption::Encrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out)
|
||||
{
|
||||
for (int i = 0; i < numBlocks; i++)
|
||||
{
|
||||
m_LastBlock.ll[0] ^= in[i].ll[0];
|
||||
m_LastBlock.ll[1] ^= in[i].ll[1];
|
||||
m_ECBEncryption.ProcessData (m_LastBlock.buf, m_LastBlock.buf, 16);
|
||||
out[i] = m_LastBlock;
|
||||
}
|
||||
}
|
||||
|
||||
void CBCDecryption::Decrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out)
|
||||
{
|
||||
for (int i = 0; i < numBlocks; i++)
|
||||
{
|
||||
m_ECBDecryption.ProcessData (out[i].buf, in[i].buf, 16);
|
||||
out[i].ll[0] ^= m_IV.ll[0];
|
||||
out[i].ll[1] ^= m_IV.ll[1];
|
||||
m_IV = in[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue