Browse Source

regaddr added

pull/9/head
orignal 8 years ago
parent
commit
60b93ac3a1
  1. 7
      Makefile
  2. 2
      i2pd
  3. 50
      regaddr.cpp

7
Makefile

@ -11,7 +11,7 @@ OBJECTS = $(SOURCES:.cpp=.o)
I2PD_LIB = libi2pd.a I2PD_LIB = libi2pd.a
all: keygen keyinfo famtool routerinfo all: keygen keyinfo famtool routerinfo regaddr
routerinfo: $(OBJECTS) routerinfo: $(OBJECTS)
$(CXX) -o routerinfo routerinfo.o $(LDFLAGS) $(LIBS) $(CXX) -o routerinfo routerinfo.o $(LDFLAGS) $(LIBS)
@ -25,6 +25,9 @@ keyinfo: $(OBJECTS)
famtool: $(OBJECTS) famtool: $(OBJECTS)
$(CXX) -o famtool famtool.o $(LDFLAGS) $(LIBS) $(CXX) -o famtool famtool.o $(LDFLAGS) $(LIBS)
regaddr: $(OBJECTS)
$(CXX) -o regaddr regaddr.o $(LDFLAGS) $(LIBS)
$(OBJECTS): libi2pd.a $(OBJECTS): libi2pd.a
.SUFFIXES: .SUFFIXES:
@ -46,7 +49,7 @@ clean-obj:
rm -f $(OBJECTS) rm -f $(OBJECTS)
clean-bin: clean-bin:
rm -f keyinfo keygen famtool rm -f keyinfo keygen famtool regaddr
clean: clean-i2pd clean-obj clean-bin clean: clean-i2pd clean-obj clean-bin

2
i2pd

@ -1 +1 @@
Subproject commit 6fc80e9b67c8ee0a4c2c82c9173d2c1fb56b0efb Subproject commit 1ce6ad5ccc812599728e0a6f07767e52b48ecbee

50
regaddr.cpp

@ -0,0 +1,50 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include "Identity.h"
#include "Base.h"
int main (int argc, char * argv[])
{
if (argc < 2)
{
std::cout << "Usage: regaddr filename address" << std::endl;
return -1;
}
i2p::crypto::InitCrypto (false);
i2p::data::PrivateKeys keys;
std::ifstream s(argv[1], std::ifstream::binary);
if (s.is_open ())
{
s.seekg (0, std::ios::end);
size_t len = s.tellg();
s.seekg (0, std::ios::beg);
uint8_t * buf = new uint8_t[len];
s.read ((char *)buf, len);
if(keys.FromBuffer (buf, len))
{
auto signatureLen = keys.GetPublic ()->GetSignatureLen ();
uint8_t * signature = new uint8_t[signatureLen];
char * sig = new char[signatureLen*2];
std::stringstream out;
out << argv[2] << "="; // address
out << keys.GetPublic ()->ToBase64 ();
keys.Sign ((uint8_t *)out.str ().c_str (), out.str ().length (), signature);
auto len = i2p::data::ByteStreamToBase64 (signature, signatureLen, sig, signatureLen*2);
sig[len] = 0;
out << "#!sig=" << sig;
delete[] signature;
delete[] sig;
std::cout << out.str () << std::endl;
}
else
std::cout << "Failed to load keyfile " << argv[1] << std::endl;
delete[] buf;
}
i2p::crypto::TerminateCrypto ();
return 0;
}
Loading…
Cancel
Save