Browse Source

Move base64 to util/

pull/239/head
EinMByte 10 years ago
parent
commit
89d3d17b28
  1. 4
      AddressBook.cpp
  2. 2
      AddressBook.h
  3. 1
      Daemon.cpp
  4. 2
      HTTPServer.cpp
  5. 1
      I2NPProtocol.cpp
  6. 1
      I2PTunnel.cpp
  7. 10
      Identity.cpp
  8. 10
      Identity.h
  9. 10
      NetDb.cpp
  10. 4
      Profiling.cpp
  11. 10
      RouterInfo.cpp
  12. 6
      SAM.cpp
  13. 4
      filelist.mk
  14. 4
      transport/NTCPSession.cpp
  15. 2
      transport/SSU.cpp
  16. 2
      transport/SSUData.cpp
  17. 2
      transport/SSUSession.cpp
  18. 2
      util/base64.cpp
  19. 2
      util/base64.h

4
AddressBook.cpp

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include <cryptopp/osrng.h>
#include "base64.h"
#include "util/base64.h"
#include "util/util.h"
#include "Identity.h"
#include "Log.h"
@ -215,7 +215,7 @@ namespace client @@ -215,7 +215,7 @@ namespace client
auto pos = address.find(".b32.i2p");
if (pos != std::string::npos)
{
Base32ToByteStream (address.c_str(), pos, ident, 32);
i2p::util::Base32ToByteStream (address.c_str(), pos, ident, 32);
return true;
}
else

2
AddressBook.h

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
#include <iostream>
#include <mutex>
#include <boost/asio.hpp>
#include "base64.h"
#include "util/base64.h"
#include "util/util.h"
#include "Identity.h"
#include "Log.h"

1
Daemon.cpp

@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
#include "Daemon.h"
#include "Log.h"
#include "base64.h"
#include "version.h"
#include "transport/Transports.h"
#include "transport/NTCPSession.h"

2
HTTPServer.cpp

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "base64.h"
#include "util/base64.h"
#include "Log.h"
#include "Tunnel.h"
#include "TransitTunnel.h"

1
I2NPProtocol.cpp

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
#include "RouterContext.h"
#include "NetDb.h"
#include "Tunnel.h"
#include "base64.h"
#include "transport/Transports.h"
#include "Garlic.h"
#include "I2NPProtocol.h"

1
I2PTunnel.cpp

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
#include <cassert>
#include "base64.h"
#include "Log.h"
#include "Destination.h"
#include "ClientContext.h"

10
Identity.cpp

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
#include <cryptopp/sha.h>
#include <cryptopp/osrng.h>
#include <cryptopp/dsa.h>
#include "base64.h"
#include "util/base64.h"
#include "CryptoConst.h"
#include "ElGamal.h"
#include "RouterContext.h"
@ -237,7 +237,7 @@ namespace data @@ -237,7 +237,7 @@ namespace data
size_t IdentityEx::FromBase64(const std::string& s)
{
uint8_t buf[1024];
auto len = Base64ToByteStream (s.c_str(), s.length(), buf, 1024);
auto len = i2p::util::Base64ToByteStream (s.c_str(), s.length(), buf, 1024);
return FromBuffer (buf, len);
}
@ -246,7 +246,7 @@ namespace data @@ -246,7 +246,7 @@ namespace data
uint8_t buf[1024];
char str[1536];
size_t l = ToBuffer (buf, 1024);
size_t l1 = i2p::data::ByteStreamToBase64 (buf, l, str, 1536);
size_t l1 = i2p::util::ByteStreamToBase64 (buf, l, str, 1536);
str[l1] = 0;
return std::string (str);
}
@ -420,7 +420,7 @@ namespace data @@ -420,7 +420,7 @@ namespace data
size_t PrivateKeys::FromBase64(const std::string& s)
{
uint8_t * buf = new uint8_t[s.length ()];
size_t l = i2p::data::Base64ToByteStream (s.c_str (), s.length (), buf, s.length ());
size_t l = i2p::util::Base64ToByteStream (s.c_str (), s.length (), buf, s.length ());
size_t ret = FromBuffer (buf, l);
delete[] buf;
return ret;
@ -431,7 +431,7 @@ namespace data @@ -431,7 +431,7 @@ namespace data
uint8_t * buf = new uint8_t[GetFullLen ()];
char * str = new char[GetFullLen ()*2];
size_t l = ToBuffer (buf, GetFullLen ());
size_t l1 = i2p::data::ByteStreamToBase64 (buf, l, str, GetFullLen ()*2);
size_t l1 = i2p::util::ByteStreamToBase64 (buf, l, str, GetFullLen ()*2);
str[l1] = 0;
delete[] buf;
std::string ret(str);

10
Identity.h

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
#include <string.h>
#include <string>
#include <memory>
#include "base64.h"
#include "util/base64.h"
#include "ElGamal.h"
#include "Signature.h"
@ -51,7 +51,7 @@ namespace data @@ -51,7 +51,7 @@ namespace data
std::string ToBase64 () const
{
char str[sz*2];
int l = i2p::data::ByteStreamToBase64 (m_Buf, sz, str, sz*2);
int l = i2p::util::ByteStreamToBase64 (m_Buf, sz, str, sz*2);
str[l] = 0;
return std::string (str);
}
@ -59,19 +59,19 @@ namespace data @@ -59,19 +59,19 @@ namespace data
std::string ToBase32 () const
{
char str[sz*2];
int l = i2p::data::ByteStreamToBase32 (m_Buf, sz, str, sz*2);
int l = i2p::util::ByteStreamToBase32 (m_Buf, sz, str, sz*2);
str[l] = 0;
return std::string (str);
}
void FromBase32 (const std::string& s)
{
i2p::data::Base32ToByteStream (s.c_str (), s.length (), m_Buf, sz);
i2p::util::Base32ToByteStream (s.c_str (), s.length (), m_Buf, sz);
}
void FromBase64 (const std::string& s)
{
i2p::data::Base64ToByteStream (s.c_str (), s.length (), m_Buf, sz);
i2p::util::Base64ToByteStream (s.c_str (), s.length (), m_Buf, sz);
}
private:

10
NetDb.cpp

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
#include <vector>
#include <boost/asio.hpp>
#include <cryptopp/gzip.h>
#include "base64.h"
#include "util/base64.h"
#include "Log.h"
#include "util/Timestamp.h"
#include "I2NPProtocol.h"
@ -263,7 +263,7 @@ namespace data @@ -263,7 +263,7 @@ namespace data
}
// list of chars might appear in base64 string
const char * chars = GetBase64SubstitutionTable (); // 64 bytes
const char * chars = i2p::util::GetBase64SubstitutionTable (); // 64 bytes
boost::filesystem::path suffix;
for (int i = 0; i < 64; i++)
{
@ -544,7 +544,7 @@ namespace data @@ -544,7 +544,7 @@ namespace data
{
const uint8_t * buf = msg->GetPayload ();
char key[48];
int l = i2p::data::ByteStreamToBase64 (buf, 32, key, 48);
int l = i2p::util::ByteStreamToBase64 (buf, 32, key, 48);
key[l] = 0;
int num = buf[32]; // num
LogPrint ("DatabaseSearchReply for ", key, " num=", num);
@ -613,7 +613,7 @@ namespace data @@ -613,7 +613,7 @@ namespace data
{
const uint8_t * router = buf + 33 + i*32;
char peerHash[48];
int l1 = i2p::data::ByteStreamToBase64 (router, 32, peerHash, 48);
int l1 = i2p::util::ByteStreamToBase64 (router, 32, peerHash, 48);
peerHash[l1] = 0;
LogPrint (i,": ", peerHash);
@ -639,7 +639,7 @@ namespace data @@ -639,7 +639,7 @@ namespace data
return;
}
char key[48];
int l = i2p::data::ByteStreamToBase64 (buf, 32, key, 48);
int l = i2p::util::ByteStreamToBase64 (buf, 32, key, 48);
key[l] = 0;
uint8_t flag = buf[64];
LogPrint ("DatabaseLookup for ", key, " recieved flags=", (int)flag);

4
Profiling.cpp

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#include <boost/filesystem.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include "base64.h"
#include "util/base64.h"
#include "util/util.h"
#include "Profiling.h"
@ -52,7 +52,7 @@ namespace data @@ -52,7 +52,7 @@ namespace data
LogPrint (eLogError, "Failed to create directory ", path);
return;
}
const char * chars = GetBase64SubstitutionTable (); // 64 bytes
const char * chars = i2p::util::GetBase64SubstitutionTable (); // 64 bytes
for (int i = 0; i < 64; i++)
{
auto path1 = path / (std::string ("p") + chars[i]);

10
RouterInfo.cpp

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
#include <cryptopp/sha.h>
#include <cryptopp/dsa.h>
#include "CryptoConst.h"
#include "base64.h"
#include "util/base64.h"
#include "util/Timestamp.h"
#include "Log.h"
#include "RouterInfo.h"
@ -176,7 +176,7 @@ namespace data @@ -176,7 +176,7 @@ namespace data
else if (!strcmp (key, "mtu"))
address.mtu = boost::lexical_cast<int>(value);
else if (!strcmp (key, "key"))
Base64ToByteStream (value, strlen (value), address.key, 32);
i2p::util::Base64ToByteStream (value, strlen (value), address.key, 32);
else if (!strcmp (key, "caps"))
ExtractCaps (value);
else if (key[0] == 'i')
@ -199,7 +199,7 @@ namespace data @@ -199,7 +199,7 @@ namespace data
else if (!strcmp (key, "itag"))
introducer.iTag = boost::lexical_cast<uint32_t>(value);
else if (!strcmp (key, "ikey"))
Base64ToByteStream (value, strlen (value), introducer.iKey, 32);
i2p::util::Base64ToByteStream (value, strlen (value), introducer.iKey, 32);
}
}
if (isValidAddress)
@ -344,7 +344,7 @@ namespace data @@ -344,7 +344,7 @@ namespace data
WriteString ("ikey" + boost::lexical_cast<std::string>(i), properties);
properties << '=';
char value[64];
size_t l = ByteStreamToBase64 (introducer.iKey, 32, value, 64);
size_t l = i2p::util::ByteStreamToBase64 (introducer.iKey, 32, value, 64);
value[l] = 0;
WriteString (value, properties);
properties << ';';
@ -373,7 +373,7 @@ namespace data @@ -373,7 +373,7 @@ namespace data
WriteString ("key", properties);
properties << '=';
char value[64];
size_t l = ByteStreamToBase64 (address.key, 32, value, 64);
size_t l = i2p::util::ByteStreamToBase64 (address.key, 32, value, 64);
value[l] = 0;
WriteString (value, properties);
properties << ';';

6
SAM.cpp

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
#include <stdlib.h>
#endif
#include <boost/lexical_cast.hpp>
#include "base64.h"
#include "util/base64.h"
#include "Identity.h"
#include "Log.h"
#include "Destination.h"
@ -319,7 +319,7 @@ namespace client @@ -319,7 +319,7 @@ namespace client
uint8_t buf[1024];
char priv[1024];
size_t l = m_Session->localDestination->GetPrivateKeys ().ToBuffer (buf, 1024);
size_t l1 = i2p::data::ByteStreamToBase64 (buf, l, priv, 1024);
size_t l1 = i2p::util::ByteStreamToBase64 (buf, l, priv, 1024);
priv[l1] = 0;
#ifdef _MSC_VER
size_t l2 = sprintf_s (m_Buffer, SAM_SOCKET_BUFFER_SIZE, SAM_SESSION_CREATE_REPLY_OK, priv);
@ -632,7 +632,7 @@ namespace client @@ -632,7 +632,7 @@ namespace client
// send remote peer address
uint8_t ident[1024];
size_t l = stream->GetRemoteIdentity ().ToBuffer (ident, 1024);
size_t l1 = i2p::data::ByteStreamToBase64 (ident, l, (char *)m_StreamBuffer, SAM_SOCKET_BUFFER_SIZE);
size_t l1 = i2p::util::ByteStreamToBase64 (ident, l, (char *)m_StreamBuffer, SAM_SOCKET_BUFFER_SIZE);
m_StreamBuffer[l1] = '\n';
HandleI2PReceive (boost::system::error_code (), l1 +1); // we send identity like it has been received from stream
}

4
filelist.mk

@ -1,12 +1,12 @@ @@ -1,12 +1,12 @@
COMMON_SRC = \
transport/NTCPSession.cpp transport/SSU.cpp transport/SSUSession.cpp \
transport/SSUData.cpp transport/Transports.cpp \
util/util.cpp \
util/util.cpp util/base64.cpp \
CryptoConst.cpp Datagram.cpp Garlic.cpp I2NPProtocol.cpp LeaseSet.cpp \
Log.cpp NetDb.cpp NetDbRequests.cpp Profiling.cpp Reseed.cpp \
RouterContext.cpp RouterInfo.cpp Signature.cpp Streaming.cpp Identity.cpp \
TransitTunnel.cpp Tunnel.cpp TunnelEndpoint.cpp TunnelPool.cpp \
TunnelGateway.cpp Destination.cpp UPnP.cpp aes.cpp base64.cpp
TunnelGateway.cpp Destination.cpp UPnP.cpp aes.cpp
ifeq ($(UNAME),Darwin)

4
transport/NTCPSession.cpp

@ -3,9 +3,9 @@ @@ -3,9 +3,9 @@
#include "I2PEndian.h"
#include <cryptopp/dh.h>
#include <cryptopp/adler32.h>
#include "base64.h"
#include "util/base64.h"
#include "Log.h"
#include "Timestamp.h"
#include "util/Timestamp.h"
#include "CryptoConst.h"
#include "I2NPProtocol.h"
#include "RouterContext.h"

2
transport/SSU.cpp

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#include <string.h>
#include <boost/bind.hpp>
#include "Log.h"
#include "Timestamp.h"
#include "util/Timestamp.h"
#include "RouterContext.h"
#include "NetDb.h"
#include "SSU.h"

2
transport/SSUData.cpp

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#include <stdlib.h>
#include <boost/bind.hpp>
#include "Log.h"
#include "Timestamp.h"
#include "util/Timestamp.h"
#include "NetDb.h"
#include "SSU.h"
#include "SSUData.h"

2
transport/SSUSession.cpp

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
#include <cryptopp/sha.h>
#include "CryptoConst.h"
#include "Log.h"
#include "Timestamp.h"
#include "util/Timestamp.h"
#include "RouterContext.h"
#include "Transports.h"
#include "SSU.h"

2
base64.cpp → util/base64.cpp

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
namespace i2p
{
namespace data
namespace util
{
static void iT64Build(void);

2
base64.h → util/base64.h

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
namespace i2p
{
namespace data
namespace util
{
Loading…
Cancel
Save