mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-07 07:44:13 +00:00
ECBEncryption implementation
This commit is contained in:
parent
b4d7116ab8
commit
63bf67ba95
42
aes.h
42
aes.h
@ -44,6 +44,48 @@ namespace crypto
|
||||
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
|
||||
|
||||
class CBCEncryption
|
||||
|
Loading…
x
Reference in New Issue
Block a user