From e90b0dd54f17e373544520b126d0768b11b149ab Mon Sep 17 00:00:00 2001 From: EinMByte Date: Mon, 27 Jul 2015 21:28:50 +0200 Subject: [PATCH 01/11] Update TODO. --- TODO | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index f7de0d33..0951dd0e 100644 --- a/TODO +++ b/TODO @@ -1,13 +1,16 @@ -Short-term refactoring: +Refactoring: - SSUSession:637, SSUSession:635 get rid of casting to SSUHeader - Identity.cpp:156 check for self asignment - -Long-term refactoring: - Rely on a library for TLS and SSL. - Move parsing code out of networking code, to allow better testing. + - Move streaming code to a separate directory. - Separate front-end code (SAM, BOB, ...) from the back-end. - Additions: - Write tests. - Add documentation. + - Create a specialized IRC tunnel (instead of just a generic ClientTunnel instance). + - Ban peers with unexpected / bad behaviour. + - EdDSA support. + - Return correct error codes in HTTPProxy. + - Modify web interface layout and use AJAX to update information. From 18ca8b9b97d598888e7c8f1ab563887b9746e841 Mon Sep 17 00:00:00 2001 From: EinMByte Date: Mon, 27 Jul 2015 22:17:31 +0200 Subject: [PATCH 02/11] Move SSU and NTCP to transport/. --- Daemon.cpp | 4 ++-- HTTPServer.cpp | 2 +- I2NPProtocol.cpp | 2 +- I2PControl.cpp | 2 +- Makefile | 3 +++ Makefile.bsd | 2 +- Makefile.linux | 2 +- Makefile.osx | 2 +- NetDb.cpp | 2 +- NetDbRequests.cpp | 2 +- TransitTunnel.cpp | 2 +- Tunnel.cpp | 2 +- TunnelEndpoint.cpp | 2 +- TunnelGateway.cpp | 2 +- TunnelPool.cpp | 2 +- api.cpp | 2 +- filelist.mk | 11 ++++++----- NTCPSession.cpp => transport/NTCPSession.cpp | 0 NTCPSession.h => transport/NTCPSession.h | 0 SSU.cpp => transport/SSU.cpp | 0 SSU.h => transport/SSU.h | 0 SSUData.cpp => transport/SSUData.cpp | 0 SSUData.h => transport/SSUData.h | 0 SSUSession.cpp => transport/SSUSession.cpp | 0 SSUSession.h => transport/SSUSession.h | 0 TransportSession.h => transport/TransportSession.h | 0 Transports.cpp => transport/Transports.cpp | 0 Transports.h => transport/Transports.h | 0 28 files changed, 25 insertions(+), 21 deletions(-) rename NTCPSession.cpp => transport/NTCPSession.cpp (100%) rename NTCPSession.h => transport/NTCPSession.h (100%) rename SSU.cpp => transport/SSU.cpp (100%) rename SSU.h => transport/SSU.h (100%) rename SSUData.cpp => transport/SSUData.cpp (100%) rename SSUData.h => transport/SSUData.h (100%) rename SSUSession.cpp => transport/SSUSession.cpp (100%) rename SSUSession.h => transport/SSUSession.h (100%) rename TransportSession.h => transport/TransportSession.h (100%) rename Transports.cpp => transport/Transports.cpp (100%) rename Transports.h => transport/Transports.h (100%) diff --git a/Daemon.cpp b/Daemon.cpp index 7ba7ccb3..81f597e1 100644 --- a/Daemon.cpp +++ b/Daemon.cpp @@ -5,8 +5,8 @@ #include "Log.h" #include "base64.h" #include "version.h" -#include "Transports.h" -#include "NTCPSession.h" +#include "transport/Transports.h" +#include "transport/NTCPSession.h" #include "RouterInfo.h" #include "RouterContext.h" #include "Tunnel.h" diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 3d656730..16ace2d8 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -5,7 +5,7 @@ #include "Log.h" #include "Tunnel.h" #include "TransitTunnel.h" -#include "Transports.h" +#include "transport/Transports.h" #include "NetDb.h" #include "I2PEndian.h" #include "Streaming.h" diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index 82e7a0be..28821240 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -8,7 +8,7 @@ #include "NetDb.h" #include "Tunnel.h" #include "base64.h" -#include "Transports.h" +#include "transport/Transports.h" #include "Garlic.h" #include "I2NPProtocol.h" diff --git a/I2PControl.cpp b/I2PControl.cpp index 9c36b2ac..d94c28fe 100644 --- a/I2PControl.cpp +++ b/I2PControl.cpp @@ -15,7 +15,7 @@ #include "Daemon.h" #include "Tunnel.h" #include "Timestamp.h" -#include "Transports.h" +#include "transport/Transports.h" #include "version.h" namespace i2p diff --git a/Makefile b/Makefile index bc9d60fc..10670bbe 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ tests: mk_build_test_dir $(TESTS) mk_build_dir: mkdir -p obj + mkdir -p obj/transport mk_build_test_dir: mkdir -p obj/tests @@ -42,12 +43,14 @@ api: $(SHLIB) deps: @mkdir -p obj + @mkdir -p obj/transport @mkdir -p obj/tests $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) -MM *.cpp > $(DEPS) @sed -i -e '/\.o:/ s/^/obj\//' $(DEPS) obj/%.o : %.cpp @mkdir -p obj + @mkdir -p obj/transport @mkdir -p obj/tests $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) -c -o $@ $< diff --git a/Makefile.bsd b/Makefile.bsd index cd6948f3..26dc0e89 100644 --- a/Makefile.bsd +++ b/Makefile.bsd @@ -7,7 +7,7 @@ CXXFLAGS = -O2 ## -std=c++11. If you want to remove this variable please do so in a way that allows setting ## custom FLAGS to work at build-time. NEEDED_CXXFLAGS = -std=c++11 -INCFLAGS = -I/usr/include/ -I/usr/local/include/ +INCFLAGS = -I/usr/include/ -I/usr/local/include/ -I. LDFLAGS = -Wl,-rpath,/usr/local/lib -L/usr/local/lib LDLIBS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread LDTESTLIBS = -lboost_unit_test_framework diff --git a/Makefile.linux b/Makefile.linux index a2bfed17..21e1bb8c 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -1,5 +1,5 @@ CXXFLAGS = -g -Wall -INCFLAGS = +INCFLAGS = -I. ## NOTE: The NEEDED_CXXFLAGS are here so that custom CXXFLAGS can be specified at build time ## **without** overwriting the CXXFLAGS which we need in order to build. diff --git a/Makefile.osx b/Makefile.osx index fddf5a6b..502efce9 100644 --- a/Makefile.osx +++ b/Makefile.osx @@ -1,7 +1,7 @@ CXX = clang++ CXXFLAGS = -g -Wall -std=c++11 -DCRYPTOPP_DISABLE_ASM -DMAC_OSX #CXXFLAGS = -g -O2 -Wall -std=c++11 -DCRYPTOPP_DISABLE_ASM -INCFLAGS = -I/usr/local/include +INCFLAGS = -I/usr/local/include -I. LDFLAGS = -Wl,-rpath,/usr/local/lib -L/usr/local/lib LDLIBS = -lcryptopp -lboost_system -lboost_date_time -lboost_filesystem -lboost_regex -lboost_program_options -lpthread LDTESTLIBS = -lboost_unit_test_framework diff --git a/NetDb.cpp b/NetDb.cpp index 474f9d2d..97d813ba 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -9,7 +9,7 @@ #include "Timestamp.h" #include "I2NPProtocol.h" #include "Tunnel.h" -#include "Transports.h" +#include "transport/Transports.h" #include "RouterContext.h" #include "Garlic.h" #include "NetDb.h" diff --git a/NetDbRequests.cpp b/NetDbRequests.cpp index d3bff8ce..1dcbbf6a 100644 --- a/NetDbRequests.cpp +++ b/NetDbRequests.cpp @@ -1,6 +1,6 @@ #include "Log.h" #include "I2NPProtocol.h" -#include "Transports.h" +#include "transport/Transports.h" #include "NetDb.h" #include "NetDbRequests.h" diff --git a/TransitTunnel.cpp b/TransitTunnel.cpp index e042ee8a..ed298699 100644 --- a/TransitTunnel.cpp +++ b/TransitTunnel.cpp @@ -4,7 +4,7 @@ #include "RouterContext.h" #include "I2NPProtocol.h" #include "Tunnel.h" -#include "Transports.h" +#include "transport/Transports.h" #include "TransitTunnel.h" namespace i2p diff --git a/Tunnel.cpp b/Tunnel.cpp index 9e85b698..0eeab5b6 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -8,7 +8,7 @@ #include "Log.h" #include "Timestamp.h" #include "I2NPProtocol.h" -#include "Transports.h" +#include "transport/Transports.h" #include "NetDb.h" #include "Tunnel.h" diff --git a/TunnelEndpoint.cpp b/TunnelEndpoint.cpp index 24dd0bb1..e38701ca 100644 --- a/TunnelEndpoint.cpp +++ b/TunnelEndpoint.cpp @@ -3,7 +3,7 @@ #include "Log.h" #include "NetDb.h" #include "I2NPProtocol.h" -#include "Transports.h" +#include "transport/Transports.h" #include "RouterContext.h" #include "TunnelEndpoint.h" diff --git a/TunnelGateway.cpp b/TunnelGateway.cpp index 89f69da1..3ef7579a 100644 --- a/TunnelGateway.cpp +++ b/TunnelGateway.cpp @@ -3,7 +3,7 @@ #include #include "Log.h" #include "RouterContext.h" -#include "Transports.h" +#include "transport/Transports.h" #include "TunnelGateway.h" namespace i2p diff --git a/TunnelPool.cpp b/TunnelPool.cpp index 62d52075..4cdc94d5 100644 --- a/TunnelPool.cpp +++ b/TunnelPool.cpp @@ -5,7 +5,7 @@ #include "NetDb.h" #include "Timestamp.h" #include "Garlic.h" -#include "Transports.h" +#include "transport/Transports.h" #include "TunnelPool.h" namespace i2p diff --git a/api.cpp b/api.cpp index e5258195..0df091f0 100644 --- a/api.cpp +++ b/api.cpp @@ -2,7 +2,7 @@ #include #include "Log.h" #include "NetDb.h" -#include "Transports.h" +#include "transport/Transports.h" #include "Tunnel.h" #include "RouterContext.h" #include "Identity.h" diff --git a/filelist.mk b/filelist.mk index 5602970c..bbf10ba2 100644 --- a/filelist.mk +++ b/filelist.mk @@ -1,10 +1,11 @@ COMMON_SRC = \ + transport/NTCPSession.cpp transport/SSU.cpp transport/SSUSession.cpp \ + transport/SSUData.cpp transport/Transports.cpp \ CryptoConst.cpp Datagram.cpp Garlic.cpp I2NPProtocol.cpp LeaseSet.cpp \ - Log.cpp NTCPSession.cpp NetDb.cpp NetDbRequests.cpp Profiling.cpp \ - Reseed.cpp RouterContext.cpp RouterInfo.cpp Signature.cpp SSU.cpp \ - SSUSession.cpp SSUData.cpp Streaming.cpp Identity.cpp TransitTunnel.cpp \ - Transports.cpp Tunnel.cpp TunnelEndpoint.cpp TunnelPool.cpp TunnelGateway.cpp \ - Destination.cpp UPnP.cpp util.cpp aes.cpp base64.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 util.cpp aes.cpp base64.cpp ifeq ($(UNAME),Darwin) diff --git a/NTCPSession.cpp b/transport/NTCPSession.cpp similarity index 100% rename from NTCPSession.cpp rename to transport/NTCPSession.cpp diff --git a/NTCPSession.h b/transport/NTCPSession.h similarity index 100% rename from NTCPSession.h rename to transport/NTCPSession.h diff --git a/SSU.cpp b/transport/SSU.cpp similarity index 100% rename from SSU.cpp rename to transport/SSU.cpp diff --git a/SSU.h b/transport/SSU.h similarity index 100% rename from SSU.h rename to transport/SSU.h diff --git a/SSUData.cpp b/transport/SSUData.cpp similarity index 100% rename from SSUData.cpp rename to transport/SSUData.cpp diff --git a/SSUData.h b/transport/SSUData.h similarity index 100% rename from SSUData.h rename to transport/SSUData.h diff --git a/SSUSession.cpp b/transport/SSUSession.cpp similarity index 100% rename from SSUSession.cpp rename to transport/SSUSession.cpp diff --git a/SSUSession.h b/transport/SSUSession.h similarity index 100% rename from SSUSession.h rename to transport/SSUSession.h diff --git a/TransportSession.h b/transport/TransportSession.h similarity index 100% rename from TransportSession.h rename to transport/TransportSession.h diff --git a/Transports.cpp b/transport/Transports.cpp similarity index 100% rename from Transports.cpp rename to transport/Transports.cpp diff --git a/Transports.h b/transport/Transports.h similarity index 100% rename from Transports.h rename to transport/Transports.h From 3668c27db6d8c97a033c954a60ab7000c7f53782 Mon Sep 17 00:00:00 2001 From: EinMByte Date: Tue, 28 Jul 2015 18:37:06 +0200 Subject: [PATCH 03/11] Moved some files to util/ --- AddressBook.cpp | 2 +- AddressBook.h | 2 +- ClientContext.cpp | 2 +- Daemon.cpp | 2 +- DaemonLinux.cpp | 2 +- DaemonWin32.cpp | 4 ++-- Destination.cpp | 4 ++-- Garlic.cpp | 2 +- Garlic.h | 2 +- HTTPProxy.cpp | 2 +- I2NPProtocol.cpp | 2 +- I2PControl.cpp | 2 +- LeaseSet.cpp | 2 +- Log.h | 2 +- Makefile | 3 +++ NetDb.cpp | 4 ++-- NetDb.h | 2 +- Profiling.cpp | 2 +- Reseed.cpp | 2 +- RouterContext.cpp | 4 ++-- RouterInfo.cpp | 2 +- Streaming.cpp | 2 +- Tunnel.cpp | 2 +- Tunnel.h | 2 +- TunnelBase.h | 2 +- TunnelConfig.h | 2 +- TunnelPool.cpp | 2 +- UPnP.cpp | 2 +- UPnP.h | 2 +- api.cpp | 2 +- filelist.mk | 14 ++++++++------ LittleBigEndian.h => util/LittleBigEndian.h | 0 Queue.h => util/Queue.h | 0 Timestamp.h => util/Timestamp.h | 0 util.cpp => util/util.cpp | 0 util.h => util/util.h | 0 36 files changed, 44 insertions(+), 39 deletions(-) rename LittleBigEndian.h => util/LittleBigEndian.h (100%) rename Queue.h => util/Queue.h (100%) rename Timestamp.h => util/Timestamp.h (100%) rename util.cpp => util/util.cpp (100%) rename util.h => util/util.h (100%) diff --git a/AddressBook.cpp b/AddressBook.cpp index 6d2893d4..938c7d31 100644 --- a/AddressBook.cpp +++ b/AddressBook.cpp @@ -9,7 +9,7 @@ #include #include #include "base64.h" -#include "util.h" +#include "util/util.h" #include "Identity.h" #include "Log.h" #include "NetDb.h" diff --git a/AddressBook.h b/AddressBook.h index 0de1bbfd..64c4cc3a 100644 --- a/AddressBook.h +++ b/AddressBook.h @@ -9,7 +9,7 @@ #include #include #include "base64.h" -#include "util.h" +#include "util/util.h" #include "Identity.h" #include "Log.h" diff --git a/ClientContext.cpp b/ClientContext.cpp index 34e195e0..0c14e4df 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -2,7 +2,7 @@ #include #include #include -#include "util.h" +#include "util/util.h" #include "Log.h" #include "Identity.h" #include "ClientContext.h" diff --git a/Daemon.cpp b/Daemon.cpp index 81f597e1..2de1033d 100644 --- a/Daemon.cpp +++ b/Daemon.cpp @@ -12,7 +12,7 @@ #include "Tunnel.h" #include "NetDb.h" #include "Garlic.h" -#include "util.h" +#include "util/util.h" #include "Streaming.h" #include "Destination.h" #include "HTTPServer.h" diff --git a/DaemonLinux.cpp b/DaemonLinux.cpp index 15e30e2f..c4107d94 100644 --- a/DaemonLinux.cpp +++ b/DaemonLinux.cpp @@ -9,7 +9,7 @@ #include #include "Log.h" -#include "util.h" +#include "util/util.h" void handle_signal(int sig) diff --git a/DaemonWin32.cpp b/DaemonWin32.cpp index 6d8139de..e3220384 100644 --- a/DaemonWin32.cpp +++ b/DaemonWin32.cpp @@ -1,5 +1,5 @@ #include "Daemon.h" -#include "util.h" +#include "util/util.h" #include "Log.h" #ifdef _WIN32 @@ -80,4 +80,4 @@ namespace i2p } } -#endif \ No newline at end of file +#endif diff --git a/Destination.cpp b/Destination.cpp index 5f214ab6..f19dbe72 100644 --- a/Destination.cpp +++ b/Destination.cpp @@ -2,9 +2,9 @@ #include #include #include "Log.h" -#include "util.h" +#include "util/util.h" #include "ElGamal.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "NetDb.h" #include "AddressBook.h" #include "Destination.h" diff --git a/Garlic.cpp b/Garlic.cpp index 0fdc6473..96ea89d2 100644 --- a/Garlic.cpp +++ b/Garlic.cpp @@ -6,7 +6,7 @@ #include "I2NPProtocol.h" #include "Tunnel.h" #include "TunnelPool.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "Destination.h" #include "Garlic.h" diff --git a/Garlic.h b/Garlic.h index 7d02c21a..da90250f 100644 --- a/Garlic.h +++ b/Garlic.h @@ -12,7 +12,7 @@ #include "aes.h" #include "I2NPProtocol.h" #include "LeaseSet.h" -#include "Queue.h" +#include "util/Queue.h" #include "Identity.h" namespace i2p diff --git a/HTTPProxy.cpp b/HTTPProxy.cpp index 3902348e..03e322e9 100644 --- a/HTTPProxy.cpp +++ b/HTTPProxy.cpp @@ -5,7 +5,7 @@ #include #include #include "HTTPProxy.h" -#include "util.h" +#include "util/util.h" #include "Identity.h" #include "Streaming.h" #include "Destination.h" diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index 28821240..9e209f47 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -3,7 +3,7 @@ #include "I2PEndian.h" #include #include "ElGamal.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "RouterContext.h" #include "NetDb.h" #include "Tunnel.h" diff --git a/I2PControl.cpp b/I2PControl.cpp index d94c28fe..5b38ac51 100644 --- a/I2PControl.cpp +++ b/I2PControl.cpp @@ -14,7 +14,7 @@ #include "RouterContext.h" #include "Daemon.h" #include "Tunnel.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "transport/Transports.h" #include "version.h" diff --git a/LeaseSet.cpp b/LeaseSet.cpp index f648a44c..22bc4267 100644 --- a/LeaseSet.cpp +++ b/LeaseSet.cpp @@ -4,7 +4,7 @@ #include #include "CryptoConst.h" #include "Log.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "NetDb.h" #include "TunnelPool.h" #include "LeaseSet.h" diff --git a/Log.h b/Log.h index 4aa4ef57..9dc72637 100644 --- a/Log.h +++ b/Log.h @@ -7,7 +7,7 @@ #include #include #include -#include "Queue.h" +#include "util/Queue.h" enum LogLevel { diff --git a/Makefile b/Makefile index 10670bbe..f48357f2 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,7 @@ tests: mk_build_test_dir $(TESTS) mk_build_dir: mkdir -p obj mkdir -p obj/transport + mkdir -p obj/util mk_build_test_dir: mkdir -p obj/tests @@ -45,6 +46,7 @@ deps: @mkdir -p obj @mkdir -p obj/transport @mkdir -p obj/tests + @mkdir -p obj/util $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) -MM *.cpp > $(DEPS) @sed -i -e '/\.o:/ s/^/obj\//' $(DEPS) @@ -52,6 +54,7 @@ obj/%.o : %.cpp @mkdir -p obj @mkdir -p obj/transport @mkdir -p obj/tests + @mkdir -p obj/util $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) -c -o $@ $< # '-' is 'ignore if missing' on first run diff --git a/NetDb.cpp b/NetDb.cpp index 97d813ba..cbaebd0c 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -6,14 +6,14 @@ #include #include "base64.h" #include "Log.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "I2NPProtocol.h" #include "Tunnel.h" #include "transport/Transports.h" #include "RouterContext.h" #include "Garlic.h" #include "NetDb.h" -#include "util.h" +#include "util/util.h" using namespace i2p::transport; diff --git a/NetDb.h b/NetDb.h index d63fdc7c..31983919 100644 --- a/NetDb.h +++ b/NetDb.h @@ -9,7 +9,7 @@ #include #include #include -#include "Queue.h" +#include "util/Queue.h" #include "I2NPProtocol.h" #include "RouterInfo.h" #include "LeaseSet.h" diff --git a/Profiling.cpp b/Profiling.cpp index 5d3ad943..87ba687d 100644 --- a/Profiling.cpp +++ b/Profiling.cpp @@ -2,7 +2,7 @@ #include #include #include "base64.h" -#include "util.h" +#include "util/util.h" #include "Profiling.h" namespace i2p diff --git a/Reseed.cpp b/Reseed.cpp index 89fbde7c..4e3b4563 100644 --- a/Reseed.cpp +++ b/Reseed.cpp @@ -17,7 +17,7 @@ #include "Identity.h" #include "CryptoConst.h" #include "NetDb.h" -#include "util.h" +#include "util/util.h" namespace i2p diff --git a/RouterContext.cpp b/RouterContext.cpp index 0f6d4954..ac2358b1 100644 --- a/RouterContext.cpp +++ b/RouterContext.cpp @@ -4,10 +4,10 @@ #include #include "CryptoConst.h" #include "RouterContext.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "I2NPProtocol.h" #include "NetDb.h" -#include "util.h" +#include "util/util.h" #include "version.h" namespace i2p diff --git a/RouterInfo.cpp b/RouterInfo.cpp index f4dadeb7..2954139c 100644 --- a/RouterInfo.cpp +++ b/RouterInfo.cpp @@ -7,7 +7,7 @@ #include #include "CryptoConst.h" #include "base64.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "Log.h" #include "RouterInfo.h" #include "RouterContext.h" diff --git a/Streaming.cpp b/Streaming.cpp index 7e2d3bef..239bd661 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -3,7 +3,7 @@ #include "RouterInfo.h" #include "RouterContext.h" #include "Tunnel.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "Destination.h" #include "Streaming.h" diff --git a/Tunnel.cpp b/Tunnel.cpp index 0eeab5b6..9b13926f 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -6,7 +6,7 @@ #include #include "RouterContext.h" #include "Log.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "I2NPProtocol.h" #include "transport/Transports.h" #include "NetDb.h" diff --git a/Tunnel.h b/Tunnel.h index cc029b76..f724a023 100644 --- a/Tunnel.h +++ b/Tunnel.h @@ -9,7 +9,7 @@ #include #include #include -#include "Queue.h" +#include "util/Queue.h" #include "TunnelConfig.h" #include "TunnelPool.h" #include "TransitTunnel.h" diff --git a/TunnelBase.h b/TunnelBase.h index c7d6b536..ea57ea0a 100644 --- a/TunnelBase.h +++ b/TunnelBase.h @@ -3,7 +3,7 @@ #include #include -#include "Timestamp.h" +#include "util/Timestamp.h" #include "I2NPProtocol.h" #include "Identity.h" diff --git a/TunnelConfig.h b/TunnelConfig.h index d3ab5ed2..a77b560f 100644 --- a/TunnelConfig.h +++ b/TunnelConfig.h @@ -8,7 +8,7 @@ #include "aes.h" #include "RouterInfo.h" #include "RouterContext.h" -#include "Timestamp.h" +#include "util/Timestamp.h" namespace i2p { diff --git a/TunnelPool.cpp b/TunnelPool.cpp index 4cdc94d5..18ffd8ae 100644 --- a/TunnelPool.cpp +++ b/TunnelPool.cpp @@ -3,7 +3,7 @@ #include "CryptoConst.h" #include "Tunnel.h" #include "NetDb.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "Garlic.h" #include "transport/Transports.h" #include "TunnelPool.h" diff --git a/UPnP.cpp b/UPnP.cpp index 6773b514..e6601f77 100644 --- a/UPnP.cpp +++ b/UPnP.cpp @@ -18,7 +18,7 @@ #include "RouterContext.h" #include "UPnP.h" #include "NetDb.h" -#include "util.h" +#include "util/util.h" #include #include diff --git a/UPnP.h b/UPnP.h index e1211a29..468b5c0c 100644 --- a/UPnP.h +++ b/UPnP.h @@ -12,7 +12,7 @@ #include -#include "util.h" +#include "util/util.h" #define I2P_UPNP_TCP 1 #define I2P_UPNP_UDP 2 diff --git a/api.cpp b/api.cpp index 0df091f0..1d381ac7 100644 --- a/api.cpp +++ b/api.cpp @@ -7,7 +7,7 @@ #include "RouterContext.h" #include "Identity.h" #include "Destination.h" -#include "util.h" +#include "util/util.h" #include "api.h" namespace i2p diff --git a/filelist.mk b/filelist.mk index bbf10ba2..cac86830 100644 --- a/filelist.mk +++ b/filelist.mk @@ -1,29 +1,31 @@ COMMON_SRC = \ transport/NTCPSession.cpp transport/SSU.cpp transport/SSUSession.cpp \ transport/SSUData.cpp transport/Transports.cpp \ + util/util.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 util.cpp aes.cpp base64.cpp + TunnelGateway.cpp Destination.cpp UPnP.cpp aes.cpp base64.cpp ifeq ($(UNAME),Darwin) # This is needed on OS X for some reason I don't understand (yet). # Else will get linker error about unknown symbols. - torkel COMMON_SRC += \ - AddressBook.cpp BOB.cpp ClientContext.cpp Daemon.cpp I2PTunnel.cpp I2PService.cpp SAM.cpp SOCKS.cpp \ - UPnP.cpp HTTPServer.cpp HTTPProxy.cpp i2p.cpp DaemonLinux.cpp I2PControl.cpp + AddressBook.cpp BOB.cpp ClientContext.cpp Daemon.cpp I2PTunnel.cpp I2PService.cpp \ + SAM.cpp SOCKS.cpp UPnP.cpp HTTPProxy.cpp i2p.cpp DaemonLinux.cpp I2PControl.cpp \ + HTTPServer.cpp endif # also: Daemon{Linux,Win32}.cpp will be added later DAEMON_SRC = $(COMMON_SRC) \ - AddressBook.cpp BOB.cpp ClientContext.cpp Daemon.cpp I2PTunnel.cpp I2PService.cpp \ - SAM.cpp SOCKS.cpp HTTPServer.cpp HTTPProxy.cpp I2PControl.cpp i2p.cpp + AddressBook.cpp BOB.cpp ClientContext.cpp Daemon.cpp I2PTunnel.cpp I2PService.cpp \ + SAM.cpp SOCKS.cpp HTTPServer.cpp HTTPProxy.cpp I2PControl.cpp i2p.cpp LIB_SRC := $(COMMON_SRC) \ api.cpp TESTS_SRC := $(COMMON_SRC) \ - tests/Utility.cpp tests/Identity.cpp tests/Data.cpp + tests/Utility.cpp tests/Identity.cpp tests/Data.cpp diff --git a/LittleBigEndian.h b/util/LittleBigEndian.h similarity index 100% rename from LittleBigEndian.h rename to util/LittleBigEndian.h diff --git a/Queue.h b/util/Queue.h similarity index 100% rename from Queue.h rename to util/Queue.h diff --git a/Timestamp.h b/util/Timestamp.h similarity index 100% rename from Timestamp.h rename to util/Timestamp.h diff --git a/util.cpp b/util/util.cpp similarity index 100% rename from util.cpp rename to util/util.cpp diff --git a/util.h b/util/util.h similarity index 100% rename from util.h rename to util/util.h From 89d3d17b28e66812c3f4e2885fe38dba1dd1b7ba Mon Sep 17 00:00:00 2001 From: EinMByte Date: Tue, 28 Jul 2015 19:27:27 +0200 Subject: [PATCH 04/11] Move base64 to util/ --- AddressBook.cpp | 4 ++-- AddressBook.h | 2 +- Daemon.cpp | 1 - HTTPServer.cpp | 2 +- I2NPProtocol.cpp | 1 - I2PTunnel.cpp | 1 - Identity.cpp | 10 +++++----- Identity.h | 10 +++++----- NetDb.cpp | 10 +++++----- Profiling.cpp | 4 ++-- RouterInfo.cpp | 10 +++++----- SAM.cpp | 6 +++--- filelist.mk | 4 ++-- transport/NTCPSession.cpp | 4 ++-- transport/SSU.cpp | 2 +- transport/SSUData.cpp | 2 +- transport/SSUSession.cpp | 2 +- base64.cpp => util/base64.cpp | 2 +- base64.h => util/base64.h | 2 +- 19 files changed, 38 insertions(+), 41 deletions(-) rename base64.cpp => util/base64.cpp (99%) rename base64.h => util/base64.h (99%) diff --git a/AddressBook.cpp b/AddressBook.cpp index 938c7d31..ab39c952 100644 --- a/AddressBook.cpp +++ b/AddressBook.cpp @@ -8,7 +8,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "util/util.h" #include "Identity.h" #include "Log.h" @@ -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 diff --git a/AddressBook.h b/AddressBook.h index 64c4cc3a..6521953d 100644 --- a/AddressBook.h +++ b/AddressBook.h @@ -8,7 +8,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "util/util.h" #include "Identity.h" #include "Log.h" diff --git a/Daemon.cpp b/Daemon.cpp index 2de1033d..124f60cc 100644 --- a/Daemon.cpp +++ b/Daemon.cpp @@ -3,7 +3,6 @@ #include "Daemon.h" #include "Log.h" -#include "base64.h" #include "version.h" #include "transport/Transports.h" #include "transport/NTCPSession.h" diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 16ace2d8..e5d23c3d 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "Log.h" #include "Tunnel.h" #include "TransitTunnel.h" diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index 9e209f47..b59d0985 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -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" diff --git a/I2PTunnel.cpp b/I2PTunnel.cpp index 50ecd27c..a7e6a29b 100644 --- a/I2PTunnel.cpp +++ b/I2PTunnel.cpp @@ -1,5 +1,4 @@ #include -#include "base64.h" #include "Log.h" #include "Destination.h" #include "ClientContext.h" diff --git a/Identity.cpp b/Identity.cpp index 6f17eca6..0d1a37db 100644 --- a/Identity.cpp +++ b/Identity.cpp @@ -3,7 +3,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "CryptoConst.h" #include "ElGamal.h" #include "RouterContext.h" @@ -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 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 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 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); diff --git a/Identity.h b/Identity.h index 4502448b..7f36545d 100644 --- a/Identity.h +++ b/Identity.h @@ -5,7 +5,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "ElGamal.h" #include "Signature.h" @@ -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 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: diff --git a/NetDb.cpp b/NetDb.cpp index cbaebd0c..45236f40 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -4,7 +4,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "Log.h" #include "util/Timestamp.h" #include "I2NPProtocol.h" @@ -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 { 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 { 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 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); diff --git a/Profiling.cpp b/Profiling.cpp index 87ba687d..f2d1269b 100644 --- a/Profiling.cpp +++ b/Profiling.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "base64.h" +#include "util/base64.h" #include "util/util.h" #include "Profiling.h" @@ -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]); diff --git a/RouterInfo.cpp b/RouterInfo.cpp index 2954139c..b394d09d 100644 --- a/RouterInfo.cpp +++ b/RouterInfo.cpp @@ -6,7 +6,7 @@ #include #include #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 else if (!strcmp (key, "mtu")) address.mtu = boost::lexical_cast(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 else if (!strcmp (key, "itag")) introducer.iTag = boost::lexical_cast(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 WriteString ("ikey" + boost::lexical_cast(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 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 << ';'; diff --git a/SAM.cpp b/SAM.cpp index 9014f373..e74ca25a 100644 --- a/SAM.cpp +++ b/SAM.cpp @@ -4,7 +4,7 @@ #include #endif #include -#include "base64.h" +#include "util/base64.h" #include "Identity.h" #include "Log.h" #include "Destination.h" @@ -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 // 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 } diff --git a/filelist.mk b/filelist.mk index cac86830..2b28c081 100644 --- a/filelist.mk +++ b/filelist.mk @@ -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) diff --git a/transport/NTCPSession.cpp b/transport/NTCPSession.cpp index c3d64221..85b62252 100644 --- a/transport/NTCPSession.cpp +++ b/transport/NTCPSession.cpp @@ -3,9 +3,9 @@ #include "I2PEndian.h" #include #include -#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" diff --git a/transport/SSU.cpp b/transport/SSU.cpp index f294db17..651ff93e 100644 --- a/transport/SSU.cpp +++ b/transport/SSU.cpp @@ -1,7 +1,7 @@ #include #include #include "Log.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "RouterContext.h" #include "NetDb.h" #include "SSU.h" diff --git a/transport/SSUData.cpp b/transport/SSUData.cpp index 02473db4..2f661e68 100644 --- a/transport/SSUData.cpp +++ b/transport/SSUData.cpp @@ -1,7 +1,7 @@ #include #include #include "Log.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "NetDb.h" #include "SSU.h" #include "SSUData.h" diff --git a/transport/SSUSession.cpp b/transport/SSUSession.cpp index 8f2c2d66..e56f67ea 100644 --- a/transport/SSUSession.cpp +++ b/transport/SSUSession.cpp @@ -3,7 +3,7 @@ #include #include "CryptoConst.h" #include "Log.h" -#include "Timestamp.h" +#include "util/Timestamp.h" #include "RouterContext.h" #include "Transports.h" #include "SSU.h" diff --git a/base64.cpp b/util/base64.cpp similarity index 99% rename from base64.cpp rename to util/base64.cpp index cc0c7c21..8ccae845 100644 --- a/base64.cpp +++ b/util/base64.cpp @@ -3,7 +3,7 @@ namespace i2p { -namespace data +namespace util { static void iT64Build(void); diff --git a/base64.h b/util/base64.h similarity index 99% rename from base64.h rename to util/base64.h index 3c1ecb76..689c35ab 100644 --- a/base64.h +++ b/util/base64.h @@ -6,7 +6,7 @@ namespace i2p { -namespace data +namespace util { From 9e5c33bce72dfa56b4206a8193d4bf34d3078025 Mon Sep 17 00:00:00 2001 From: EinMByte Date: Tue, 28 Jul 2015 19:30:44 +0200 Subject: [PATCH 05/11] Fixed tests after introducing util/. --- filelist.mk | 2 +- tests/{Data.cpp => Base64.cpp} | 6 +++--- tests/Utility.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename tests/{Data.cpp => Base64.cpp} (97%) diff --git a/filelist.mk b/filelist.mk index 2b28c081..765c0255 100644 --- a/filelist.mk +++ b/filelist.mk @@ -28,4 +28,4 @@ LIB_SRC := $(COMMON_SRC) \ api.cpp TESTS_SRC := $(COMMON_SRC) \ - tests/Utility.cpp tests/Identity.cpp tests/Data.cpp + tests/Utility.cpp tests/Identity.cpp tests/Base64.cpp diff --git a/tests/Data.cpp b/tests/Base64.cpp similarity index 97% rename from tests/Data.cpp rename to tests/Base64.cpp index 9e14ebfe..290b83bf 100644 --- a/tests/Data.cpp +++ b/tests/Base64.cpp @@ -1,11 +1,11 @@ #define BOOST_TEST_DYN_LINK #include -#include "../Identity.h" +#include "util/base64.h" -BOOST_AUTO_TEST_SUITE(DataTests) +BOOST_AUTO_TEST_SUITE(Base64and32Tests) -using namespace i2p::data; +using namespace i2p::util; BOOST_AUTO_TEST_CASE(Base64EncodeEmpty) { diff --git a/tests/Utility.cpp b/tests/Utility.cpp index 7fabfce7..dbbe2bb6 100644 --- a/tests/Utility.cpp +++ b/tests/Utility.cpp @@ -1,5 +1,5 @@ #include -#include "../util.h" +#include "util/util.h" BOOST_AUTO_TEST_SUITE(UtilityTests) From b9aebadd468764283aac086132fc79e07f540da0 Mon Sep 17 00:00:00 2001 From: EinMByte Date: Tue, 28 Jul 2015 22:03:39 +0200 Subject: [PATCH 06/11] Add crypto/ directory. --- Destination.cpp | 2 +- Destination.h | 2 +- Garlic.h | 2 +- I2NPProtocol.cpp | 2 +- Identity.cpp | 4 ++-- Identity.h | 4 ++-- LeaseSet.cpp | 2 +- Makefile | 3 +++ Reseed.cpp | 2 +- Reseed.h | 2 +- RouterContext.cpp | 2 +- RouterInfo.cpp | 2 +- TransitTunnel.h | 2 +- TunnelConfig.h | 2 +- TunnelPool.cpp | 2 +- CryptoConst.cpp => crypto/CryptoConst.cpp | 0 CryptoConst.h => crypto/CryptoConst.h | 0 ElGamal.h => crypto/ElGamal.h | 0 Signature.cpp => crypto/Signature.cpp | 0 Signature.h => crypto/Signature.h | 0 aes.cpp => crypto/aes.cpp | 0 aes.h => crypto/aes.h | 0 hmac.h => crypto/hmac.h | 0 filelist.mk | 7 ++++--- transport/NTCPSession.cpp | 2 +- transport/NTCPSession.h | 2 +- transport/SSU.h | 2 +- transport/SSUSession.cpp | 2 +- transport/SSUSession.h | 4 ++-- transport/Transports.cpp | 2 +- 30 files changed, 30 insertions(+), 26 deletions(-) rename CryptoConst.cpp => crypto/CryptoConst.cpp (100%) rename CryptoConst.h => crypto/CryptoConst.h (100%) rename ElGamal.h => crypto/ElGamal.h (100%) rename Signature.cpp => crypto/Signature.cpp (100%) rename Signature.h => crypto/Signature.h (100%) rename aes.cpp => crypto/aes.cpp (100%) rename aes.h => crypto/aes.h (100%) rename hmac.h => crypto/hmac.h (100%) diff --git a/Destination.cpp b/Destination.cpp index f19dbe72..0196e6b9 100644 --- a/Destination.cpp +++ b/Destination.cpp @@ -3,7 +3,7 @@ #include #include "Log.h" #include "util/util.h" -#include "ElGamal.h" +#include "crypto/ElGamal.h" #include "util/Timestamp.h" #include "NetDb.h" #include "AddressBook.h" diff --git a/Destination.h b/Destination.h index 7e73af95..fdad4426 100644 --- a/Destination.h +++ b/Destination.h @@ -11,7 +11,7 @@ #include #include "Identity.h" #include "TunnelPool.h" -#include "CryptoConst.h" +#include "crypto/CryptoConst.h" #include "LeaseSet.h" #include "Garlic.h" #include "NetDb.h" diff --git a/Garlic.h b/Garlic.h index da90250f..457b64e0 100644 --- a/Garlic.h +++ b/Garlic.h @@ -9,7 +9,7 @@ #include #include #include -#include "aes.h" +#include "crypto/aes.h" #include "I2NPProtocol.h" #include "LeaseSet.h" #include "util/Queue.h" diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index b59d0985..51127897 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -2,7 +2,7 @@ #include #include "I2PEndian.h" #include -#include "ElGamal.h" +#include "crypto/ElGamal.h" #include "util/Timestamp.h" #include "RouterContext.h" #include "NetDb.h" diff --git a/Identity.cpp b/Identity.cpp index 0d1a37db..80230630 100644 --- a/Identity.cpp +++ b/Identity.cpp @@ -4,8 +4,8 @@ #include #include #include "util/base64.h" -#include "CryptoConst.h" -#include "ElGamal.h" +#include "crypto/CryptoConst.h" +#include "crypto/ElGamal.h" #include "RouterContext.h" #include "Identity.h" #include "I2PEndian.h" diff --git a/Identity.h b/Identity.h index 7f36545d..3388b150 100644 --- a/Identity.h +++ b/Identity.h @@ -6,8 +6,8 @@ #include #include #include "util/base64.h" -#include "ElGamal.h" -#include "Signature.h" +#include "crypto/ElGamal.h" +#include "crypto/Signature.h" namespace i2p { diff --git a/LeaseSet.cpp b/LeaseSet.cpp index 22bc4267..c815b1ec 100644 --- a/LeaseSet.cpp +++ b/LeaseSet.cpp @@ -2,7 +2,7 @@ #include "I2PEndian.h" #include #include -#include "CryptoConst.h" +#include "crypto/CryptoConst.h" #include "Log.h" #include "util/Timestamp.h" #include "NetDb.h" diff --git a/Makefile b/Makefile index f48357f2..e97812fa 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ mk_build_dir: mkdir -p obj mkdir -p obj/transport mkdir -p obj/util + mkdir -p obj/crypto mk_build_test_dir: mkdir -p obj/tests @@ -47,6 +48,7 @@ deps: @mkdir -p obj/transport @mkdir -p obj/tests @mkdir -p obj/util + @mkdir -p obj/crypto $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) -MM *.cpp > $(DEPS) @sed -i -e '/\.o:/ s/^/obj\//' $(DEPS) @@ -55,6 +57,7 @@ obj/%.o : %.cpp @mkdir -p obj/transport @mkdir -p obj/tests @mkdir -p obj/util + @mkdir -p obj/crypto $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) -c -o $@ $< # '-' is 'ignore if missing' on first run diff --git a/Reseed.cpp b/Reseed.cpp index 4e3b4563..63cdaa21 100644 --- a/Reseed.cpp +++ b/Reseed.cpp @@ -15,7 +15,7 @@ #include "Reseed.h" #include "Log.h" #include "Identity.h" -#include "CryptoConst.h" +#include "crypto/CryptoConst.h" #include "NetDb.h" #include "util/util.h" diff --git a/Reseed.h b/Reseed.h index cdd76858..a18ccd67 100644 --- a/Reseed.h +++ b/Reseed.h @@ -9,7 +9,7 @@ #include #include #include "Identity.h" -#include "aes.h" +#include "crypto/aes.h" namespace i2p { diff --git a/RouterContext.cpp b/RouterContext.cpp index ac2358b1..7032ea66 100644 --- a/RouterContext.cpp +++ b/RouterContext.cpp @@ -2,7 +2,7 @@ #include #include #include -#include "CryptoConst.h" +#include "crypto/CryptoConst.h" #include "RouterContext.h" #include "util/Timestamp.h" #include "I2NPProtocol.h" diff --git a/RouterInfo.cpp b/RouterInfo.cpp index b394d09d..2e30c90d 100644 --- a/RouterInfo.cpp +++ b/RouterInfo.cpp @@ -5,7 +5,7 @@ #include #include #include -#include "CryptoConst.h" +#include "crypto/CryptoConst.h" #include "util/base64.h" #include "util/Timestamp.h" #include "Log.h" diff --git a/TransitTunnel.h b/TransitTunnel.h index fea6d4eb..b92dca3c 100644 --- a/TransitTunnel.h +++ b/TransitTunnel.h @@ -5,7 +5,7 @@ #include #include #include -#include "aes.h" +#include "crypto/aes.h" #include "I2NPProtocol.h" #include "TunnelEndpoint.h" #include "TunnelGateway.h" diff --git a/TunnelConfig.h b/TunnelConfig.h index a77b560f..b121c8d6 100644 --- a/TunnelConfig.h +++ b/TunnelConfig.h @@ -5,7 +5,7 @@ #include #include #include -#include "aes.h" +#include "crypto/aes.h" #include "RouterInfo.h" #include "RouterContext.h" #include "util/Timestamp.h" diff --git a/TunnelPool.cpp b/TunnelPool.cpp index 18ffd8ae..598cc373 100644 --- a/TunnelPool.cpp +++ b/TunnelPool.cpp @@ -1,6 +1,6 @@ #include #include "I2PEndian.h" -#include "CryptoConst.h" +#include "crypto/CryptoConst.h" #include "Tunnel.h" #include "NetDb.h" #include "util/Timestamp.h" diff --git a/CryptoConst.cpp b/crypto/CryptoConst.cpp similarity index 100% rename from CryptoConst.cpp rename to crypto/CryptoConst.cpp diff --git a/CryptoConst.h b/crypto/CryptoConst.h similarity index 100% rename from CryptoConst.h rename to crypto/CryptoConst.h diff --git a/ElGamal.h b/crypto/ElGamal.h similarity index 100% rename from ElGamal.h rename to crypto/ElGamal.h diff --git a/Signature.cpp b/crypto/Signature.cpp similarity index 100% rename from Signature.cpp rename to crypto/Signature.cpp diff --git a/Signature.h b/crypto/Signature.h similarity index 100% rename from Signature.h rename to crypto/Signature.h diff --git a/aes.cpp b/crypto/aes.cpp similarity index 100% rename from aes.cpp rename to crypto/aes.cpp diff --git a/aes.h b/crypto/aes.h similarity index 100% rename from aes.h rename to crypto/aes.h diff --git a/hmac.h b/crypto/hmac.h similarity index 100% rename from hmac.h rename to crypto/hmac.h diff --git a/filelist.mk b/filelist.mk index 765c0255..5a8955fe 100644 --- a/filelist.mk +++ b/filelist.mk @@ -2,11 +2,12 @@ COMMON_SRC = \ transport/NTCPSession.cpp transport/SSU.cpp transport/SSUSession.cpp \ transport/SSUData.cpp transport/Transports.cpp \ util/util.cpp util/base64.cpp \ - CryptoConst.cpp Datagram.cpp Garlic.cpp I2NPProtocol.cpp LeaseSet.cpp \ + crypto/CryptoConst.cpp crypto/aes.cpp crypto/Signature.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 \ + RouterContext.cpp RouterInfo.cpp Streaming.cpp Identity.cpp \ TransitTunnel.cpp Tunnel.cpp TunnelEndpoint.cpp TunnelPool.cpp \ - TunnelGateway.cpp Destination.cpp UPnP.cpp aes.cpp + TunnelGateway.cpp Destination.cpp UPnP.cpp ifeq ($(UNAME),Darwin) diff --git a/transport/NTCPSession.cpp b/transport/NTCPSession.cpp index 85b62252..4d6123f1 100644 --- a/transport/NTCPSession.cpp +++ b/transport/NTCPSession.cpp @@ -6,7 +6,7 @@ #include "util/base64.h" #include "Log.h" #include "util/Timestamp.h" -#include "CryptoConst.h" +#include "crypto/CryptoConst.h" #include "I2NPProtocol.h" #include "RouterContext.h" #include "Transports.h" diff --git a/transport/NTCPSession.h b/transport/NTCPSession.h index 7b99483e..2dbfd360 100644 --- a/transport/NTCPSession.h +++ b/transport/NTCPSession.h @@ -9,7 +9,7 @@ #include #include #include -#include "aes.h" +#include "crypto/aes.h" #include "Identity.h" #include "RouterInfo.h" #include "I2NPProtocol.h" diff --git a/transport/SSU.h b/transport/SSU.h index 54d9326a..7c756f01 100644 --- a/transport/SSU.h +++ b/transport/SSU.h @@ -9,7 +9,7 @@ #include #include #include -#include "aes.h" +#include "crypto/aes.h" #include "I2PEndian.h" #include "Identity.h" #include "RouterInfo.h" diff --git a/transport/SSUSession.cpp b/transport/SSUSession.cpp index e56f67ea..69a99125 100644 --- a/transport/SSUSession.cpp +++ b/transport/SSUSession.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "CryptoConst.h" +#include "crypto/CryptoConst.h" #include "Log.h" #include "util/Timestamp.h" #include "RouterContext.h" diff --git a/transport/SSUSession.h b/transport/SSUSession.h index 427b81c8..f7194358 100644 --- a/transport/SSUSession.h +++ b/transport/SSUSession.h @@ -4,8 +4,8 @@ #include #include #include -#include "aes.h" -#include "hmac.h" +#include "crypto/aes.h" +#include "crypto/hmac.h" #include "I2NPProtocol.h" #include "TransportSession.h" #include "SSUData.h" diff --git a/transport/Transports.cpp b/transport/Transports.cpp index 52856c5f..623892ac 100644 --- a/transport/Transports.cpp +++ b/transport/Transports.cpp @@ -1,6 +1,6 @@ #include #include "Log.h" -#include "CryptoConst.h" +#include "crypto/CryptoConst.h" #include "RouterContext.h" #include "I2NPProtocol.h" #include "NetDb.h" From 13e89456661371763a32c7a7ed9490142e55a0c8 Mon Sep 17 00:00:00 2001 From: EinMByte Date: Tue, 28 Jul 2015 22:48:38 +0200 Subject: [PATCH 07/11] Moved I2PEndian to util/ --- Garlic.cpp | 2 +- HTTPProxy.cpp | 2 +- HTTPServer.cpp | 2 +- I2NPProtocol.cpp | 2 +- I2NPProtocol.h | 2 +- Identity.cpp | 2 +- LeaseSet.cpp | 2 +- NetDb.cpp | 2 +- Reseed.cpp | 2 +- RouterInfo.cpp | 2 +- SOCKS.cpp | 2 +- Streaming.h | 2 +- TransitTunnel.cpp | 2 +- Tunnel.cpp | 2 +- TunnelEndpoint.cpp | 2 +- TunnelGateway.cpp | 2 +- TunnelPool.cpp | 2 +- filelist.mk | 2 +- transport/NTCPSession.cpp | 2 +- transport/SSU.h | 2 +- I2PEndian.cpp => util/I2PEndian.cpp | 0 I2PEndian.h => util/I2PEndian.h | 0 22 files changed, 20 insertions(+), 20 deletions(-) rename I2PEndian.cpp => util/I2PEndian.cpp (100%) rename I2PEndian.h => util/I2PEndian.h (100%) diff --git a/Garlic.cpp b/Garlic.cpp index 96ea89d2..e611addd 100644 --- a/Garlic.cpp +++ b/Garlic.cpp @@ -1,5 +1,5 @@ #include -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include #include #include "RouterContext.h" diff --git a/HTTPProxy.cpp b/HTTPProxy.cpp index 03e322e9..a5a64431 100644 --- a/HTTPProxy.cpp +++ b/HTTPProxy.cpp @@ -10,7 +10,7 @@ #include "Streaming.h" #include "Destination.h" #include "ClientContext.h" -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include "I2PTunnel.h" namespace i2p diff --git a/HTTPServer.cpp b/HTTPServer.cpp index e5d23c3d..f55fab8d 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -7,7 +7,7 @@ #include "TransitTunnel.h" #include "transport/Transports.h" #include "NetDb.h" -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include "Streaming.h" #include "Destination.h" #include "RouterContext.h" diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index 51127897..7a579825 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -1,6 +1,6 @@ #include #include -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include #include "crypto/ElGamal.h" #include "util/Timestamp.h" diff --git a/I2NPProtocol.h b/I2NPProtocol.h index 28a0e111..d8570330 100644 --- a/I2NPProtocol.h +++ b/I2NPProtocol.h @@ -6,7 +6,7 @@ #include #include #include -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include "Identity.h" #include "RouterInfo.h" #include "LeaseSet.h" diff --git a/Identity.cpp b/Identity.cpp index 80230630..226e41fb 100644 --- a/Identity.cpp +++ b/Identity.cpp @@ -8,7 +8,7 @@ #include "crypto/ElGamal.h" #include "RouterContext.h" #include "Identity.h" -#include "I2PEndian.h" +#include "util/I2PEndian.h" namespace i2p { diff --git a/LeaseSet.cpp b/LeaseSet.cpp index c815b1ec..f98291c1 100644 --- a/LeaseSet.cpp +++ b/LeaseSet.cpp @@ -1,5 +1,5 @@ #include -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include #include #include "crypto/CryptoConst.h" diff --git a/NetDb.cpp b/NetDb.cpp index 45236f40..e544d780 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -1,5 +1,5 @@ #include -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include #include #include diff --git a/Reseed.cpp b/Reseed.cpp index 63cdaa21..5b294675 100644 --- a/Reseed.cpp +++ b/Reseed.cpp @@ -11,7 +11,7 @@ #include #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 #include -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include "Reseed.h" #include "Log.h" #include "Identity.h" diff --git a/RouterInfo.cpp b/RouterInfo.cpp index 2e30c90d..e819e419 100644 --- a/RouterInfo.cpp +++ b/RouterInfo.cpp @@ -1,6 +1,6 @@ #include #include -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include #include #include diff --git a/SOCKS.cpp b/SOCKS.cpp index be68d35d..6e092707 100644 --- a/SOCKS.cpp +++ b/SOCKS.cpp @@ -7,7 +7,7 @@ #include "Streaming.h" #include "Destination.h" #include "ClientContext.h" -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include "I2PTunnel.h" namespace i2p diff --git a/Streaming.h b/Streaming.h index f100a69f..562d5a8e 100644 --- a/Streaming.h +++ b/Streaming.h @@ -11,7 +11,7 @@ #include #include #include -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include "Identity.h" #include "LeaseSet.h" #include "I2NPProtocol.h" diff --git a/TransitTunnel.cpp b/TransitTunnel.cpp index ed298699..23427d05 100644 --- a/TransitTunnel.cpp +++ b/TransitTunnel.cpp @@ -1,5 +1,5 @@ #include -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include "Log.h" #include "RouterContext.h" #include "I2NPProtocol.h" diff --git a/Tunnel.cpp b/Tunnel.cpp index 9b13926f..4f95a4c5 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -1,5 +1,5 @@ #include -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include #include #include diff --git a/TunnelEndpoint.cpp b/TunnelEndpoint.cpp index e38701ca..7697e4c1 100644 --- a/TunnelEndpoint.cpp +++ b/TunnelEndpoint.cpp @@ -1,4 +1,4 @@ -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include #include "Log.h" #include "NetDb.h" diff --git a/TunnelGateway.cpp b/TunnelGateway.cpp index 3ef7579a..3fd405ee 100644 --- a/TunnelGateway.cpp +++ b/TunnelGateway.cpp @@ -1,5 +1,5 @@ #include -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include #include "Log.h" #include "RouterContext.h" diff --git a/TunnelPool.cpp b/TunnelPool.cpp index 598cc373..a790ca66 100644 --- a/TunnelPool.cpp +++ b/TunnelPool.cpp @@ -1,5 +1,5 @@ #include -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include "crypto/CryptoConst.h" #include "Tunnel.h" #include "NetDb.h" diff --git a/filelist.mk b/filelist.mk index 5a8955fe..d9150a58 100644 --- a/filelist.mk +++ b/filelist.mk @@ -1,7 +1,7 @@ COMMON_SRC = \ transport/NTCPSession.cpp transport/SSU.cpp transport/SSUSession.cpp \ transport/SSUData.cpp transport/Transports.cpp \ - util/util.cpp util/base64.cpp \ + util/util.cpp util/base64.cpp\ crypto/CryptoConst.cpp crypto/aes.cpp crypto/Signature.cpp \ Datagram.cpp Garlic.cpp I2NPProtocol.cpp LeaseSet.cpp \ Log.cpp NetDb.cpp NetDbRequests.cpp Profiling.cpp Reseed.cpp \ diff --git a/transport/NTCPSession.cpp b/transport/NTCPSession.cpp index 4d6123f1..6a79956d 100644 --- a/transport/NTCPSession.cpp +++ b/transport/NTCPSession.cpp @@ -1,6 +1,6 @@ #include #include -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include #include #include "util/base64.h" diff --git a/transport/SSU.h b/transport/SSU.h index 7c756f01..ec0706c2 100644 --- a/transport/SSU.h +++ b/transport/SSU.h @@ -10,7 +10,7 @@ #include #include #include "crypto/aes.h" -#include "I2PEndian.h" +#include "util/I2PEndian.h" #include "Identity.h" #include "RouterInfo.h" #include "I2NPProtocol.h" diff --git a/I2PEndian.cpp b/util/I2PEndian.cpp similarity index 100% rename from I2PEndian.cpp rename to util/I2PEndian.cpp diff --git a/I2PEndian.h b/util/I2PEndian.h similarity index 100% rename from I2PEndian.h rename to util/I2PEndian.h From 6268e297e4f98d142d02550e273b5605fe6b00c8 Mon Sep 17 00:00:00 2001 From: EinMByte Date: Wed, 29 Jul 2015 18:37:15 +0200 Subject: [PATCH 08/11] Fix building with cmake. --- .gitignore | 9 +++++++++ build/CMakeLists.txt | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 1adbe1ef..40d8fe07 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,15 @@ netDb tunnels.cfg tests/tests +# Build files +build/CMakeCache.txt +build/CMakeFiles/* +build/cmake_install.cmake +build/i2pd +build/libcommon.a +build/libi2pd.a + + # Autotools autom4te.cache .deps diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index ed8a281f..2ea64a32 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -15,41 +15,41 @@ set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" ) set ( CMAKE_SOURCE_DIR ".." ) set (COMMON_SRC + "${CMAKE_SOURCE_DIR}/transport/NTCPSession.cpp" + "${CMAKE_SOURCE_DIR}/transport/SSU.cpp" + "${CMAKE_SOURCE_DIR}/transport/SSUData.cpp" + "${CMAKE_SOURCE_DIR}/transport/SSUSession.cpp" + "${CMAKE_SOURCE_DIR}/transport/Transports.cpp" + "${CMAKE_SOURCE_DIR}/crypto/CryptoConst.cpp" + "${CMAKE_SOURCE_DIR}/crypto/aes.cpp" + "${CMAKE_SOURCE_DIR}/crypto/Signature.cpp" + "${CMAKE_SOURCE_DIR}/util/base64.cpp" + "${CMAKE_SOURCE_DIR}/util/util.cpp" "${CMAKE_SOURCE_DIR}/AddressBook.cpp" - "${CMAKE_SOURCE_DIR}/CryptoConst.cpp" "${CMAKE_SOURCE_DIR}/Garlic.cpp" "${CMAKE_SOURCE_DIR}/I2NPProtocol.cpp" "${CMAKE_SOURCE_DIR}/Identity.cpp" "${CMAKE_SOURCE_DIR}/LeaseSet.cpp" "${CMAKE_SOURCE_DIR}/Log.cpp" - "${CMAKE_SOURCE_DIR}/NTCPSession.cpp" "${CMAKE_SOURCE_DIR}/NetDbRequests.cpp" "${CMAKE_SOURCE_DIR}/NetDb.cpp" "${CMAKE_SOURCE_DIR}/Profiling.cpp" "${CMAKE_SOURCE_DIR}/Reseed.cpp" "${CMAKE_SOURCE_DIR}/RouterContext.cpp" "${CMAKE_SOURCE_DIR}/RouterInfo.cpp" - "${CMAKE_SOURCE_DIR}/SSU.cpp" - "${CMAKE_SOURCE_DIR}/SSUData.cpp" - "${CMAKE_SOURCE_DIR}/SSUSession.cpp" "${CMAKE_SOURCE_DIR}/Streaming.cpp" "${CMAKE_SOURCE_DIR}/Destination.cpp" "${CMAKE_SOURCE_DIR}/TransitTunnel.cpp" "${CMAKE_SOURCE_DIR}/Tunnel.cpp" "${CMAKE_SOURCE_DIR}/TunnelGateway.cpp" - "${CMAKE_SOURCE_DIR}/Transports.cpp" "${CMAKE_SOURCE_DIR}/TunnelEndpoint.cpp" "${CMAKE_SOURCE_DIR}/TunnelPool.cpp" - "${CMAKE_SOURCE_DIR}/aes.cpp" - "${CMAKE_SOURCE_DIR}/base64.cpp" - "${CMAKE_SOURCE_DIR}/util.cpp" "${CMAKE_SOURCE_DIR}/Datagram.cpp" - "${CMAKE_SOURCE_DIR}/Signature.cpp" "${CMAKE_SOURCE_DIR}/UPnP.cpp" ) if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - list (APPEND COMMON_SRC "${CMAKE_SOURCE_DIR}/I2PEndian.cpp") + list (APPEND COMMON_SRC "${CMAKE_SOURCE_DIR}/util/I2PEndian.cpp") endif () add_library(common ${COMMON_SRC}) @@ -223,7 +223,7 @@ if (NOT ${MINIUPNPC_FOUND}) endif() # load includes -include_directories( ${Boost_INCLUDE_DIRS} ${CRYPTO++_INCLUDE_DIR} ) +include_directories( ${CMAKE_SOURCE_DIR} ${Boost_INCLUDE_DIRS} ${CRYPTO++_INCLUDE_DIR} ) # show summary message(STATUS "---------------------------------------") From c8190d00209e6c835a96fac80cbdf2b8e875136c Mon Sep 17 00:00:00 2001 From: EinMByte Date: Thu, 30 Jul 2015 15:34:56 +0200 Subject: [PATCH 09/11] Move Log.h/cpp to util/ --- AddressBook.cpp | 2 +- AddressBook.h | 2 +- BOB.cpp | 2 +- ClientContext.cpp | 2 +- Daemon.cpp | 2 +- DaemonLinux.cpp | 2 +- DaemonWin32.cpp | 2 +- Datagram.cpp | 2 +- Destination.cpp | 2 +- HTTPServer.cpp | 2 +- I2PControl.cpp | 2 +- I2PTunnel.cpp | 2 +- LeaseSet.cpp | 2 +- NetDb.cpp | 2 +- NetDbRequests.cpp | 2 +- Reseed.cpp | 2 +- RouterInfo.cpp | 2 +- SAM.cpp | 2 +- Streaming.cpp | 2 +- TransitTunnel.cpp | 2 +- Tunnel.cpp | 2 +- TunnelEndpoint.cpp | 2 +- TunnelGateway.cpp | 2 +- UPnP.cpp | 2 +- api.cpp | 2 +- build/CMakeLists.txt | 2 +- crypto/ElGamal.h | 2 +- crypto/Signature.cpp | 2 +- filelist.mk | 4 ++-- transport/NTCPSession.cpp | 2 +- transport/SSU.cpp | 2 +- transport/SSUData.cpp | 2 +- transport/SSUSession.cpp | 2 +- transport/Transports.cpp | 2 +- Log.cpp => util/Log.cpp | 0 Log.h => util/Log.h | 2 +- 36 files changed, 36 insertions(+), 36 deletions(-) rename Log.cpp => util/Log.cpp (100%) rename Log.h => util/Log.h (98%) diff --git a/AddressBook.cpp b/AddressBook.cpp index ab39c952..af10cdea 100644 --- a/AddressBook.cpp +++ b/AddressBook.cpp @@ -11,7 +11,7 @@ #include "util/base64.h" #include "util/util.h" #include "Identity.h" -#include "Log.h" +#include "util/Log.h" #include "NetDb.h" #include "ClientContext.h" #include "AddressBook.h" diff --git a/AddressBook.h b/AddressBook.h index 6521953d..e00283a2 100644 --- a/AddressBook.h +++ b/AddressBook.h @@ -11,7 +11,7 @@ #include "util/base64.h" #include "util/util.h" #include "Identity.h" -#include "Log.h" +#include "util/Log.h" namespace i2p { diff --git a/BOB.cpp b/BOB.cpp index cbe8f142..9247edbd 100644 --- a/BOB.cpp +++ b/BOB.cpp @@ -1,6 +1,6 @@ #include #include -#include "Log.h" +#include "util/Log.h" #include "ClientContext.h" #include "BOB.h" diff --git a/ClientContext.cpp b/ClientContext.cpp index 0c14e4df..9ffd2303 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -3,7 +3,7 @@ #include #include #include "util/util.h" -#include "Log.h" +#include "util/Log.h" #include "Identity.h" #include "ClientContext.h" diff --git a/Daemon.cpp b/Daemon.cpp index 124f60cc..2c52cfc1 100644 --- a/Daemon.cpp +++ b/Daemon.cpp @@ -2,7 +2,7 @@ #include "Daemon.h" -#include "Log.h" +#include "util/Log.h" #include "version.h" #include "transport/Transports.h" #include "transport/NTCPSession.h" diff --git a/DaemonLinux.cpp b/DaemonLinux.cpp index c4107d94..bbd5962e 100644 --- a/DaemonLinux.cpp +++ b/DaemonLinux.cpp @@ -8,7 +8,7 @@ #include #include -#include "Log.h" +#include "util/Log.h" #include "util/util.h" diff --git a/DaemonWin32.cpp b/DaemonWin32.cpp index e3220384..3f5d5b00 100644 --- a/DaemonWin32.cpp +++ b/DaemonWin32.cpp @@ -1,6 +1,6 @@ #include "Daemon.h" #include "util/util.h" -#include "Log.h" +#include "util/Log.h" #ifdef _WIN32 diff --git a/Datagram.cpp b/Datagram.cpp index 4b08e25c..a4ad5086 100644 --- a/Datagram.cpp +++ b/Datagram.cpp @@ -2,7 +2,7 @@ #include #include #include -#include "Log.h" +#include "util/Log.h" #include "TunnelBase.h" #include "RouterContext.h" #include "Destination.h" diff --git a/Destination.cpp b/Destination.cpp index 0196e6b9..c680313c 100644 --- a/Destination.cpp +++ b/Destination.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "Log.h" +#include "util/Log.h" #include "util/util.h" #include "crypto/ElGamal.h" #include "util/Timestamp.h" diff --git a/HTTPServer.cpp b/HTTPServer.cpp index f55fab8d..b45160ca 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -2,7 +2,7 @@ #include #include #include "util/base64.h" -#include "Log.h" +#include "util/Log.h" #include "Tunnel.h" #include "TransitTunnel.h" #include "transport/Transports.h" diff --git a/I2PControl.cpp b/I2PControl.cpp index 5b38ac51..feeacb6d 100644 --- a/I2PControl.cpp +++ b/I2PControl.cpp @@ -9,7 +9,7 @@ #if !GCC47_BOOST149 #include #endif -#include "Log.h" +#include "util/Log.h" #include "NetDb.h" #include "RouterContext.h" #include "Daemon.h" diff --git a/I2PTunnel.cpp b/I2PTunnel.cpp index a7e6a29b..ef968d11 100644 --- a/I2PTunnel.cpp +++ b/I2PTunnel.cpp @@ -1,5 +1,5 @@ #include -#include "Log.h" +#include "util/Log.h" #include "Destination.h" #include "ClientContext.h" #include "I2PTunnel.h" diff --git a/LeaseSet.cpp b/LeaseSet.cpp index f98291c1..98acec26 100644 --- a/LeaseSet.cpp +++ b/LeaseSet.cpp @@ -3,7 +3,7 @@ #include #include #include "crypto/CryptoConst.h" -#include "Log.h" +#include "util/Log.h" #include "util/Timestamp.h" #include "NetDb.h" #include "TunnelPool.h" diff --git a/NetDb.cpp b/NetDb.cpp index e544d780..248b956e 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -5,7 +5,7 @@ #include #include #include "util/base64.h" -#include "Log.h" +#include "util/Log.h" #include "util/Timestamp.h" #include "I2NPProtocol.h" #include "Tunnel.h" diff --git a/NetDbRequests.cpp b/NetDbRequests.cpp index 1dcbbf6a..382d0e3b 100644 --- a/NetDbRequests.cpp +++ b/NetDbRequests.cpp @@ -1,4 +1,4 @@ -#include "Log.h" +#include "util/Log.h" #include "I2NPProtocol.h" #include "transport/Transports.h" #include "NetDb.h" diff --git a/Reseed.cpp b/Reseed.cpp index 5b294675..3e16f48b 100644 --- a/Reseed.cpp +++ b/Reseed.cpp @@ -13,7 +13,7 @@ #include #include "util/I2PEndian.h" #include "Reseed.h" -#include "Log.h" +#include "util/Log.h" #include "Identity.h" #include "crypto/CryptoConst.h" #include "NetDb.h" diff --git a/RouterInfo.cpp b/RouterInfo.cpp index e819e419..b3b11d73 100644 --- a/RouterInfo.cpp +++ b/RouterInfo.cpp @@ -8,7 +8,7 @@ #include "crypto/CryptoConst.h" #include "util/base64.h" #include "util/Timestamp.h" -#include "Log.h" +#include "util/Log.h" #include "RouterInfo.h" #include "RouterContext.h" diff --git a/SAM.cpp b/SAM.cpp index e74ca25a..695e8d4a 100644 --- a/SAM.cpp +++ b/SAM.cpp @@ -6,7 +6,7 @@ #include #include "util/base64.h" #include "Identity.h" -#include "Log.h" +#include "util/Log.h" #include "Destination.h" #include "ClientContext.h" #include "SAM.h" diff --git a/Streaming.cpp b/Streaming.cpp index 239bd661..9c891994 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -1,5 +1,5 @@ #include -#include "Log.h" +#include "util/Log.h" #include "RouterInfo.h" #include "RouterContext.h" #include "Tunnel.h" diff --git a/TransitTunnel.cpp b/TransitTunnel.cpp index 23427d05..79d19564 100644 --- a/TransitTunnel.cpp +++ b/TransitTunnel.cpp @@ -1,6 +1,6 @@ #include #include "util/I2PEndian.h" -#include "Log.h" +#include "util/Log.h" #include "RouterContext.h" #include "I2NPProtocol.h" #include "Tunnel.h" diff --git a/Tunnel.cpp b/Tunnel.cpp index 4f95a4c5..a209d3b8 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -5,7 +5,7 @@ #include #include #include "RouterContext.h" -#include "Log.h" +#include "util/Log.h" #include "util/Timestamp.h" #include "I2NPProtocol.h" #include "transport/Transports.h" diff --git a/TunnelEndpoint.cpp b/TunnelEndpoint.cpp index 7697e4c1..bd982358 100644 --- a/TunnelEndpoint.cpp +++ b/TunnelEndpoint.cpp @@ -1,6 +1,6 @@ #include "util/I2PEndian.h" #include -#include "Log.h" +#include "util/Log.h" #include "NetDb.h" #include "I2NPProtocol.h" #include "transport/Transports.h" diff --git a/TunnelGateway.cpp b/TunnelGateway.cpp index 3fd405ee..6b55f543 100644 --- a/TunnelGateway.cpp +++ b/TunnelGateway.cpp @@ -1,7 +1,7 @@ #include #include "util/I2PEndian.h" #include -#include "Log.h" +#include "util/Log.h" #include "RouterContext.h" #include "transport/Transports.h" #include "TunnelGateway.h" diff --git a/UPnP.cpp b/UPnP.cpp index e6601f77..175528b4 100644 --- a/UPnP.cpp +++ b/UPnP.cpp @@ -13,7 +13,7 @@ #include #endif -#include "Log.h" +#include "util/Log.h" #include "RouterContext.h" #include "UPnP.h" diff --git a/api.cpp b/api.cpp index 1d381ac7..17d6fdac 100644 --- a/api.cpp +++ b/api.cpp @@ -1,6 +1,6 @@ #include #include -#include "Log.h" +#include "util/Log.h" #include "NetDb.h" #include "transport/Transports.h" #include "Tunnel.h" diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 2ea64a32..bbcfa01a 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -25,12 +25,12 @@ set (COMMON_SRC "${CMAKE_SOURCE_DIR}/crypto/Signature.cpp" "${CMAKE_SOURCE_DIR}/util/base64.cpp" "${CMAKE_SOURCE_DIR}/util/util.cpp" + "${CMAKE_SOURCE_DIR}/util/Log.cpp" "${CMAKE_SOURCE_DIR}/AddressBook.cpp" "${CMAKE_SOURCE_DIR}/Garlic.cpp" "${CMAKE_SOURCE_DIR}/I2NPProtocol.cpp" "${CMAKE_SOURCE_DIR}/Identity.cpp" "${CMAKE_SOURCE_DIR}/LeaseSet.cpp" - "${CMAKE_SOURCE_DIR}/Log.cpp" "${CMAKE_SOURCE_DIR}/NetDbRequests.cpp" "${CMAKE_SOURCE_DIR}/NetDb.cpp" "${CMAKE_SOURCE_DIR}/Profiling.cpp" diff --git a/crypto/ElGamal.h b/crypto/ElGamal.h index 9f90da53..8a0d04df 100644 --- a/crypto/ElGamal.h +++ b/crypto/ElGamal.h @@ -7,7 +7,7 @@ #include #include #include "CryptoConst.h" -#include "Log.h" +#include "util/Log.h" namespace i2p { diff --git a/crypto/Signature.cpp b/crypto/Signature.cpp index d56efddd..bf2809a0 100644 --- a/crypto/Signature.cpp +++ b/crypto/Signature.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "Log.h" +#include "util/Log.h" #include "Signature.h" namespace i2p diff --git a/filelist.mk b/filelist.mk index d9150a58..e0a66f04 100644 --- a/filelist.mk +++ b/filelist.mk @@ -1,10 +1,10 @@ COMMON_SRC = \ transport/NTCPSession.cpp transport/SSU.cpp transport/SSUSession.cpp \ transport/SSUData.cpp transport/Transports.cpp \ - util/util.cpp util/base64.cpp\ + util/util.cpp util/base64.cpp util/Log.cpp \ crypto/CryptoConst.cpp crypto/aes.cpp crypto/Signature.cpp \ Datagram.cpp Garlic.cpp I2NPProtocol.cpp LeaseSet.cpp \ - Log.cpp NetDb.cpp NetDbRequests.cpp Profiling.cpp Reseed.cpp \ + NetDb.cpp NetDbRequests.cpp Profiling.cpp Reseed.cpp \ RouterContext.cpp RouterInfo.cpp Streaming.cpp Identity.cpp \ TransitTunnel.cpp Tunnel.cpp TunnelEndpoint.cpp TunnelPool.cpp \ TunnelGateway.cpp Destination.cpp UPnP.cpp diff --git a/transport/NTCPSession.cpp b/transport/NTCPSession.cpp index 6a79956d..d323041b 100644 --- a/transport/NTCPSession.cpp +++ b/transport/NTCPSession.cpp @@ -4,7 +4,7 @@ #include #include #include "util/base64.h" -#include "Log.h" +#include "util/Log.h" #include "util/Timestamp.h" #include "crypto/CryptoConst.h" #include "I2NPProtocol.h" diff --git a/transport/SSU.cpp b/transport/SSU.cpp index 651ff93e..9c1337ec 100644 --- a/transport/SSU.cpp +++ b/transport/SSU.cpp @@ -1,6 +1,6 @@ #include #include -#include "Log.h" +#include "util/Log.h" #include "util/Timestamp.h" #include "RouterContext.h" #include "NetDb.h" diff --git a/transport/SSUData.cpp b/transport/SSUData.cpp index 2f661e68..a1d49ba9 100644 --- a/transport/SSUData.cpp +++ b/transport/SSUData.cpp @@ -1,6 +1,6 @@ #include #include -#include "Log.h" +#include "util/Log.h" #include "util/Timestamp.h" #include "NetDb.h" #include "SSU.h" diff --git a/transport/SSUSession.cpp b/transport/SSUSession.cpp index 69a99125..f76592e7 100644 --- a/transport/SSUSession.cpp +++ b/transport/SSUSession.cpp @@ -2,7 +2,7 @@ #include #include #include "crypto/CryptoConst.h" -#include "Log.h" +#include "util/Log.h" #include "util/Timestamp.h" #include "RouterContext.h" #include "Transports.h" diff --git a/transport/Transports.cpp b/transport/Transports.cpp index 623892ac..45e2346c 100644 --- a/transport/Transports.cpp +++ b/transport/Transports.cpp @@ -1,5 +1,5 @@ #include -#include "Log.h" +#include "util/Log.h" #include "crypto/CryptoConst.h" #include "RouterContext.h" #include "I2NPProtocol.h" diff --git a/Log.cpp b/util/Log.cpp similarity index 100% rename from Log.cpp rename to util/Log.cpp diff --git a/Log.h b/util/Log.h similarity index 98% rename from Log.h rename to util/Log.h index 9dc72637..4aa4ef57 100644 --- a/Log.h +++ b/util/Log.h @@ -7,7 +7,7 @@ #include #include #include -#include "util/Queue.h" +#include "Queue.h" enum LogLevel { From d9bb09780f2f72666b76ee0fe37b1c05c6597e9a Mon Sep 17 00:00:00 2001 From: EinMByte Date: Thu, 30 Jul 2015 16:25:43 +0200 Subject: [PATCH 10/11] Created tunnel/ --- Daemon.cpp | 2 +- Datagram.cpp | 2 +- Destination.h | 2 +- Garlic.cpp | 4 ++-- HTTPServer.cpp | 4 ++-- I2NPProtocol.cpp | 2 +- I2PControl.cpp | 2 +- LeaseSet.cpp | 2 +- Makefile | 3 +++ NetDb.cpp | 2 +- NetDb.h | 4 ++-- Streaming.cpp | 2 +- Streaming.h | 2 +- api.cpp | 2 +- build/CMakeLists.txt | 10 +++++----- crypto/aes.cpp | 2 +- filelist.mk | 5 +++-- TransitTunnel.cpp => tunnel/TransitTunnel.cpp | 0 TransitTunnel.h => tunnel/TransitTunnel.h | 0 Tunnel.cpp => tunnel/Tunnel.cpp | 0 Tunnel.h => tunnel/Tunnel.h | 0 TunnelBase.h => tunnel/TunnelBase.h | 0 TunnelConfig.h => tunnel/TunnelConfig.h | 0 TunnelEndpoint.cpp => tunnel/TunnelEndpoint.cpp | 0 TunnelEndpoint.h => tunnel/TunnelEndpoint.h | 0 TunnelGateway.cpp => tunnel/TunnelGateway.cpp | 0 TunnelGateway.h => tunnel/TunnelGateway.h | 0 TunnelPool.cpp => tunnel/TunnelPool.cpp | 0 TunnelPool.h => tunnel/TunnelPool.h | 0 29 files changed, 28 insertions(+), 24 deletions(-) rename TransitTunnel.cpp => tunnel/TransitTunnel.cpp (100%) rename TransitTunnel.h => tunnel/TransitTunnel.h (100%) rename Tunnel.cpp => tunnel/Tunnel.cpp (100%) rename Tunnel.h => tunnel/Tunnel.h (100%) rename TunnelBase.h => tunnel/TunnelBase.h (100%) rename TunnelConfig.h => tunnel/TunnelConfig.h (100%) rename TunnelEndpoint.cpp => tunnel/TunnelEndpoint.cpp (100%) rename TunnelEndpoint.h => tunnel/TunnelEndpoint.h (100%) rename TunnelGateway.cpp => tunnel/TunnelGateway.cpp (100%) rename TunnelGateway.h => tunnel/TunnelGateway.h (100%) rename TunnelPool.cpp => tunnel/TunnelPool.cpp (100%) rename TunnelPool.h => tunnel/TunnelPool.h (100%) diff --git a/Daemon.cpp b/Daemon.cpp index 2c52cfc1..46ab2eb2 100644 --- a/Daemon.cpp +++ b/Daemon.cpp @@ -8,7 +8,7 @@ #include "transport/NTCPSession.h" #include "RouterInfo.h" #include "RouterContext.h" -#include "Tunnel.h" +#include "tunnel/Tunnel.h" #include "NetDb.h" #include "Garlic.h" #include "util/util.h" diff --git a/Datagram.cpp b/Datagram.cpp index a4ad5086..c5d4311b 100644 --- a/Datagram.cpp +++ b/Datagram.cpp @@ -3,7 +3,7 @@ #include #include #include "util/Log.h" -#include "TunnelBase.h" +#include "tunnel/TunnelBase.h" #include "RouterContext.h" #include "Destination.h" #include "Datagram.h" diff --git a/Destination.h b/Destination.h index fdad4426..789474e2 100644 --- a/Destination.h +++ b/Destination.h @@ -10,7 +10,7 @@ #include #include #include "Identity.h" -#include "TunnelPool.h" +#include "tunnel/TunnelPool.h" #include "crypto/CryptoConst.h" #include "LeaseSet.h" #include "Garlic.h" diff --git a/Garlic.cpp b/Garlic.cpp index e611addd..3b9e4b43 100644 --- a/Garlic.cpp +++ b/Garlic.cpp @@ -4,8 +4,8 @@ #include #include "RouterContext.h" #include "I2NPProtocol.h" -#include "Tunnel.h" -#include "TunnelPool.h" +#include "tunnel/Tunnel.h" +#include "tunnel/TunnelPool.h" #include "util/Timestamp.h" #include "Destination.h" #include "Garlic.h" diff --git a/HTTPServer.cpp b/HTTPServer.cpp index b45160ca..2419b386 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -3,8 +3,8 @@ #include #include "util/base64.h" #include "util/Log.h" -#include "Tunnel.h" -#include "TransitTunnel.h" +#include "tunnel/Tunnel.h" +#include "tunnel/TransitTunnel.h" #include "transport/Transports.h" #include "NetDb.h" #include "util/I2PEndian.h" diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index 7a579825..82a015d1 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -6,7 +6,7 @@ #include "util/Timestamp.h" #include "RouterContext.h" #include "NetDb.h" -#include "Tunnel.h" +#include "tunnel/Tunnel.h" #include "transport/Transports.h" #include "Garlic.h" #include "I2NPProtocol.h" diff --git a/I2PControl.cpp b/I2PControl.cpp index feeacb6d..4e993aa9 100644 --- a/I2PControl.cpp +++ b/I2PControl.cpp @@ -13,7 +13,7 @@ #include "NetDb.h" #include "RouterContext.h" #include "Daemon.h" -#include "Tunnel.h" +#include "tunnel/Tunnel.h" #include "util/Timestamp.h" #include "transport/Transports.h" #include "version.h" diff --git a/LeaseSet.cpp b/LeaseSet.cpp index 98acec26..15771f65 100644 --- a/LeaseSet.cpp +++ b/LeaseSet.cpp @@ -6,7 +6,7 @@ #include "util/Log.h" #include "util/Timestamp.h" #include "NetDb.h" -#include "TunnelPool.h" +#include "tunnel/TunnelPool.h" #include "LeaseSet.h" namespace i2p diff --git a/Makefile b/Makefile index e97812fa..cd4961f4 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,7 @@ mk_build_dir: mkdir -p obj/transport mkdir -p obj/util mkdir -p obj/crypto + mkdir -p obj/tunnel mk_build_test_dir: mkdir -p obj/tests @@ -49,6 +50,7 @@ deps: @mkdir -p obj/tests @mkdir -p obj/util @mkdir -p obj/crypto + @mkdir -p obj/tunnel $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) -MM *.cpp > $(DEPS) @sed -i -e '/\.o:/ s/^/obj\//' $(DEPS) @@ -58,6 +60,7 @@ obj/%.o : %.cpp @mkdir -p obj/tests @mkdir -p obj/util @mkdir -p obj/crypto + @mkdir -p obj/tunnel $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) $(CPU_FLAGS) -c -o $@ $< # '-' is 'ignore if missing' on first run diff --git a/NetDb.cpp b/NetDb.cpp index 248b956e..23d69226 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -8,7 +8,7 @@ #include "util/Log.h" #include "util/Timestamp.h" #include "I2NPProtocol.h" -#include "Tunnel.h" +#include "tunnel/Tunnel.h" #include "transport/Transports.h" #include "RouterContext.h" #include "Garlic.h" diff --git a/NetDb.h b/NetDb.h index 31983919..84280332 100644 --- a/NetDb.h +++ b/NetDb.h @@ -13,8 +13,8 @@ #include "I2NPProtocol.h" #include "RouterInfo.h" #include "LeaseSet.h" -#include "Tunnel.h" -#include "TunnelPool.h" +#include "tunnel/Tunnel.h" +#include "tunnel/TunnelPool.h" #include "Reseed.h" #include "NetDbRequests.h" diff --git a/Streaming.cpp b/Streaming.cpp index 9c891994..8b95139f 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -2,7 +2,7 @@ #include "util/Log.h" #include "RouterInfo.h" #include "RouterContext.h" -#include "Tunnel.h" +#include "tunnel/Tunnel.h" #include "util/Timestamp.h" #include "Destination.h" #include "Streaming.h" diff --git a/Streaming.h b/Streaming.h index 562d5a8e..370d1822 100644 --- a/Streaming.h +++ b/Streaming.h @@ -16,7 +16,7 @@ #include "LeaseSet.h" #include "I2NPProtocol.h" #include "Garlic.h" -#include "Tunnel.h" +#include "tunnel/Tunnel.h" namespace i2p { diff --git a/api.cpp b/api.cpp index 17d6fdac..cd24d15a 100644 --- a/api.cpp +++ b/api.cpp @@ -3,7 +3,7 @@ #include "util/Log.h" #include "NetDb.h" #include "transport/Transports.h" -#include "Tunnel.h" +#include "tunnel/Tunnel.h" #include "RouterContext.h" #include "Identity.h" #include "Destination.h" diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index bbcfa01a..058d0810 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -26,6 +26,11 @@ set (COMMON_SRC "${CMAKE_SOURCE_DIR}/util/base64.cpp" "${CMAKE_SOURCE_DIR}/util/util.cpp" "${CMAKE_SOURCE_DIR}/util/Log.cpp" + "${CMAKE_SOURCE_DIR}/tunnel/TransitTunnel.cpp" + "${CMAKE_SOURCE_DIR}/tunnel/Tunnel.cpp" + "${CMAKE_SOURCE_DIR}/tunnel/TunnelGateway.cpp" + "${CMAKE_SOURCE_DIR}/tunnel/TunnelEndpoint.cpp" + "${CMAKE_SOURCE_DIR}/tunnel/TunnelPool.cpp" "${CMAKE_SOURCE_DIR}/AddressBook.cpp" "${CMAKE_SOURCE_DIR}/Garlic.cpp" "${CMAKE_SOURCE_DIR}/I2NPProtocol.cpp" @@ -39,11 +44,6 @@ set (COMMON_SRC "${CMAKE_SOURCE_DIR}/RouterInfo.cpp" "${CMAKE_SOURCE_DIR}/Streaming.cpp" "${CMAKE_SOURCE_DIR}/Destination.cpp" - "${CMAKE_SOURCE_DIR}/TransitTunnel.cpp" - "${CMAKE_SOURCE_DIR}/Tunnel.cpp" - "${CMAKE_SOURCE_DIR}/TunnelGateway.cpp" - "${CMAKE_SOURCE_DIR}/TunnelEndpoint.cpp" - "${CMAKE_SOURCE_DIR}/TunnelPool.cpp" "${CMAKE_SOURCE_DIR}/Datagram.cpp" "${CMAKE_SOURCE_DIR}/UPnP.cpp" ) diff --git a/crypto/aes.cpp b/crypto/aes.cpp index fe354b9f..8b89f22f 100644 --- a/crypto/aes.cpp +++ b/crypto/aes.cpp @@ -1,5 +1,5 @@ #include -#include "TunnelBase.h" +#include "tunnel/TunnelBase.h" #include "aes.h" namespace i2p diff --git a/filelist.mk b/filelist.mk index e0a66f04..4e88d5a5 100644 --- a/filelist.mk +++ b/filelist.mk @@ -3,11 +3,12 @@ COMMON_SRC = \ transport/SSUData.cpp transport/Transports.cpp \ util/util.cpp util/base64.cpp util/Log.cpp \ crypto/CryptoConst.cpp crypto/aes.cpp crypto/Signature.cpp \ + tunnel/Tunnel.cpp tunnel/TransitTunnel.cpp tunnel/TunnelEndpoint.cpp \ + tunnel/TunnelEndpoint.cpp tunnel/TunnelPool.cpp tunnel/TunnelGateway.cpp \ Datagram.cpp Garlic.cpp I2NPProtocol.cpp LeaseSet.cpp \ NetDb.cpp NetDbRequests.cpp Profiling.cpp Reseed.cpp \ RouterContext.cpp RouterInfo.cpp Streaming.cpp Identity.cpp \ - TransitTunnel.cpp Tunnel.cpp TunnelEndpoint.cpp TunnelPool.cpp \ - TunnelGateway.cpp Destination.cpp UPnP.cpp + Destination.cpp UPnP.cpp ifeq ($(UNAME),Darwin) diff --git a/TransitTunnel.cpp b/tunnel/TransitTunnel.cpp similarity index 100% rename from TransitTunnel.cpp rename to tunnel/TransitTunnel.cpp diff --git a/TransitTunnel.h b/tunnel/TransitTunnel.h similarity index 100% rename from TransitTunnel.h rename to tunnel/TransitTunnel.h diff --git a/Tunnel.cpp b/tunnel/Tunnel.cpp similarity index 100% rename from Tunnel.cpp rename to tunnel/Tunnel.cpp diff --git a/Tunnel.h b/tunnel/Tunnel.h similarity index 100% rename from Tunnel.h rename to tunnel/Tunnel.h diff --git a/TunnelBase.h b/tunnel/TunnelBase.h similarity index 100% rename from TunnelBase.h rename to tunnel/TunnelBase.h diff --git a/TunnelConfig.h b/tunnel/TunnelConfig.h similarity index 100% rename from TunnelConfig.h rename to tunnel/TunnelConfig.h diff --git a/TunnelEndpoint.cpp b/tunnel/TunnelEndpoint.cpp similarity index 100% rename from TunnelEndpoint.cpp rename to tunnel/TunnelEndpoint.cpp diff --git a/TunnelEndpoint.h b/tunnel/TunnelEndpoint.h similarity index 100% rename from TunnelEndpoint.h rename to tunnel/TunnelEndpoint.h diff --git a/TunnelGateway.cpp b/tunnel/TunnelGateway.cpp similarity index 100% rename from TunnelGateway.cpp rename to tunnel/TunnelGateway.cpp diff --git a/TunnelGateway.h b/tunnel/TunnelGateway.h similarity index 100% rename from TunnelGateway.h rename to tunnel/TunnelGateway.h diff --git a/TunnelPool.cpp b/tunnel/TunnelPool.cpp similarity index 100% rename from TunnelPool.cpp rename to tunnel/TunnelPool.cpp diff --git a/TunnelPool.h b/tunnel/TunnelPool.h similarity index 100% rename from TunnelPool.h rename to tunnel/TunnelPool.h From 959791718349e576774f41bfb85e04700933b54e Mon Sep 17 00:00:00 2001 From: EinMByte Date: Thu, 30 Jul 2015 17:27:47 +0200 Subject: [PATCH 11/11] Split tunnel-specific crypto from aes.h/cpp. --- AESNIMacros.h | 66 +++++ build/CMakeLists.txt | 1 + crypto/aes.cpp | 541 +++++++++++++++------------------------- crypto/aes.h | 44 ---- filelist.mk | 2 +- tunnel/TransitTunnel.h | 2 +- tunnel/TunnelConfig.h | 2 +- tunnel/TunnelCrypto.cpp | 88 +++++++ tunnel/TunnelCrypto.h | 49 ++++ 9 files changed, 410 insertions(+), 385 deletions(-) create mode 100644 AESNIMacros.h create mode 100644 tunnel/TunnelCrypto.cpp create mode 100644 tunnel/TunnelCrypto.h diff --git a/AESNIMacros.h b/AESNIMacros.h new file mode 100644 index 00000000..5fb16a73 --- /dev/null +++ b/AESNIMacros.h @@ -0,0 +1,66 @@ +#ifndef AESNIMACROS_H__ +#define AESNIMACROS_H__ + +#define KeyExpansion256(round0,round1) \ + "pshufd $0xff, %%xmm2, %%xmm2 \n" \ + "movaps %%xmm1, %%xmm4 \n" \ + "pslldq $4, %%xmm4 \n" \ + "pxor %%xmm4, %%xmm1 \n" \ + "pslldq $4, %%xmm4 \n" \ + "pxor %%xmm4, %%xmm1 \n" \ + "pslldq $4, %%xmm4 \n" \ + "pxor %%xmm4, %%xmm1 \n" \ + "pxor %%xmm2, %%xmm1 \n" \ + "movaps %%xmm1, "#round0"(%[sched]) \n" \ + "aeskeygenassist $0, %%xmm1, %%xmm4 \n" \ + "pshufd $0xaa, %%xmm4, %%xmm2 \n" \ + "movaps %%xmm3, %%xmm4 \n" \ + "pslldq $4, %%xmm4 \n" \ + "pxor %%xmm4, %%xmm3 \n" \ + "pslldq $4, %%xmm4 \n" \ + "pxor %%xmm4, %%xmm3 \n" \ + "pslldq $4, %%xmm4 \n" \ + "pxor %%xmm4, %%xmm3 \n" \ + "pxor %%xmm2, %%xmm3 \n" \ + "movaps %%xmm3, "#round1"(%[sched]) \n" + +#define EncryptAES256(sched) \ + "pxor (%["#sched"]), %%xmm0 \n" \ + "aesenc 16(%["#sched"]), %%xmm0 \n" \ + "aesenc 32(%["#sched"]), %%xmm0 \n" \ + "aesenc 48(%["#sched"]), %%xmm0 \n" \ + "aesenc 64(%["#sched"]), %%xmm0 \n" \ + "aesenc 80(%["#sched"]), %%xmm0 \n" \ + "aesenc 96(%["#sched"]), %%xmm0 \n" \ + "aesenc 112(%["#sched"]), %%xmm0 \n" \ + "aesenc 128(%["#sched"]), %%xmm0 \n" \ + "aesenc 144(%["#sched"]), %%xmm0 \n" \ + "aesenc 160(%["#sched"]), %%xmm0 \n" \ + "aesenc 176(%["#sched"]), %%xmm0 \n" \ + "aesenc 192(%["#sched"]), %%xmm0 \n" \ + "aesenc 208(%["#sched"]), %%xmm0 \n" \ + "aesenclast 224(%["#sched"]), %%xmm0 \n" + +#define DecryptAES256(sched) \ + "pxor 224(%["#sched"]), %%xmm0 \n" \ + "aesdec 208(%["#sched"]), %%xmm0 \n" \ + "aesdec 192(%["#sched"]), %%xmm0 \n" \ + "aesdec 176(%["#sched"]), %%xmm0 \n" \ + "aesdec 160(%["#sched"]), %%xmm0 \n" \ + "aesdec 144(%["#sched"]), %%xmm0 \n" \ + "aesdec 128(%["#sched"]), %%xmm0 \n" \ + "aesdec 112(%["#sched"]), %%xmm0 \n" \ + "aesdec 96(%["#sched"]), %%xmm0 \n" \ + "aesdec 80(%["#sched"]), %%xmm0 \n" \ + "aesdec 64(%["#sched"]), %%xmm0 \n" \ + "aesdec 48(%["#sched"]), %%xmm0 \n" \ + "aesdec 32(%["#sched"]), %%xmm0 \n" \ + "aesdec 16(%["#sched"]), %%xmm0 \n" \ + "aesdeclast (%["#sched"]), %%xmm0 \n" + +#define CallAESIMC(offset) \ + "movaps "#offset"(%[shed]), %%xmm0 \n" \ + "aesimc %%xmm0, %%xmm0 \n" \ + "movaps %%xmm0, "#offset"(%[shed]) \n" + +#endif diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 058d0810..f7f85a16 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -31,6 +31,7 @@ set (COMMON_SRC "${CMAKE_SOURCE_DIR}/tunnel/TunnelGateway.cpp" "${CMAKE_SOURCE_DIR}/tunnel/TunnelEndpoint.cpp" "${CMAKE_SOURCE_DIR}/tunnel/TunnelPool.cpp" + "${CMAKE_SOURCE_DIR}/tunnel/TunnelCrypto.cpp" "${CMAKE_SOURCE_DIR}/AddressBook.cpp" "${CMAKE_SOURCE_DIR}/Garlic.cpp" "${CMAKE_SOURCE_DIR}/I2NPProtocol.cpp" diff --git a/crypto/aes.cpp b/crypto/aes.cpp index 8b89f22f..a4fee883 100644 --- a/crypto/aes.cpp +++ b/crypto/aes.cpp @@ -1,357 +1,222 @@ #include -#include "tunnel/TunnelBase.h" #include "aes.h" -namespace i2p -{ -namespace crypto -{ +namespace i2p { +namespace crypto { #ifdef AESNI - - #define KeyExpansion256(round0,round1) \ - "pshufd $0xff, %%xmm2, %%xmm2 \n" \ - "movaps %%xmm1, %%xmm4 \n" \ - "pslldq $4, %%xmm4 \n" \ - "pxor %%xmm4, %%xmm1 \n" \ - "pslldq $4, %%xmm4 \n" \ - "pxor %%xmm4, %%xmm1 \n" \ - "pslldq $4, %%xmm4 \n" \ - "pxor %%xmm4, %%xmm1 \n" \ - "pxor %%xmm2, %%xmm1 \n" \ - "movaps %%xmm1, "#round0"(%[sched]) \n" \ - "aeskeygenassist $0, %%xmm1, %%xmm4 \n" \ - "pshufd $0xaa, %%xmm4, %%xmm2 \n" \ - "movaps %%xmm3, %%xmm4 \n" \ - "pslldq $4, %%xmm4 \n" \ - "pxor %%xmm4, %%xmm3 \n" \ - "pslldq $4, %%xmm4 \n" \ - "pxor %%xmm4, %%xmm3 \n" \ - "pslldq $4, %%xmm4 \n" \ - "pxor %%xmm4, %%xmm3 \n" \ - "pxor %%xmm2, %%xmm3 \n" \ - "movaps %%xmm3, "#round1"(%[sched]) \n" +#include "AESNIMacros.h" - void ECBCryptoAESNI::ExpandKey (const AESKey& key) - { - __asm__ - ( - "movups (%[key]), %%xmm1 \n" - "movups 16(%[key]), %%xmm3 \n" - "movaps %%xmm1, (%[sched]) \n" - "movaps %%xmm3, 16(%[sched]) \n" - "aeskeygenassist $1, %%xmm3, %%xmm2 \n" - KeyExpansion256(32,48) - "aeskeygenassist $2, %%xmm3, %%xmm2 \n" - KeyExpansion256(64,80) - "aeskeygenassist $4, %%xmm3, %%xmm2 \n" - KeyExpansion256(96,112) - "aeskeygenassist $8, %%xmm3, %%xmm2 \n" - KeyExpansion256(128,144) - "aeskeygenassist $16, %%xmm3, %%xmm2 \n" - KeyExpansion256(160,176) - "aeskeygenassist $32, %%xmm3, %%xmm2 \n" - KeyExpansion256(192,208) - "aeskeygenassist $64, %%xmm3, %%xmm2 \n" - // key expansion final - "pshufd $0xff, %%xmm2, %%xmm2 \n" - "movaps %%xmm1, %%xmm4 \n" - "pslldq $4, %%xmm4 \n" - "pxor %%xmm4, %%xmm1 \n" - "pslldq $4, %%xmm4 \n" - "pxor %%xmm4, %%xmm1 \n" - "pslldq $4, %%xmm4 \n" - "pxor %%xmm4, %%xmm1 \n" - "pxor %%xmm2, %%xmm1 \n" - "movups %%xmm1, 224(%[sched]) \n" - : // output - : [key]"r"((const uint8_t *)key), [sched]"r"(GetKeySchedule ()) // input - : "%xmm1", "%xmm2", "%xmm3", "%xmm4", "memory" // clogged - ); - } +void ECBCryptoAESNI::ExpandKey (const AESKey& key) +{ + __asm__ + ( + "movups (%[key]), %%xmm1 \n" + "movups 16(%[key]), %%xmm3 \n" + "movaps %%xmm1, (%[sched]) \n" + "movaps %%xmm3, 16(%[sched]) \n" + "aeskeygenassist $1, %%xmm3, %%xmm2 \n" + KeyExpansion256(32,48) + "aeskeygenassist $2, %%xmm3, %%xmm2 \n" + KeyExpansion256(64,80) + "aeskeygenassist $4, %%xmm3, %%xmm2 \n" + KeyExpansion256(96,112) + "aeskeygenassist $8, %%xmm3, %%xmm2 \n" + KeyExpansion256(128,144) + "aeskeygenassist $16, %%xmm3, %%xmm2 \n" + KeyExpansion256(160,176) + "aeskeygenassist $32, %%xmm3, %%xmm2 \n" + KeyExpansion256(192,208) + "aeskeygenassist $64, %%xmm3, %%xmm2 \n" + // key expansion final + "pshufd $0xff, %%xmm2, %%xmm2 \n" + "movaps %%xmm1, %%xmm4 \n" + "pslldq $4, %%xmm4 \n" + "pxor %%xmm4, %%xmm1 \n" + "pslldq $4, %%xmm4 \n" + "pxor %%xmm4, %%xmm1 \n" + "pslldq $4, %%xmm4 \n" + "pxor %%xmm4, %%xmm1 \n" + "pxor %%xmm2, %%xmm1 \n" + "movups %%xmm1, 224(%[sched]) \n" + : // output + : [key]"r"((const uint8_t *)key), [sched]"r"(GetKeySchedule ()) // input + : "%xmm1", "%xmm2", "%xmm3", "%xmm4", "memory" // clogged + ); +} - #define EncryptAES256(sched) \ - "pxor (%["#sched"]), %%xmm0 \n" \ - "aesenc 16(%["#sched"]), %%xmm0 \n" \ - "aesenc 32(%["#sched"]), %%xmm0 \n" \ - "aesenc 48(%["#sched"]), %%xmm0 \n" \ - "aesenc 64(%["#sched"]), %%xmm0 \n" \ - "aesenc 80(%["#sched"]), %%xmm0 \n" \ - "aesenc 96(%["#sched"]), %%xmm0 \n" \ - "aesenc 112(%["#sched"]), %%xmm0 \n" \ - "aesenc 128(%["#sched"]), %%xmm0 \n" \ - "aesenc 144(%["#sched"]), %%xmm0 \n" \ - "aesenc 160(%["#sched"]), %%xmm0 \n" \ - "aesenc 176(%["#sched"]), %%xmm0 \n" \ - "aesenc 192(%["#sched"]), %%xmm0 \n" \ - "aesenc 208(%["#sched"]), %%xmm0 \n" \ - "aesenclast 224(%["#sched"]), %%xmm0 \n" - - void ECBEncryptionAESNI::Encrypt (const ChipherBlock * in, ChipherBlock * out) - { - __asm__ - ( - "movups (%[in]), %%xmm0 \n" - EncryptAES256(sched) - "movups %%xmm0, (%[out]) \n" - : : [sched]"r"(GetKeySchedule ()), [in]"r"(in), [out]"r"(out) : "%xmm0", "memory" - ); - } +void ECBEncryptionAESNI::Encrypt (const ChipherBlock * in, ChipherBlock * out) +{ + __asm__ + ( + "movups (%[in]), %%xmm0 \n" + EncryptAES256(sched) + "movups %%xmm0, (%[out]) \n" + : : [sched]"r"(GetKeySchedule ()), [in]"r"(in), [out]"r"(out) : "%xmm0", "memory" + ); +} - #define DecryptAES256(sched) \ - "pxor 224(%["#sched"]), %%xmm0 \n" \ - "aesdec 208(%["#sched"]), %%xmm0 \n" \ - "aesdec 192(%["#sched"]), %%xmm0 \n" \ - "aesdec 176(%["#sched"]), %%xmm0 \n" \ - "aesdec 160(%["#sched"]), %%xmm0 \n" \ - "aesdec 144(%["#sched"]), %%xmm0 \n" \ - "aesdec 128(%["#sched"]), %%xmm0 \n" \ - "aesdec 112(%["#sched"]), %%xmm0 \n" \ - "aesdec 96(%["#sched"]), %%xmm0 \n" \ - "aesdec 80(%["#sched"]), %%xmm0 \n" \ - "aesdec 64(%["#sched"]), %%xmm0 \n" \ - "aesdec 48(%["#sched"]), %%xmm0 \n" \ - "aesdec 32(%["#sched"]), %%xmm0 \n" \ - "aesdec 16(%["#sched"]), %%xmm0 \n" \ - "aesdeclast (%["#sched"]), %%xmm0 \n" - - void ECBDecryptionAESNI::Decrypt (const ChipherBlock * in, ChipherBlock * out) - { - __asm__ - ( - "movups (%[in]), %%xmm0 \n" - DecryptAES256(sched) - "movups %%xmm0, (%[out]) \n" - : : [sched]"r"(GetKeySchedule ()), [in]"r"(in), [out]"r"(out) : "%xmm0", "memory" - ); - } - #define CallAESIMC(offset) \ - "movaps "#offset"(%[shed]), %%xmm0 \n" \ - "aesimc %%xmm0, %%xmm0 \n" \ - "movaps %%xmm0, "#offset"(%[shed]) \n" +void ECBDecryptionAESNI::Decrypt (const ChipherBlock * in, ChipherBlock * out) +{ + __asm__ + ( + "movups (%[in]), %%xmm0 \n" + DecryptAES256(sched) + "movups %%xmm0, (%[out]) \n" + : : [sched]"r"(GetKeySchedule ()), [in]"r"(in), [out]"r"(out) : "%xmm0", "memory" + ); +} - void ECBDecryptionAESNI::SetKey (const AESKey& key) - { - ExpandKey (key); // expand encryption key first - // then invert it using aesimc - __asm__ - ( - CallAESIMC(16) - CallAESIMC(32) - CallAESIMC(48) - CallAESIMC(64) - CallAESIMC(80) - CallAESIMC(96) - CallAESIMC(112) - CallAESIMC(128) - CallAESIMC(144) - CallAESIMC(160) - CallAESIMC(176) - CallAESIMC(192) - CallAESIMC(208) - : : [shed]"r"(GetKeySchedule ()) : "%xmm0", "memory" - ); - } +void ECBDecryptionAESNI::SetKey (const AESKey& key) +{ + ExpandKey (key); // expand encryption key first + // then invert it using aesimc + __asm__ + ( + CallAESIMC(16) + CallAESIMC(32) + CallAESIMC(48) + CallAESIMC(64) + CallAESIMC(80) + CallAESIMC(96) + CallAESIMC(112) + CallAESIMC(128) + CallAESIMC(144) + CallAESIMC(160) + CallAESIMC(176) + CallAESIMC(192) + CallAESIMC(208) + : : [shed]"r"(GetKeySchedule ()) : "%xmm0", "memory" + ); +} #endif - void CBCEncryption::Encrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out) - { +void CBCEncryption::Encrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out) +{ #ifdef AESNI - __asm__ - ( - "movups (%[iv]), %%xmm1 \n" - "1: \n" - "movups (%[in]), %%xmm0 \n" - "pxor %%xmm1, %%xmm0 \n" - EncryptAES256(sched) - "movaps %%xmm0, %%xmm1 \n" - "movups %%xmm0, (%[out]) \n" - "add $16, %[in] \n" - "add $16, %[out] \n" - "dec %[num] \n" - "jnz 1b \n" - "movups %%xmm1, (%[iv]) \n" - : - : [iv]"r"(&m_LastBlock), [sched]"r"(m_ECBEncryption.GetKeySchedule ()), - [in]"r"(in), [out]"r"(out), [num]"r"(numBlocks) - : "%xmm0", "%xmm1", "cc", "memory" - ); + __asm__ + ( + "movups (%[iv]), %%xmm1 \n" + "1: \n" + "movups (%[in]), %%xmm0 \n" + "pxor %%xmm1, %%xmm0 \n" + EncryptAES256(sched) + "movaps %%xmm0, %%xmm1 \n" + "movups %%xmm0, (%[out]) \n" + "add $16, %[in] \n" + "add $16, %[out] \n" + "dec %[num] \n" + "jnz 1b \n" + "movups %%xmm1, (%[iv]) \n" + : + : [iv]"r"(&m_LastBlock), [sched]"r"(m_ECBEncryption.GetKeySchedule ()), + [in]"r"(in), [out]"r"(out), [num]"r"(numBlocks) + : "%xmm0", "%xmm1", "cc", "memory" + ); #else - for (int i = 0; i < numBlocks; i++) - { - m_LastBlock ^= in[i]; - m_ECBEncryption.Encrypt (&m_LastBlock, &m_LastBlock); - out[i] = m_LastBlock; - } + for (int i = 0; i < numBlocks; i++) + { + m_LastBlock ^= in[i]; + m_ECBEncryption.Encrypt (&m_LastBlock, &m_LastBlock); + out[i] = m_LastBlock; + } #endif - } - - void CBCEncryption::Encrypt (const uint8_t * in, std::size_t len, uint8_t * out) - { - // len/16 - int numBlocks = len >> 4; - if (numBlocks > 0) - Encrypt (numBlocks, (const ChipherBlock *)in, (ChipherBlock *)out); - } - - void CBCEncryption::Encrypt (const uint8_t * in, uint8_t * out) - { -#ifdef AESNI - __asm__ - ( - "movups (%[iv]), %%xmm1 \n" - "movups (%[in]), %%xmm0 \n" - "pxor %%xmm1, %%xmm0 \n" - EncryptAES256(sched) - "movups %%xmm0, (%[out]) \n" - "movups %%xmm0, (%[iv]) \n" - : - : [iv]"r"(&m_LastBlock), [sched]"r"(m_ECBEncryption.GetKeySchedule ()), - [in]"r"(in), [out]"r"(out) - : "%xmm0", "%xmm1", "memory" - ); -#else - Encrypt (1, (const ChipherBlock *)in, (ChipherBlock *)out); -#endif - } - - void CBCDecryption::Decrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out) - { -#ifdef AESNI - __asm__ - ( - "movups (%[iv]), %%xmm1 \n" - "1: \n" - "movups (%[in]), %%xmm0 \n" - "movaps %%xmm0, %%xmm2 \n" - DecryptAES256(sched) - "pxor %%xmm1, %%xmm0 \n" - "movups %%xmm0, (%[out]) \n" - "movaps %%xmm2, %%xmm1 \n" - "add $16, %[in] \n" - "add $16, %[out] \n" - "dec %[num] \n" - "jnz 1b \n" - "movups %%xmm1, (%[iv]) \n" - : - : [iv]"r"(&m_IV), [sched]"r"(m_ECBDecryption.GetKeySchedule ()), - [in]"r"(in), [out]"r"(out), [num]"r"(numBlocks) - : "%xmm0", "%xmm1", "%xmm2", "cc", "memory" - ); -#else - for (int i = 0; i < numBlocks; i++) - { - ChipherBlock tmp = in[i]; - m_ECBDecryption.Decrypt (in + i, out + i); - out[i] ^= m_IV; - m_IV = tmp; - } -#endif - } - - void CBCDecryption::Decrypt (const uint8_t * in, std::size_t len, uint8_t * out) - { - int numBlocks = len >> 4; - if (numBlocks > 0) - Decrypt (numBlocks, (const ChipherBlock *)in, (ChipherBlock *)out); - } - - void CBCDecryption::Decrypt (const uint8_t * in, uint8_t * out) - { -#ifdef AESNI - __asm__ - ( - "movups (%[iv]), %%xmm1 \n" - "movups (%[in]), %%xmm0 \n" - "movups %%xmm0, (%[iv]) \n" - DecryptAES256(sched) - "pxor %%xmm1, %%xmm0 \n" - "movups %%xmm0, (%[out]) \n" - : - : [iv]"r"(&m_IV), [sched]"r"(m_ECBDecryption.GetKeySchedule ()), - [in]"r"(in), [out]"r"(out) - : "%xmm0", "%xmm1", "memory" - ); -#else - Decrypt (1, (const ChipherBlock *)in, (ChipherBlock *)out); -#endif - } - - void TunnelEncryption::Encrypt (const uint8_t * in, uint8_t * out) - { -#ifdef AESNI - __asm__ - ( - // encrypt IV - "movups (%[in]), %%xmm0 \n" - EncryptAES256(sched_iv) - "movaps %%xmm0, %%xmm1 \n" - // double IV encryption - EncryptAES256(sched_iv) - "movups %%xmm0, (%[out]) \n" - // encrypt data, IV is xmm1 - "1: \n" - "add $16, %[in] \n" - "add $16, %[out] \n" - "movups (%[in]), %%xmm0 \n" - "pxor %%xmm1, %%xmm0 \n" - EncryptAES256(sched_l) - "movaps %%xmm0, %%xmm1 \n" - "movups %%xmm0, (%[out]) \n" - "dec %[num] \n" - "jnz 1b \n" - : - : [sched_iv]"r"(m_IVEncryption.GetKeySchedule ()), [sched_l]"r"(m_LayerEncryption.GetKeySchedule ()), - [in]"r"(in), [out]"r"(out), [num]"r"(63) // 63 blocks = 1008 bytes - : "%xmm0", "%xmm1", "cc", "memory" - ); -#else - m_IVEncryption.Encrypt ((const ChipherBlock *)in, (ChipherBlock *)out); // iv - m_LayerEncryption.SetIV (out); - m_LayerEncryption.Encrypt (in + 16, i2p::tunnel::TUNNEL_DATA_ENCRYPTED_SIZE, out + 16); // data - m_IVEncryption.Encrypt ((ChipherBlock *)out, (ChipherBlock *)out); // double iv -#endif - } - - void TunnelDecryption::Decrypt (const uint8_t * in, uint8_t * out) - { -#ifdef AESNI - __asm__ - ( - // decrypt IV - "movups (%[in]), %%xmm0 \n" - DecryptAES256(sched_iv) - "movaps %%xmm0, %%xmm1 \n" - // double IV encryption - DecryptAES256(sched_iv) - "movups %%xmm0, (%[out]) \n" - // decrypt data, IV is xmm1 - "1: \n" - "add $16, %[in] \n" - "add $16, %[out] \n" - "movups (%[in]), %%xmm0 \n" - "movaps %%xmm0, %%xmm2 \n" - DecryptAES256(sched_l) - "pxor %%xmm1, %%xmm0 \n" - "movups %%xmm0, (%[out]) \n" - "movaps %%xmm2, %%xmm1 \n" - "dec %[num] \n" - "jnz 1b \n" - : - : [sched_iv]"r"(m_IVDecryption.GetKeySchedule ()), [sched_l]"r"(m_LayerDecryption.GetKeySchedule ()), - [in]"r"(in), [out]"r"(out), [num]"r"(63) // 63 blocks = 1008 bytes - : "%xmm0", "%xmm1", "%xmm2", "cc", "memory" - ); -#else - m_IVDecryption.Decrypt ((const ChipherBlock *)in, (ChipherBlock *)out); // iv - m_LayerDecryption.SetIV (out); - m_LayerDecryption.Decrypt (in + 16, i2p::tunnel::TUNNEL_DATA_ENCRYPTED_SIZE, out + 16); // data - m_IVDecryption.Decrypt ((ChipherBlock *)out, (ChipherBlock *)out); // double iv -#endif - } -} } +void CBCEncryption::Encrypt (const uint8_t * in, std::size_t len, uint8_t * out) +{ + // len/16 + int numBlocks = len >> 4; + if (numBlocks > 0) + Encrypt (numBlocks, (const ChipherBlock *)in, (ChipherBlock *)out); +} + +void CBCEncryption::Encrypt (const uint8_t * in, uint8_t * out) +{ +#ifdef AESNI + __asm__ + ( + "movups (%[iv]), %%xmm1 \n" + "movups (%[in]), %%xmm0 \n" + "pxor %%xmm1, %%xmm0 \n" + EncryptAES256(sched) + "movups %%xmm0, (%[out]) \n" + "movups %%xmm0, (%[iv]) \n" + : + : [iv]"r"(&m_LastBlock), [sched]"r"(m_ECBEncryption.GetKeySchedule ()), + [in]"r"(in), [out]"r"(out) + : "%xmm0", "%xmm1", "memory" + ); +#else + Encrypt (1, (const ChipherBlock *)in, (ChipherBlock *)out); +#endif +} + +void CBCDecryption::Decrypt (int numBlocks, const ChipherBlock * in, ChipherBlock * out) +{ +#ifdef AESNI + __asm__ + ( + "movups (%[iv]), %%xmm1 \n" + "1: \n" + "movups (%[in]), %%xmm0 \n" + "movaps %%xmm0, %%xmm2 \n" + DecryptAES256(sched) + "pxor %%xmm1, %%xmm0 \n" + "movups %%xmm0, (%[out]) \n" + "movaps %%xmm2, %%xmm1 \n" + "add $16, %[in] \n" + "add $16, %[out] \n" + "dec %[num] \n" + "jnz 1b \n" + "movups %%xmm1, (%[iv]) \n" + : + : [iv]"r"(&m_IV), [sched]"r"(m_ECBDecryption.GetKeySchedule ()), + [in]"r"(in), [out]"r"(out), [num]"r"(numBlocks) + : "%xmm0", "%xmm1", "%xmm2", "cc", "memory" + ); +#else + for (int i = 0; i < numBlocks; i++) + { + ChipherBlock tmp = in[i]; + m_ECBDecryption.Decrypt (in + i, out + i); + out[i] ^= m_IV; + m_IV = tmp; + } +#endif +} + +void CBCDecryption::Decrypt (const uint8_t * in, std::size_t len, uint8_t * out) +{ + int numBlocks = len >> 4; + if (numBlocks > 0) + Decrypt (numBlocks, (const ChipherBlock *)in, (ChipherBlock *)out); +} + +void CBCDecryption::Decrypt (const uint8_t * in, uint8_t * out) +{ +#ifdef AESNI + __asm__ + ( + "movups (%[iv]), %%xmm1 \n" + "movups (%[in]), %%xmm0 \n" + "movups %%xmm0, (%[iv]) \n" + DecryptAES256(sched) + "pxor %%xmm1, %%xmm0 \n" + "movups %%xmm0, (%[out]) \n" + : + : [iv]"r"(&m_IV), [sched]"r"(m_ECBDecryption.GetKeySchedule ()), + [in]"r"(in), [out]"r"(out) + : "%xmm0", "%xmm1", "memory" + ); +#else + Decrypt (1, (const ChipherBlock *)in, (ChipherBlock *)out); +#endif +} + +} // crypto +} // i2p + diff --git a/crypto/aes.h b/crypto/aes.h index 1751246f..6e763125 100644 --- a/crypto/aes.h +++ b/crypto/aes.h @@ -181,51 +181,7 @@ namespace crypto ECBDecryption m_ECBDecryption; }; - class TunnelEncryption // with double IV encryption - { - public: - - void SetKeys (const AESKey& layerKey, const AESKey& ivKey) - { - m_LayerEncryption.SetKey (layerKey); - m_IVEncryption.SetKey (ivKey); - } - - void Encrypt (const uint8_t * in, uint8_t * out); // 1024 bytes (16 IV + 1008 data) - - private: - - ECBEncryption m_IVEncryption; -#ifdef AESNI - ECBEncryption m_LayerEncryption; -#else - CBCEncryption m_LayerEncryption; -#endif - }; - - class TunnelDecryption // with double IV encryption - { - public: - - void SetKeys (const AESKey& layerKey, const AESKey& ivKey) - { - m_LayerDecryption.SetKey (layerKey); - m_IVDecryption.SetKey (ivKey); - } - - void Decrypt (const uint8_t * in, uint8_t * out); // 1024 bytes (16 IV + 1008 data) - - private: - - ECBDecryption m_IVDecryption; -#ifdef AESNI - ECBDecryption m_LayerDecryption; -#else - CBCDecryption m_LayerDecryption; -#endif - }; } } #endif - diff --git a/filelist.mk b/filelist.mk index 4e88d5a5..e276c1cc 100644 --- a/filelist.mk +++ b/filelist.mk @@ -5,7 +5,7 @@ COMMON_SRC = \ crypto/CryptoConst.cpp crypto/aes.cpp crypto/Signature.cpp \ tunnel/Tunnel.cpp tunnel/TransitTunnel.cpp tunnel/TunnelEndpoint.cpp \ tunnel/TunnelEndpoint.cpp tunnel/TunnelPool.cpp tunnel/TunnelGateway.cpp \ - Datagram.cpp Garlic.cpp I2NPProtocol.cpp LeaseSet.cpp \ + tunnel/TunnelCrypto.cpp Datagram.cpp Garlic.cpp I2NPProtocol.cpp LeaseSet.cpp \ NetDb.cpp NetDbRequests.cpp Profiling.cpp Reseed.cpp \ RouterContext.cpp RouterInfo.cpp Streaming.cpp Identity.cpp \ Destination.cpp UPnP.cpp diff --git a/tunnel/TransitTunnel.h b/tunnel/TransitTunnel.h index b92dca3c..e9458481 100644 --- a/tunnel/TransitTunnel.h +++ b/tunnel/TransitTunnel.h @@ -5,7 +5,7 @@ #include #include #include -#include "crypto/aes.h" +#include "TunnelCrypto.h" #include "I2NPProtocol.h" #include "TunnelEndpoint.h" #include "TunnelGateway.h" diff --git a/tunnel/TunnelConfig.h b/tunnel/TunnelConfig.h index b121c8d6..632d1a17 100644 --- a/tunnel/TunnelConfig.h +++ b/tunnel/TunnelConfig.h @@ -5,7 +5,7 @@ #include #include #include -#include "crypto/aes.h" +#include "TunnelCrypto.h" #include "RouterInfo.h" #include "RouterContext.h" #include "util/Timestamp.h" diff --git a/tunnel/TunnelCrypto.cpp b/tunnel/TunnelCrypto.cpp new file mode 100644 index 00000000..50241a19 --- /dev/null +++ b/tunnel/TunnelCrypto.cpp @@ -0,0 +1,88 @@ +#include "TunnelCrypto.h" +#include "TunnelBase.h" +#include "AESNIMacros.h" + +namespace i2p { +namespace crypto { + +void TunnelEncryption::SetKeys (const AESKey& layerKey, const AESKey& ivKey) +{ + m_LayerEncryption.SetKey (layerKey); + m_IVEncryption.SetKey (ivKey); +} + +void TunnelEncryption::Encrypt (const uint8_t * in, uint8_t * out) +{ +#ifdef AESNI + __asm__ + ( + // encrypt IV + "movups (%[in]), %%xmm0 \n" + EncryptAES256(sched_iv) + "movaps %%xmm0, %%xmm1 \n" + // double IV encryption + EncryptAES256(sched_iv) + "movups %%xmm0, (%[out]) \n" + // encrypt data, IV is xmm1 + "1: \n" + "add $16, %[in] \n" + "add $16, %[out] \n" + "movups (%[in]), %%xmm0 \n" + "pxor %%xmm1, %%xmm0 \n" + EncryptAES256(sched_l) + "movaps %%xmm0, %%xmm1 \n" + "movups %%xmm0, (%[out]) \n" + "dec %[num] \n" + "jnz 1b \n" + : + : [sched_iv]"r"(m_IVEncryption.GetKeySchedule ()), [sched_l]"r"(m_LayerEncryption.GetKeySchedule ()), + [in]"r"(in), [out]"r"(out), [num]"r"(63) // 63 blocks = 1008 bytes + : "%xmm0", "%xmm1", "cc", "memory" + ); +#else + m_IVEncryption.Encrypt ((const ChipherBlock *)in, (ChipherBlock *)out); // iv + m_LayerEncryption.SetIV (out); + m_LayerEncryption.Encrypt (in + 16, i2p::tunnel::TUNNEL_DATA_ENCRYPTED_SIZE, out + 16); // data + m_IVEncryption.Encrypt ((ChipherBlock *)out, (ChipherBlock *)out); // double iv +#endif + } + +void TunnelDecryption::Decrypt (const uint8_t * in, uint8_t * out) +{ +#ifdef AESNI + __asm__ + ( + // decrypt IV + "movups (%[in]), %%xmm0 \n" + DecryptAES256(sched_iv) + "movaps %%xmm0, %%xmm1 \n" + // double IV encryption + DecryptAES256(sched_iv) + "movups %%xmm0, (%[out]) \n" + // decrypt data, IV is xmm1 + "1: \n" + "add $16, %[in] \n" + "add $16, %[out] \n" + "movups (%[in]), %%xmm0 \n" + "movaps %%xmm0, %%xmm2 \n" + DecryptAES256(sched_l) + "pxor %%xmm1, %%xmm0 \n" + "movups %%xmm0, (%[out]) \n" + "movaps %%xmm2, %%xmm1 \n" + "dec %[num] \n" + "jnz 1b \n" + : + : [sched_iv]"r"(m_IVDecryption.GetKeySchedule ()), [sched_l]"r"(m_LayerDecryption.GetKeySchedule ()), + [in]"r"(in), [out]"r"(out), [num]"r"(63) // 63 blocks = 1008 bytes + : "%xmm0", "%xmm1", "%xmm2", "cc", "memory" + ); +#else + m_IVDecryption.Decrypt ((const ChipherBlock *)in, (ChipherBlock *)out); // iv + m_LayerDecryption.SetIV (out); + m_LayerDecryption.Decrypt (in + 16, i2p::tunnel::TUNNEL_DATA_ENCRYPTED_SIZE, out + 16); // data + m_IVDecryption.Decrypt ((ChipherBlock *)out, (ChipherBlock *)out); // double iv +#endif +} + +} // crypto +} // i2p diff --git a/tunnel/TunnelCrypto.h b/tunnel/TunnelCrypto.h new file mode 100644 index 00000000..ec01acfb --- /dev/null +++ b/tunnel/TunnelCrypto.h @@ -0,0 +1,49 @@ +#ifndef TUNNEL_CRYPTO_H__ +#define TUNNEL_CRYPTO_H__ + +#include "crypto/aes.h" + +namespace i2p { +namespace crypto { + +class TunnelEncryption { // with double IV encryption +public: + void SetKeys (const AESKey& layerKey, const AESKey& ivKey); + + void Encrypt (const uint8_t * in, uint8_t * out); // 1024 bytes (16 IV + 1008 data) + +private: + + ECBEncryption m_IVEncryption; +#ifdef AESNI + ECBEncryption m_LayerEncryption; +#else + CBCEncryption m_LayerEncryption; +#endif +}; + +class TunnelDecryption { // with double IV encryption +public: + + void SetKeys (const AESKey& layerKey, const AESKey& ivKey) + { + m_LayerDecryption.SetKey (layerKey); + m_IVDecryption.SetKey (ivKey); + } + + void Decrypt (const uint8_t * in, uint8_t * out); // 1024 bytes (16 IV + 1008 data) + +private: + + ECBDecryption m_IVDecryption; +#ifdef AESNI + ECBDecryption m_LayerDecryption; +#else + CBCDecryption m_LayerDecryption; +#endif +}; + +} // crypto +} // i2p + +#endif