Browse Source

initial code for Ed25519 added

pull/178/head
orignal 10 years ago
parent
commit
75d45ae988
  1. 44
      Signature.cpp
  2. 1
      Win32/i2pd.vcxproj
  3. 1
      build/CMakeLists.txt
  4. 6
      build/autotools/Makefile.in
  5. 7
      filelist.mk

44
Signature.cpp

@ -0,0 +1,44 @@
#include <cryptopp/integer.h>
#include <cryptopp/eccrypto.h>
#include "Signature.h"
namespace i2p
{
namespace crypto
{
class Ed25519
{
public:
Ed25519 (): b(256)
{
q = CryptoPP::Integer::Power2 (255) - CryptoPP::Integer (19); // 2^255-19
l = CryptoPP::Integer::Power2 (252) + CryptoPP::Integer ("27742317777372353535851937790883648493");
// 2^252 + 27742317777372353535851937790883648493
d = CryptoPP::Integer (-121665) * CryptoPP::Integer (121666).InverseMod (q); // -121665/121666
}
private:
CryptoPP::ECP::Point Sum (CryptoPP::ECP::Point p1, CryptoPP::ECP::Point p2)
{
CryptoPP::Integer m = d*p1.x*p2.x*p1.y*p2.y,
x = a_times_b_mod_c (p1.x*p2.y + p2.x*p1.y, (CryptoPP::Integer::One() + m).InverseMod (q), q),
y = a_times_b_mod_c (p1.y*p2.y + p1.x*p2.x, (CryptoPP::Integer::One() - m).InverseMod (q), q);
return CryptoPP::ECP::Point {x, y};
}
CryptoPP::ECP::Point Mul (CryptoPP::ECP::Point p, CryptoPP::Integer e)
{
if (e.IsZero ()) return CryptoPP::ECP::Point {0, 1};
return p; // TODO
}
private:
CryptoPP::Integer b, q, l, d;
};
}
}

1
Win32/i2pd.vcxproj

@ -42,6 +42,7 @@
<ClCompile Include="..\Reseed.cpp" /> <ClCompile Include="..\Reseed.cpp" />
<ClCompile Include="..\RouterContext.cpp" /> <ClCompile Include="..\RouterContext.cpp" />
<ClCompile Include="..\RouterInfo.cpp" /> <ClCompile Include="..\RouterInfo.cpp" />
<ClCompile Include="..\Signature.cpp" />
<ClCompile Include="..\SAM.cpp" /> <ClCompile Include="..\SAM.cpp" />
<ClCompile Include="..\SSU.cpp" /> <ClCompile Include="..\SSU.cpp" />
<ClCompile Include="..\SSUData.cpp" /> <ClCompile Include="..\SSUData.cpp" />

1
build/CMakeLists.txt

@ -41,6 +41,7 @@ set (COMMON_SRC
"${CMAKE_SOURCE_DIR}/base64.cpp" "${CMAKE_SOURCE_DIR}/base64.cpp"
"${CMAKE_SOURCE_DIR}/util.cpp" "${CMAKE_SOURCE_DIR}/util.cpp"
"${CMAKE_SOURCE_DIR}/Datagram.cpp" "${CMAKE_SOURCE_DIR}/Datagram.cpp"
"${CMAKE_SOURCE_DIR}/Signature.cpp"
) )
set (DAEMON_SRC set (DAEMON_SRC

6
build/autotools/Makefile.in

@ -116,7 +116,7 @@ am_i2p_OBJECTS = AddressBook.$(OBJEXT) CryptoConst.$(OBJEXT) \
aes.$(OBJEXT) base64.$(OBJEXT) i2p.$(OBJEXT) util.$(OBJEXT) \ aes.$(OBJEXT) base64.$(OBJEXT) i2p.$(OBJEXT) util.$(OBJEXT) \
SAM.$(OBJEXT) Destination.$(OBJEXT) ClientContext.$(OBJEXT) \ SAM.$(OBJEXT) Destination.$(OBJEXT) ClientContext.$(OBJEXT) \
Datagram.$(OBJEXT) SSUSession.$(OBJEXT) BOB.$(OBJEXT) \ Datagram.$(OBJEXT) SSUSession.$(OBJEXT) BOB.$(OBJEXT) \
I2PControl.$(OBJEXT) Profiling.$(OBJEXT) I2PControl.$(OBJEXT) Profiling.$(OBJEXT) Signature.$(OBJEXT)
i2p_OBJECTS = $(am_i2p_OBJECTS) i2p_OBJECTS = $(am_i2p_OBJECTS)
i2p_LDADD = $(LDADD) i2p_LDADD = $(LDADD)
AM_V_P = $(am__v_P_@AM_V@) AM_V_P = $(am__v_P_@AM_V@)
@ -328,7 +328,7 @@ i2p_SOURCES = AddressBook.cpp CryptoConst.cpp Daemon.cpp \
TunnelGateway.cpp TunnelPool.cpp UPnP.cpp aes.cpp \ TunnelGateway.cpp TunnelPool.cpp UPnP.cpp aes.cpp \
base64.cpp i2p.cpp util.cpp SAM.cpp Destination.cpp \ base64.cpp i2p.cpp util.cpp SAM.cpp Destination.cpp \
ClientContext.cpp DataFram.cpp SSUSession.cpp BOB.cpp \ ClientContext.cpp DataFram.cpp SSUSession.cpp BOB.cpp \
I2PControl.cpp Profiling.cpp \ I2PControl.cpp Profiling.cpp Signature.cpp \
\ \
AddressBook.h CryptoConst.h Daemon.h ElGamal.h \ AddressBook.h CryptoConst.h Daemon.h ElGamal.h \
Garlic.h HTTPProxy.h HTTPServer.h I2NPProtocol.h \ Garlic.h HTTPProxy.h HTTPServer.h I2NPProtocol.h \
@ -493,6 +493,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClientContext.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClientContext.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Datagram.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Datagram.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SSUSession.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SSUSession.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Profiling.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Signature.Po@am__quote@
.cpp.o: .cpp.o:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<

7
filelist.mk

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

Loading…
Cancel
Save