Browse Source

fix keyinfo on latest gcc, update Makefile

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/86/head
R4SAS 2 years ago
parent
commit
f9348979a2
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 64
      Makefile
  2. 2
      i2pd
  3. 52
      keyinfo.cpp
  4. 4
      regaddr.cpp

64
Makefile

@ -5,82 +5,84 @@ I2PD_LIB = libi2pd.a
LIBI2PD_PATH = $(I2PD_PATH)/libi2pd LIBI2PD_PATH = $(I2PD_PATH)/libi2pd
LIBI2PD_CLIENT_PATH = $(I2PD_PATH)/libi2pd_client LIBI2PD_CLIENT_PATH = $(I2PD_PATH)/libi2pd_client
CXX ?= g++ CXX ?= g++
FLAGS = -Wall -std=c++11 -Wno-misleading-indentation CXXFLAGS = -Wall -std=c++17
INCFLAGS = -I$(LIBI2PD_PATH) -I$(LIBI2PD_CLIENT_PATH)
DEFINES = -DOPENSSL_SUPPRESS_DEPRECATED
LDFLAGS =
LDLIBS = $(I2PD_PATH)/$(I2PD_LIB) -lboost_system$(BOOST_SUFFIX) -lboost_date_time$(BOOST_SUFFIX) -lboost_filesystem$(BOOST_SUFFIX) -lboost_program_options$(BOOST_SUFFIX) -lssl -lcrypto -lz
ifeq ($(UNAME),Linux) ifeq ($(UNAME),Linux)
FLAGS += -g CXXFLAGS += -g
else ifeq ($(UNAME),Darwin) else ifeq ($(UNAME),Darwin)
FLAGS += -g CXXFLAGS += -g
else ifeq ($(UNAME),FreeBSD) else ifeq ($(UNAME),FreeBSD)
FLAGS += -g CXXFLAGS += -g
else else
# Win32 # Win32
FLAGS += -Os -D_MT -DWIN32 -D_WINDOWS -DWIN32_LEAN_AND_MEAN CXXFLAGS += -Os -fPIC -msse
DEFINES += -DWIN32_LEAN_AND_MEAN
BOOST_SUFFIX = -mt BOOST_SUFFIX = -mt
endif endif
INCFLAGS = -I$(LIBI2PD_PATH) -I$(LIBI2PD_CLIENT_PATH)
CXXFLAGS = $(FLAGS)
LDFLAGS =
LIBS = $(I2PD_PATH)/$(I2PD_LIB) -lboost_system$(BOOST_SUFFIX) -lboost_date_time$(BOOST_SUFFIX) -lboost_filesystem$(BOOST_SUFFIX) -lboost_program_options$(BOOST_SUFFIX) -lssl -lcrypto -lz
ifeq ($(UNAME),Linux) ifeq ($(UNAME),Linux)
LIBS += -lrt -lpthread LDLIBS += -lrt -lpthread
else ifeq ($(UNAME),Darwin) else ifeq ($(UNAME),Darwin)
LIBS += -lpthread LDLIBS += -lpthread
LDFLAGS += -L/usr/local/opt/openssl@1.1/lib -L/usr/local/lib LDFLAGS += -L/usr/local/opt/openssl@1.1/lib -L/usr/local/lib
INCFLAGS += -I/usr/local/opt/openssl@1.1/include -I/usr/local/include INCFLAGS += -I/usr/local/opt/openssl@1.1/include -I/usr/local/include
else ifeq ($(UNAME),FreeBSD) else ifeq ($(UNAME),FreeBSD)
LIBS += -lthr -lpthread LDLIBS += -lthr -lpthread
LDFLAGS += -L/usr/local/lib LDFLAGS += -L/usr/local/lib
INCFLAGS += -I/usr/local/include INCFLAGS += -I/usr/local/include
else else
# Win32 # Win32
LIBS += -lws2_32 -lwsock32 -lgdi32 -liphlpapi -lstdc++ -lpthread LDLIBS += -lwsock32 -lws2_32 -liphlpapi -lpthread
LDFLAGS += -s -Wl,-Bstatic -static-libgcc -static-libstdc++ LDFLAGS += -s -static
endif endif
all: $(I2PD_LIB) keygen keyinfo famtool routerinfo regaddr regaddr_3ld vain i2pbase64 offlinekeys b33address regaddralias x25519 verifyhost all: $(I2PD_LIB) keygen keyinfo famtool routerinfo regaddr regaddr_3ld vain i2pbase64 offlinekeys b33address regaddralias x25519 verifyhost
routerinfo: routerinfo.o $(I2PD_LIB) routerinfo: routerinfo.o $(I2PD_LIB)
$(CXX) -o routerinfo routerinfo.o $(LDFLAGS) $(LIBS) $(CXX) -o routerinfo $(LDFLAGS) routerinfo.o $(LDLIBS)
keygen: keygen.o $(I2PD_LIB) keygen: keygen.o $(I2PD_LIB)
$(CXX) -o keygen keygen.o $(LDFLAGS) $(LIBS) $(CXX) -o keygen $(DEFINES) $(LDFLAGS) keygen.o $(LDLIBS)
keyinfo: keyinfo.o $(I2PD_LIB) keyinfo: keyinfo.o $(I2PD_LIB)
$(CXX) -o keyinfo keyinfo.o $(LDFLAGS) $(LIBS) $(CXX) -o keyinfo $(DEFINES) $(LDFLAGS) keyinfo.o $(LDLIBS)
famtool: famtool.o $(I2PD_LIB) famtool: famtool.o $(I2PD_LIB)
$(CXX) -o famtool famtool.o $(LDFLAGS) $(LIBS) $(CXX) -o famtool $(DEFINES) $(LDFLAGS) famtool.o $(LDLIBS)
regaddr: regaddr.o $(I2PD_LIB) regaddr: regaddr.o $(I2PD_LIB)
$(CXX) -o regaddr regaddr.o $(LDFLAGS) $(LIBS) $(CXX) -o regaddr $(DEFINES) $(LDFLAGS) regaddr.o $(LDLIBS)
regaddr_3ld: regaddr_3ld.o $(I2PD_LIB) regaddr_3ld: regaddr_3ld.o $(I2PD_LIB)
$(CXX) -o regaddr_3ld regaddr_3ld.o $(LDFLAGS) $(LIBS) $(CXX) -o regaddr_3ld $(DEFINES) $(LDFLAGS) regaddr_3ld.o $(LDLIBS)
vain: vanitygen.o $(I2PD_LIB) vain: vanitygen.o $(I2PD_LIB)
$(CXX) -o vain vanitygen.o $(LDFLAGS) $(LIBS) $(CXX) -o vain $(DEFINES) $(LDFLAGS) vanitygen.o $(LDLIBS)
i2pbase64: i2pbase64.o $(I2PD_LIB) i2pbase64: i2pbase64.o $(I2PD_LIB)
$(CXX) -o i2pbase64 i2pbase64.o $(LDFLAGS) $(LIBS) $(CXX) -o i2pbase64 $(DEFINES) $(LDFLAGS) i2pbase64.o $(LDLIBS)
offlinekeys: offlinekeys.o $(I2PD_LIB) offlinekeys: offlinekeys.o $(I2PD_LIB)
$(CXX) -o offlinekeys offlinekeys.o $(LDFLAGS) $(LIBS) $(CXX) -o offlinekeys $(DEFINES) $(LDFLAGS) offlinekeys.o $(LDLIBS)
b33address: b33address.o $(I2PD_LIB) b33address: b33address.o $(I2PD_LIB)
$(CXX) -o b33address b33address.o $(LDFLAGS) $(LIBS) $(CXX) -o b33address $(DEFINES) $(LDFLAGS) b33address.o $(LDLIBS)
regaddralias: regaddralias.o $(I2PD_LIB) regaddralias: regaddralias.o $(I2PD_LIB)
$(CXX) -o regaddralias regaddralias.o $(LDFLAGS) $(LIBS) $(CXX) -o regaddralias $(DEFINES) $(LDFLAGS) regaddralias.o $(LDLIBS)
x25519: x25519.o $(I2PD_LIB) x25519: x25519.o $(I2PD_LIB)
$(CXX) -o x25519 x25519.o $(LDFLAGS) $(LIBS) $(CXX) -o x25519 $(DEFINES) $(LDFLAGS) x25519.o $(LDLIBS)
verifyhost: verifyhost.o $(I2PD_LIB) verifyhost: verifyhost.o $(I2PD_LIB)
$(CXX) -o verifyhost verifyhost.o $(LDFLAGS) $(LIBS) $(CXX) -o verifyhost $(DEFINES) $(LDFLAGS) verifyhost.o $(LDLIBS)
.SUFFIXES: .SUFFIXES:
.SUFFIXES: .c .cc .C .cpp .o .SUFFIXES: .c .cc .C .cpp .o
@ -89,7 +91,7 @@ $(I2PD_LIB):
$(MAKE) -C $(I2PD_PATH) mk_obj_dir $(I2PD_LIB) $(MAKE) -C $(I2PD_PATH) mk_obj_dir $(I2PD_LIB)
%.o: %.cpp $(I2PD_LIB) %.o: %.cpp $(I2PD_LIB)
$(CXX) -o $@ -c $(CXXFLAGS) $(INCFLAGS) $< $(CXX) $(CXXFLAGS) $(DEFINES) $(INCFLAGS) -c -o $@ $<
count: count:
wc *.c *.cc *.C *.cpp *.h *.hpp wc *.c *.cc *.C *.cpp *.h *.hpp

2
i2pd

@ -1 +1 @@
Subproject commit aead9db9712f8b07828a264a40898643385d7553 Subproject commit a6bd8275ca496c75c84d7eb890c0071569d28f55

52
keyinfo.cpp

@ -12,7 +12,7 @@
static int printHelp(const char * exe, int exitcode) static int printHelp(const char * exe, int exitcode)
{ {
std::cout << "usage: " << exe << " [-v] [-d] [-b] privatekey.dat" << std::endl; std::cout << "usage: " << exe << " [-v] [-d] [-p] [-b] privatekey.dat" << std::endl;
return exitcode; return exitcode;
} }
@ -31,10 +31,11 @@ int main(int argc, char * argv[])
} }
int opt; int opt;
bool print_full = false; bool print_dest = false;
bool print_private = false;
bool print_blinded = false; bool print_blinded = false;
bool verbose = false; bool verbose = false;
while((opt = getopt(argc, argv, "hvdb")) != -1) { while((opt = getopt(argc, argv, "hvdpb")) != -1) {
switch(opt){ switch(opt){
case 'h': case 'h':
return printHelp(argv[0], 0); return printHelp(argv[0], 0);
@ -42,7 +43,10 @@ int main(int argc, char * argv[])
verbose = true; verbose = true;
break; break;
case 'd': case 'd':
print_full = true; print_dest = true;
break;
case 'p':
print_private = true;
break; break;
case 'b': case 'b':
print_blinded = true; print_blinded = true;
@ -54,23 +58,22 @@ int main(int argc, char * argv[])
std::string fname(argv[optind]); std::string fname(argv[optind]);
i2p::data::PrivateKeys keys; i2p::data::PrivateKeys keys;
{ std::ifstream s(fname, std::ifstream::binary);
std::vector<uint8_t> buff;
std::ifstream inf; if (!s.is_open()) {
inf.open(fname); std::cout << "cannot open private key file " << fname << std::endl;
if (!inf.is_open()) { return 2;
std::cout << "cannot open private key file " << fname << std::endl; }
return 2;
} s.seekg(0, std::ios::end);
inf.seekg(0, std::ios::end); size_t len = s.tellg();
const std::size_t len = inf.tellg(); s.seekg(0, std::ios::beg);
inf.seekg(0, std::ios::beg); uint8_t * buf = new uint8_t[len];
buff.resize(len); s.read((char*)buf, len);
inf.read((char*)buff.data(), buff.size());
if (!keys.FromBuffer(buff.data(), buff.size())) { if (!keys.FromBuffer(buf, len)) {
std::cout << "bad key file format" << std::endl; std::cout << "bad key file format" << std::endl;
return 3; return 3;
}
} }
auto dest = keys.GetPublic(); auto dest = keys.GetPublic();
@ -94,7 +97,9 @@ int main(int argc, char * argv[])
std::cout << "Transient Signature Type: " << SigTypeToName(bufbe16toh(offlineSignature.data () + 4)) << std::endl; std::cout << "Transient Signature Type: " << SigTypeToName(bufbe16toh(offlineSignature.data () + 4)) << std::endl;
} }
} else { } else {
if(print_full) { if(print_private) {
std::cout << keys.ToBase64() << std::endl;
} else if(print_dest) {
std::cout << dest->ToBase64() << std::endl; std::cout << dest->ToBase64() << std::endl;
} else { } else {
std::cout << ident.ToBase32() << ".b32.i2p" << std::endl; std::cout << ident.ToBase32() << ".b32.i2p" << std::endl;
@ -112,4 +117,7 @@ int main(int argc, char * argv[])
else else
std::cout << "Invalid signature type " << SigTypeToName (dest->GetSigningKeyType ()) << std::endl; std::cout << "Invalid signature type " << SigTypeToName (dest->GetSigningKeyType ()) << std::endl;
} }
i2p::crypto::TerminateCrypto ();
return 0;
} }

4
regaddr.cpp

@ -16,6 +16,7 @@ int main (int argc, char * argv[])
i2p::data::PrivateKeys keys; i2p::data::PrivateKeys keys;
std::ifstream s(argv[1], std::ifstream::binary); std::ifstream s(argv[1], std::ifstream::binary);
if (s.is_open ()) if (s.is_open ())
{ {
s.seekg (0, std::ios::end); s.seekg (0, std::ios::end);
@ -23,6 +24,7 @@ int main (int argc, char * argv[])
s.seekg (0, std::ios::beg); s.seekg (0, std::ios::beg);
uint8_t * buf = new uint8_t[len]; uint8_t * buf = new uint8_t[len];
s.read ((char *)buf, len); s.read ((char *)buf, len);
if(keys.FromBuffer (buf, len)) if(keys.FromBuffer (buf, len))
{ {
auto signatureLen = keys.GetPublic ()->GetSignatureLen (); auto signatureLen = keys.GetPublic ()->GetSignatureLen ();
@ -41,10 +43,10 @@ int main (int argc, char * argv[])
} }
else else
std::cout << "Failed to load keyfile " << argv[1] << std::endl; std::cout << "Failed to load keyfile " << argv[1] << std::endl;
delete[] buf; delete[] buf;
} }
i2p::crypto::TerminateCrypto (); i2p::crypto::TerminateCrypto ();
return 0; return 0;
} }

Loading…
Cancel
Save