mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 11:17:49 +02:00
crypto key encryptor and decryptor
This commit is contained in:
parent
88ba494701
commit
9fa67b0e0a
2 changed files with 144 additions and 0 deletions
|
@ -8,6 +8,75 @@ namespace i2p
|
|||
{
|
||||
namespace crypto
|
||||
{
|
||||
class CryptoKeyEncryptor
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~CryptoKeyEncryptor () {};
|
||||
virtual void Encrypt (const uint8_t * data, uint8_t * encrypted); // 222 bytes data, 512 bytes encrypted
|
||||
};
|
||||
|
||||
class CryptoKeyDecryptor
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~CryptoKeyDecryptor () {};
|
||||
virtual void Decrypt (const uint8_t * encrypted, uint8_t * data); // 512 bytes encrypted, 222 bytes data
|
||||
};
|
||||
|
||||
class ElGamalEncryptor // for destination
|
||||
{
|
||||
public:
|
||||
|
||||
ElGamalEncryptor (const uint8_t * pub);
|
||||
void Encrypt (const uint8_t * data, uint8_t * encrypted);
|
||||
|
||||
private:
|
||||
|
||||
uint8_t m_PublicKey[256];
|
||||
};
|
||||
|
||||
class ElGamalDecryptor // for destination
|
||||
{
|
||||
public:
|
||||
|
||||
ElGamalDecryptor (const uint8_t * priv);
|
||||
void Decrypt (const uint8_t * encrypted, uint8_t * data);
|
||||
|
||||
private:
|
||||
|
||||
uint8_t m_PrivateKey[256];
|
||||
};
|
||||
|
||||
class ECIESP256Encryptor
|
||||
{
|
||||
public:
|
||||
|
||||
ECIESP256Encryptor (const uint8_t * pub);
|
||||
~ECIESP256Encryptor ();
|
||||
void Encrypt (const uint8_t * data, uint8_t * encrypted);
|
||||
|
||||
private:
|
||||
|
||||
EC_GROUP * m_Curve;
|
||||
EC_POINT * m_PublicKey;
|
||||
};
|
||||
|
||||
|
||||
class ECIESP256Decryptor
|
||||
{
|
||||
public:
|
||||
|
||||
ECIESP256Decryptor (const uint8_t * priv);
|
||||
~ECIESP256Decryptor ();
|
||||
void Decrypt (const uint8_t * encrypted, uint8_t * data);
|
||||
|
||||
private:
|
||||
|
||||
EC_GROUP * m_Curve;
|
||||
BIGNUM * m_PrivateKey;
|
||||
};
|
||||
|
||||
void CreateECIESP256RandomKeys (uint8_t * priv, uint8_t * pub);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue