|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013-2020, The PurpleI2P Project |
|
|
|
|
* Copyright (c) 2013-2021, The PurpleI2P Project |
|
|
|
|
* |
|
|
|
|
* This file is part of Purple i2pd project and licensed under BSD3 |
|
|
|
|
* |
|
|
|
@ -21,7 +21,7 @@ namespace crypto
@@ -21,7 +21,7 @@ namespace crypto
|
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
virtual ~CryptoKeyEncryptor () {}; |
|
|
|
|
virtual void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx, bool zeroPadding) = 0; // 222 bytes data, 512/514 bytes encrypted
|
|
|
|
|
virtual void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx, bool zeroPadding) = 0; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class CryptoKeyDecryptor |
|
|
|
@ -29,7 +29,7 @@ namespace crypto
@@ -29,7 +29,7 @@ namespace crypto
|
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
virtual ~CryptoKeyDecryptor () {}; |
|
|
|
|
virtual bool Decrypt (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx, bool zeroPadding) = 0; // 512/514 bytes encrypted, 222 bytes data
|
|
|
|
|
virtual bool Decrypt (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx) = 0; |
|
|
|
|
virtual size_t GetPublicKeyLen () const = 0; // we need it to set key in LS2
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -39,7 +39,7 @@ namespace crypto
@@ -39,7 +39,7 @@ namespace crypto
|
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
ElGamalEncryptor (const uint8_t * pub); |
|
|
|
|
void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx, bool zeroPadding); |
|
|
|
|
void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx, bool zeroPadding) override; // 222 bytes data, 512/514 bytes encrypted
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
@ -51,8 +51,8 @@ namespace crypto
@@ -51,8 +51,8 @@ namespace crypto
|
|
|
|
|
public: |
|
|
|
|
|
|
|
|
|
ElGamalDecryptor (const uint8_t * priv); |
|
|
|
|
bool Decrypt (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx, bool zeroPadding); |
|
|
|
|
size_t GetPublicKeyLen () const { return 256; }; |
|
|
|
|
bool Decrypt (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx) override; // 514 bytes encrypted, 222 bytes data
|
|
|
|
|
size_t GetPublicKeyLen () const override { return 256; }; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
@ -67,7 +67,7 @@ namespace crypto
@@ -67,7 +67,7 @@ namespace crypto
|
|
|
|
|
|
|
|
|
|
ECIESP256Encryptor (const uint8_t * pub); |
|
|
|
|
~ECIESP256Encryptor (); |
|
|
|
|
void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx, bool zeroPadding); |
|
|
|
|
void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx, bool zeroPadding) override; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
@ -82,8 +82,8 @@ namespace crypto
@@ -82,8 +82,8 @@ namespace crypto
|
|
|
|
|
|
|
|
|
|
ECIESP256Decryptor (const uint8_t * priv); |
|
|
|
|
~ECIESP256Decryptor (); |
|
|
|
|
bool Decrypt (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx, bool zeroPadding); |
|
|
|
|
size_t GetPublicKeyLen () const { return 64; }; |
|
|
|
|
bool Decrypt (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx) override; |
|
|
|
|
size_t GetPublicKeyLen () const override { return 64; }; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
@ -101,7 +101,7 @@ namespace crypto
@@ -101,7 +101,7 @@ namespace crypto
|
|
|
|
|
|
|
|
|
|
ECIESGOSTR3410Encryptor (const uint8_t * pub); |
|
|
|
|
~ECIESGOSTR3410Encryptor (); |
|
|
|
|
void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx, bool zeroPadding); |
|
|
|
|
void Encrypt (const uint8_t * data, uint8_t * encrypted, BN_CTX * ctx, bool zeroPadding) override; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
@ -115,8 +115,8 @@ namespace crypto
@@ -115,8 +115,8 @@ namespace crypto
|
|
|
|
|
|
|
|
|
|
ECIESGOSTR3410Decryptor (const uint8_t * priv); |
|
|
|
|
~ECIESGOSTR3410Decryptor (); |
|
|
|
|
bool Decrypt (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx, bool zeroPadding); |
|
|
|
|
size_t GetPublicKeyLen () const { return 64; }; |
|
|
|
|
bool Decrypt (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx) override; |
|
|
|
|
size_t GetPublicKeyLen () const override { return 64; }; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
@ -133,7 +133,7 @@ namespace crypto
@@ -133,7 +133,7 @@ namespace crypto
|
|
|
|
|
|
|
|
|
|
ECIESX25519AEADRatchetEncryptor (const uint8_t * pub); |
|
|
|
|
~ECIESX25519AEADRatchetEncryptor () {}; |
|
|
|
|
void Encrypt (const uint8_t *, uint8_t * pub, BN_CTX *, bool); |
|
|
|
|
void Encrypt (const uint8_t *, uint8_t * pub, BN_CTX *, bool) override; |
|
|
|
|
// copies m_PublicKey to pub
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
@ -147,9 +147,9 @@ namespace crypto
@@ -147,9 +147,9 @@ namespace crypto
|
|
|
|
|
|
|
|
|
|
ECIESX25519AEADRatchetDecryptor (const uint8_t * priv, bool calculatePublic = false); |
|
|
|
|
~ECIESX25519AEADRatchetDecryptor () {}; |
|
|
|
|
bool Decrypt (const uint8_t * epub, uint8_t * sharedSecret, BN_CTX * ctx, bool zeroPadding); |
|
|
|
|
bool Decrypt (const uint8_t * epub, uint8_t * sharedSecret, BN_CTX * ctx) override; |
|
|
|
|
// agree with static and return in sharedSecret (32 bytes)
|
|
|
|
|
size_t GetPublicKeyLen () const { return 32; }; |
|
|
|
|
size_t GetPublicKeyLen () const override { return 32; }; |
|
|
|
|
const uint8_t * GetPubicKey () const { return m_StaticKeys.GetPublicKey (); }; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|