mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-31 09:04:14 +00:00
Merge remote-tracking branch 'purple/openssl'
This commit is contained in:
commit
bc0aed186e
@ -41,6 +41,8 @@ namespace config {
|
|||||||
("datadir", value<std::string>()->default_value(""), "Path to storage of i2pd data (RI, keys, peer profiles, ...)")
|
("datadir", value<std::string>()->default_value(""), "Path to storage of i2pd data (RI, keys, peer profiles, ...)")
|
||||||
("host", value<std::string>()->default_value("0.0.0.0"), "External IP")
|
("host", value<std::string>()->default_value("0.0.0.0"), "External IP")
|
||||||
("ifname", value<std::string>()->default_value(""), "Network interface to bind to")
|
("ifname", value<std::string>()->default_value(""), "Network interface to bind to")
|
||||||
|
("ifname4", value<std::string>()->default_value(""), "Network interface to bind to for ipv4")
|
||||||
|
("ifname6", value<std::string>()->default_value(""), "Network interface to bind to for ipv6")
|
||||||
("nat", value<bool>()->zero_tokens()->default_value(true), "Should we assume we are behind NAT?")
|
("nat", value<bool>()->zero_tokens()->default_value(true), "Should we assume we are behind NAT?")
|
||||||
("port", value<uint16_t>()->default_value(0), "Port to listen for incoming connections (default: auto)")
|
("port", value<uint16_t>()->default_value(0), "Port to listen for incoming connections (default: auto)")
|
||||||
("ipv4", value<bool>()->zero_tokens()->default_value(true), "Enable communication through ipv4")
|
("ipv4", value<bool>()->zero_tokens()->default_value(true), "Enable communication through ipv4")
|
||||||
@ -59,7 +61,7 @@ namespace config {
|
|||||||
("close", value<std::string>()->default_value("ask"), "Action on close: minimize, exit, ask") // TODO: add custom validator or something
|
("close", value<std::string>()->default_value("ask"), "Action on close: minimize, exit, ask") // TODO: add custom validator or something
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
options_description limits("Limits options");
|
options_description limits("Limits options");
|
||||||
limits.add_options()
|
limits.add_options()
|
||||||
("limits.coresize", value<uint32_t>()->default_value(0), "Maximum size of corefile in Kb (0 - use system limit)")
|
("limits.coresize", value<uint32_t>()->default_value(0), "Maximum size of corefile in Kb (0 - use system limit)")
|
||||||
@ -193,7 +195,7 @@ namespace config {
|
|||||||
("trust.family", value<std::string>()->default_value(""), "Router Familiy to trust for first hops")
|
("trust.family", value<std::string>()->default_value(""), "Router Familiy to trust for first hops")
|
||||||
("trust.routers", value<std::string>()->default_value(""), "Only Connect to these routers")
|
("trust.routers", value<std::string>()->default_value(""), "Only Connect to these routers")
|
||||||
("trust.hidden", value<bool>()->default_value(false), "Should we hide our router from other routers?");
|
("trust.hidden", value<bool>()->default_value(false), "Should we hide our router from other routers?");
|
||||||
|
|
||||||
options_description websocket("Websocket Options");
|
options_description websocket("Websocket Options");
|
||||||
websocket.add_options()
|
websocket.add_options()
|
||||||
("websockets.enabled", value<bool>()->default_value(false), "enable websocket server")
|
("websockets.enabled", value<bool>()->default_value(false), "enable websocket server")
|
||||||
|
@ -308,12 +308,12 @@ namespace crypto
|
|||||||
BN_free (b1);
|
BN_free (b1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElGamalEncryption::Encrypt (const uint8_t * data, int len, uint8_t * encrypted, bool zeroPadding) const
|
void ElGamalEncryption::Encrypt (const uint8_t * data, uint8_t * encrypted, bool zeroPadding) const
|
||||||
{
|
{
|
||||||
// create m
|
// create m
|
||||||
uint8_t m[255];
|
uint8_t m[255];
|
||||||
m[0] = 0xFF;
|
m[0] = 0xFF;
|
||||||
memcpy (m+33, data, len);
|
memcpy (m+33, data, 222);
|
||||||
SHA256 (m+33, 222, m+1);
|
SHA256 (m+33, 222, m+1);
|
||||||
// calculate b = b1*m mod p
|
// calculate b = b1*m mod p
|
||||||
BIGNUM * b = BN_new ();
|
BIGNUM * b = BN_new ();
|
||||||
|
2
Crypto.h
2
Crypto.h
@ -54,7 +54,7 @@ namespace crypto
|
|||||||
ElGamalEncryption (const uint8_t * key);
|
ElGamalEncryption (const uint8_t * key);
|
||||||
~ElGamalEncryption ();
|
~ElGamalEncryption ();
|
||||||
|
|
||||||
void Encrypt (const uint8_t * data, int len, uint8_t * encrypted, bool zeroPadding = false) const;
|
void Encrypt (const uint8_t * data, uint8_t * encrypted, bool zeroPadding = false) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ 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);
|
||||||
m_ElGamalEncryption->Encrypt ((uint8_t *)&elGamal, sizeof(elGamal), buf, true);
|
m_ElGamalEncryption->Encrypt ((uint8_t *)&elGamal, buf, true);
|
||||||
m_Encryption.SetIV (iv);
|
m_Encryption.SetIV (iv);
|
||||||
buf += 514;
|
buf += 514;
|
||||||
len += 514;
|
len += 514;
|
||||||
|
@ -53,6 +53,8 @@ namespace i2p
|
|||||||
bool ipv6; i2p::config::GetOption("ipv6", ipv6);
|
bool ipv6; i2p::config::GetOption("ipv6", ipv6);
|
||||||
bool nat; i2p::config::GetOption("nat", nat);
|
bool nat; i2p::config::GetOption("nat", nat);
|
||||||
std::string ifname; i2p::config::GetOption("ifname", ifname);
|
std::string ifname; i2p::config::GetOption("ifname", ifname);
|
||||||
|
std::string ifname4; i2p::config::GetOption("ifname4", ifname4);
|
||||||
|
std::string ifname6; i2p::config::GetOption("ifname6", ifname6);
|
||||||
if (ipv4)
|
if (ipv4)
|
||||||
{
|
{
|
||||||
std::string host = "127.0.0.1";
|
std::string host = "127.0.0.1";
|
||||||
@ -61,6 +63,10 @@ namespace i2p
|
|||||||
else if (!nat && !ifname.empty())
|
else if (!nat && !ifname.empty())
|
||||||
/* bind to interface, we have no NAT so set external address too */
|
/* bind to interface, we have no NAT so set external address too */
|
||||||
host = i2p::util::net::GetInterfaceAddress(ifname, false).to_string(); // v4
|
host = i2p::util::net::GetInterfaceAddress(ifname, false).to_string(); // v4
|
||||||
|
|
||||||
|
if(ifname4.size())
|
||||||
|
host = i2p::util::net::GetInterfaceAddress(ifname4, false).to_string();
|
||||||
|
|
||||||
routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ());
|
routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ());
|
||||||
routerInfo.AddNTCPAddress (host.c_str(), port);
|
routerInfo.AddNTCPAddress (host.c_str(), port);
|
||||||
}
|
}
|
||||||
@ -71,9 +77,14 @@ namespace i2p
|
|||||||
i2p::config::GetOption("host", host);
|
i2p::config::GetOption("host", host);
|
||||||
else if (!ifname.empty())
|
else if (!ifname.empty())
|
||||||
host = i2p::util::net::GetInterfaceAddress(ifname, true).to_string(); // v6
|
host = i2p::util::net::GetInterfaceAddress(ifname, true).to_string(); // v6
|
||||||
|
|
||||||
|
if(ifname6.size())
|
||||||
|
host = i2p::util::net::GetInterfaceAddress(ifname6, true).to_string();
|
||||||
|
|
||||||
routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ());
|
routerInfo.AddSSUAddress (host.c_str(), port, routerInfo.GetIdentHash ());
|
||||||
routerInfo.AddNTCPAddress (host.c_str(), port);
|
routerInfo.AddNTCPAddress (host.c_str(), port);
|
||||||
}
|
}
|
||||||
|
|
||||||
routerInfo.SetCaps (i2p::data::RouterInfo::eReachable |
|
routerInfo.SetCaps (i2p::data::RouterInfo::eReachable |
|
||||||
i2p::data::RouterInfo::eSSUTesting | i2p::data::RouterInfo::eSSUIntroducer); // LR, BC
|
i2p::data::RouterInfo::eSSUTesting | i2p::data::RouterInfo::eSSUIntroducer); // LR, BC
|
||||||
routerInfo.SetProperty ("netId", std::to_string (m_NetID));
|
routerInfo.SetProperty ("netId", std::to_string (m_NetID));
|
||||||
|
@ -102,7 +102,7 @@ namespace tunnel
|
|||||||
htobe32buf (clearText + BUILD_REQUEST_RECORD_SEND_MSG_ID_OFFSET, replyMsgID);
|
htobe32buf (clearText + BUILD_REQUEST_RECORD_SEND_MSG_ID_OFFSET, replyMsgID);
|
||||||
RAND_bytes (clearText + BUILD_REQUEST_RECORD_PADDING_OFFSET, BUILD_REQUEST_RECORD_CLEAR_TEXT_SIZE - BUILD_REQUEST_RECORD_PADDING_OFFSET);
|
RAND_bytes (clearText + BUILD_REQUEST_RECORD_PADDING_OFFSET, BUILD_REQUEST_RECORD_CLEAR_TEXT_SIZE - BUILD_REQUEST_RECORD_PADDING_OFFSET);
|
||||||
i2p::crypto::ElGamalEncryption elGamalEncryption (ident->GetEncryptionPublicKey ());
|
i2p::crypto::ElGamalEncryption elGamalEncryption (ident->GetEncryptionPublicKey ());
|
||||||
elGamalEncryption.Encrypt (clearText, BUILD_REQUEST_RECORD_CLEAR_TEXT_SIZE, record + BUILD_REQUEST_RECORD_ENCRYPTED_OFFSET);
|
elGamalEncryption.Encrypt (clearText, record + BUILD_REQUEST_RECORD_ENCRYPTED_OFFSET);
|
||||||
memcpy (record + BUILD_REQUEST_RECORD_TO_PEER_OFFSET, (const uint8_t *)ident->GetIdentHash (), 16);
|
memcpy (record + BUILD_REQUEST_RECORD_TO_PEER_OFFSET, (const uint8_t *)ident->GetIdentHash (), 16);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user