mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-30 12:47:48 +02:00
Split tunnel-specific crypto from aes.h/cpp.
This commit is contained in:
parent
d9bb09780f
commit
9597917183
9 changed files with 410 additions and 385 deletions
49
tunnel/TunnelCrypto.h
Normal file
49
tunnel/TunnelCrypto.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
#ifndef TUNNEL_CRYPTO_H__
|
||||
#define TUNNEL_CRYPTO_H__
|
||||
|
||||
#include "crypto/aes.h"
|
||||
|
||||
namespace i2p {
|
||||
namespace crypto {
|
||||
|
||||
class TunnelEncryption { // with double IV encryption
|
||||
public:
|
||||
void SetKeys (const AESKey& layerKey, const AESKey& ivKey);
|
||||
|
||||
void Encrypt (const uint8_t * in, uint8_t * out); // 1024 bytes (16 IV + 1008 data)
|
||||
|
||||
private:
|
||||
|
||||
ECBEncryption m_IVEncryption;
|
||||
#ifdef AESNI
|
||||
ECBEncryption m_LayerEncryption;
|
||||
#else
|
||||
CBCEncryption m_LayerEncryption;
|
||||
#endif
|
||||
};
|
||||
|
||||
class TunnelDecryption { // with double IV encryption
|
||||
public:
|
||||
|
||||
void SetKeys (const AESKey& layerKey, const AESKey& ivKey)
|
||||
{
|
||||
m_LayerDecryption.SetKey (layerKey);
|
||||
m_IVDecryption.SetKey (ivKey);
|
||||
}
|
||||
|
||||
void Decrypt (const uint8_t * in, uint8_t * out); // 1024 bytes (16 IV + 1008 data)
|
||||
|
||||
private:
|
||||
|
||||
ECBDecryption m_IVDecryption;
|
||||
#ifdef AESNI
|
||||
ECBDecryption m_LayerDecryption;
|
||||
#else
|
||||
CBCDecryption m_LayerDecryption;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // crypto
|
||||
} // i2p
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue