mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-23 17:36:37 +02:00
ECBEncryption implementation
This commit is contained in:
parent
b4d7116ab8
commit
63bf67ba95
1 changed files with 42 additions and 0 deletions
42
aes.h
42
aes.h
|
@ -44,6 +44,48 @@ namespace crypto
|
||||||
void Decrypt (const ChipherBlock * in, ChipherBlock * out);
|
void Decrypt (const ChipherBlock * in, ChipherBlock * out);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef ECBEncryptionAESNI ECBEncryption;
|
||||||
|
typedef ECBDecryptionAESNI ECBDecryption;
|
||||||
|
|
||||||
|
#else // use crypto++
|
||||||
|
|
||||||
|
class ECBEncryption
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
void SetKey (const uint8_t * key)
|
||||||
|
{
|
||||||
|
m_Encryption.SetKey (key, 32);
|
||||||
|
}
|
||||||
|
void Encrypt (const ChipherBlock * in, ChipherBlock * out)
|
||||||
|
{
|
||||||
|
m_Encryption.ProcessData (out->buf, in->buf, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
CryptoPP::ECB_Mode<CryptoPP::AES>::Encryption m_Encryption;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ECBDecryption
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
void SetKey (const uint8_t * key)
|
||||||
|
{
|
||||||
|
m_Decryption.SetKey (key, 32);
|
||||||
|
}
|
||||||
|
void Decrypt (const ChipherBlock * in, ChipherBlock * out)
|
||||||
|
{
|
||||||
|
m_Decryption.ProcessData (out->buf, in->buf, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
CryptoPP::ECB_Mode<CryptoPP::AES>::Decryption m_Decryption;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class CBCEncryption
|
class CBCEncryption
|
||||||
|
|
Loading…
Add table
Reference in a new issue