I2P: End-to-End encrypted and anonymous Internet https://i2pd.website/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
652 B

10 years ago
#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];
}
}
}
}