|
|
@ -187,7 +187,8 @@ namespace garlic |
|
|
|
RAND_bytes (elGamal.preIV, 32); // Pre-IV
|
|
|
|
RAND_bytes (elGamal.preIV, 32); // Pre-IV
|
|
|
|
uint8_t iv[32]; // IV is first 16 bytes
|
|
|
|
uint8_t iv[32]; // IV is first 16 bytes
|
|
|
|
SHA256(elGamal.preIV, 32, iv); |
|
|
|
SHA256(elGamal.preIV, 32, iv); |
|
|
|
i2p::crypto::ElGamalEncrypt (m_Destination->GetEncryptionPublicKey (), (uint8_t *)&elGamal, buf, true); |
|
|
|
i2p::crypto::ElGamalEncrypt (m_Destination->GetEncryptionPublicKey (), |
|
|
|
|
|
|
|
(uint8_t *)&elGamal, buf, m_Owner->GetBNContext (), true); |
|
|
|
m_Encryption.SetIV (iv); |
|
|
|
m_Encryption.SetIV (iv); |
|
|
|
buf += 514; |
|
|
|
buf += 514; |
|
|
|
len += 514; |
|
|
|
len += 514; |
|
|
@ -389,8 +390,14 @@ namespace garlic |
|
|
|
return size; |
|
|
|
return size; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GarlicDestination::GarlicDestination (): m_NumTags (32) // 32 tags by default
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_Ctx = BN_CTX_new (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GarlicDestination::~GarlicDestination () |
|
|
|
GarlicDestination::~GarlicDestination () |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
BN_CTX_free (m_Ctx); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void GarlicDestination::CleanUp () |
|
|
|
void GarlicDestination::CleanUp () |
|
|
@ -446,7 +453,7 @@ namespace garlic |
|
|
|
{ |
|
|
|
{ |
|
|
|
// tag not found. Use ElGamal
|
|
|
|
// tag not found. Use ElGamal
|
|
|
|
ElGamalBlock elGamal; |
|
|
|
ElGamalBlock elGamal; |
|
|
|
if (length >= 514 && i2p::crypto::ElGamalDecrypt (GetEncryptionPrivateKey (), buf, (uint8_t *)&elGamal, true)) |
|
|
|
if (length >= 514 && i2p::crypto::ElGamalDecrypt (GetEncryptionPrivateKey (), buf, (uint8_t *)&elGamal, m_Ctx, true)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto decryption = std::make_shared<i2p::crypto::CBCDecryption>(); |
|
|
|
auto decryption = std::make_shared<i2p::crypto::CBCDecryption>(); |
|
|
|
decryption->SetKey (elGamal.sessionKey); |
|
|
|
decryption->SetKey (elGamal.sessionKey); |
|
|
|