Browse Source

Merge branch 'master' of https://github.com/chertov/i2pd

pull/12/head
chertov 11 years ago
parent
commit
651ee9cd8f
  1. 85
      CryptoConst.h
  2. 6
      RouterContext.cpp
  3. 16
      RouterInfo.cpp
  4. 3
      TunnelConfig.h

85
CryptoConst.h

@ -9,40 +9,65 @@ namespace crypto
{ {
// DH // DH
const CryptoPP::Integer elgp ( inline const CryptoPP::Integer& get_elgp ()
"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" {
"29024E088A67CC74020BBEA63B139B22514A08798E3404DD" static const CryptoPP::Integer elgp_ (
"EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
"E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" "29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245"
"C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED"
"83655D23DCA3AD961C62F356208552BB9ED529077096966D" "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D"
"670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F"
"E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" "83655D23DCA3AD961C62F356208552BB9ED529077096966D"
"DE2BCBF6955817183995497CEA956AE515D2261898FA0510" "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B"
"15728E5A8AACAA68FFFFFFFFFFFFFFFF" "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9"
"h"); "DE2BCBF6955817183995497CEA956AE515D2261898FA0510"
"15728E5A8AACAA68FFFFFFFFFFFFFFFF"
"h");
return elgp_;
}
#define elgp get_elgp()
const CryptoPP::Integer elgg (2); inline const CryptoPP::Integer& get_elgg ()
{
static const CryptoPP::Integer elgg_ (2);
return elgg_;
}
#define elgg get_elgg()
// DSA // DSA
const CryptoPP::Integer dsap ( inline const CryptoPP::Integer& get_dsap ()
"9c05b2aa960d9b97b8931963c9cc9e8c3026e9b8ed92fad0a69cc886d5bf8015fcadae31" {
"a0ad18fab3f01b00a358de237655c4964afaa2b337e96ad316b9fb1cc564b5aec5b69a9f" static const CryptoPP::Integer dsap_ (
"f6c3e4548707fef8503d91dd8602e867e6d35d2235c1869ce2479c3b9d5401de04e0727f" "9c05b2aa960d9b97b8931963c9cc9e8c3026e9b8ed92fad0a69cc886d5bf8015fcadae31"
"b33d6511285d4cf29538d9e3b6051f5b22cc1c93" "a0ad18fab3f01b00a358de237655c4964afaa2b337e96ad316b9fb1cc564b5aec5b69a9f"
"h"); "f6c3e4548707fef8503d91dd8602e867e6d35d2235c1869ce2479c3b9d5401de04e0727f"
"b33d6511285d4cf29538d9e3b6051f5b22cc1c93"
const CryptoPP::Integer dsaq ( "h");
"a5dfc28fef4ca1e286744cd8eed9d29d684046b7" return dsap_;
"h"); }
#define dsap get_dsap()
inline const CryptoPP::Integer& get_dsaq ()
{
static const CryptoPP::Integer dsaq_ (
"a5dfc28fef4ca1e286744cd8eed9d29d684046b7"
"h");
return dsaq_;
}
#define dsaq get_dsaq()
const CryptoPP::Integer dsag ( inline const CryptoPP::Integer& get_dsag ()
"c1f4d27d40093b429e962d7223824e0bbc47e7c832a39236fc683af84889581075ff9082" {
"ed32353d4374d7301cda1d23c431f4698599dda02451824ff369752593647cc3ddc197de" static const CryptoPP::Integer dsag_ (
"985e43d136cdcfc6bd5409cd2f450821142a5e6f8eb1c3ab5d0484b8129fcf17bce4f7f3" "c1f4d27d40093b429e962d7223824e0bbc47e7c832a39236fc683af84889581075ff9082"
"3321c3cb3dbb14a905e7b2b3e93be4708cbcc82" "ed32353d4374d7301cda1d23c431f4698599dda02451824ff369752593647cc3ddc197de"
"h"); "985e43d136cdcfc6bd5409cd2f450821142a5e6f8eb1c3ab5d0484b8129fcf17bce4f7f3"
"3321c3cb3dbb14a905e7b2b3e93be4708cbcc82"
"h");
return dsag_;
}
#define dsag get_dsag()
} }
} }

6
RouterContext.cpp

@ -60,7 +60,7 @@ namespace i2p
bool RouterContext::Load () bool RouterContext::Load ()
{ {
std::ifstream fk (ROUTER_KEYS); std::ifstream fk (ROUTER_KEYS, std::ios::binary);
if (!fk.is_open ()) return false; if (!fk.is_open ()) return false;
fk.read ((char *)&m_Keys, sizeof (m_Keys)); fk.read ((char *)&m_Keys, sizeof (m_Keys));
@ -74,10 +74,10 @@ namespace i2p
void RouterContext::Save () void RouterContext::Save ()
{ {
std::ofstream fk (ROUTER_KEYS); std::ofstream fk (ROUTER_KEYS, std::ios::binary);
fk.write ((char *)&m_Keys, sizeof (m_Keys)); fk.write ((char *)&m_Keys, sizeof (m_Keys));
std::ofstream fi (ROUTER_INFO); std::ofstream fi(ROUTER_INFO, std::ios::binary);
fi.write ((char *)m_RouterInfo.GetBuffer (), m_RouterInfo.GetBufferLen ()); fi.write ((char *)m_RouterInfo.GetBuffer (), m_RouterInfo.GetBufferLen ());
} }
} }

16
RouterInfo.cpp

@ -41,7 +41,7 @@ namespace data
void RouterInfo::ReadFromFile (const char * filename) void RouterInfo::ReadFromFile (const char * filename)
{ {
std::ifstream s(filename); std::ifstream s(filename, std::ios::binary);
if (s.is_open ()) if (s.is_open ())
{ {
s.seekg (0,std::ios::end); s.seekg (0,std::ios::end);
@ -95,7 +95,7 @@ namespace data
size = be16toh (size); size = be16toh (size);
while (r < size) while (r < size)
{ {
char key[50], value[50]; char key[500], value[500];
r += ReadString (key, s); r += ReadString (key, s);
s.seekg (1, std::ios_base::cur); r++; // = s.seekg (1, std::ios_base::cur); r++; // =
r += ReadString (value, s); r += ReadString (value, s);
@ -117,7 +117,7 @@ namespace data
size = be16toh (size); size = be16toh (size);
while (r < size) while (r < size)
{ {
char key[50], value[50]; char key[500], value[500];
r += ReadString (key, s); r += ReadString (key, s);
s.seekg (1, std::ios_base::cur); r++; // = s.seekg (1, std::ios_base::cur); r++; // =
r += ReadString (value, s); r += ReadString (value, s);
@ -212,6 +212,16 @@ namespace data
{ {
uint8_t len; uint8_t len;
s.read ((char *)&len, 1); s.read ((char *)&len, 1);
//static int count_l = 0;
//count_l++;
//std::cout << count_l << " " << (int)len << std::endl;
//if (len > 40)
//{
// std::cout << (int)len << std::endl;
//}
s.read (str, len); s.read (str, len);
str[len] = 0; str[len] = 0;
return len+1; return len+1;

3
TunnelConfig.h

@ -115,8 +115,9 @@ namespace tunnel
while (hop) while (hop)
{ {
delete hop; auto tmp = hop;
hop = hop->next; hop = hop->next;
delete tmp;
} }
} }

Loading…
Cancel
Save