diff --git a/Identity.h b/Identity.h index 5c93e3d6..d82e225e 100644 --- a/Identity.h +++ b/Identity.h @@ -6,6 +6,7 @@ #include #include "base64.h" #include "ElGamal.h" +#include "Signature.h" namespace i2p { diff --git a/Signature.h b/Signature.h new file mode 100644 index 00000000..69c1bb86 --- /dev/null +++ b/Signature.h @@ -0,0 +1,43 @@ +#ifndef SIGNATURE_H__ +#define SIGNATURE_H__ + +#include +#include +#include "CryptoConst.h" + +namespace i2p +{ +namespace crypto +{ + class Verifier + { + public: + + virtual ~Verifier () {}; + virtual bool Verify (const uint8_t * buf, size_t len, const uint8_t * signature) = 0; + }; + + class DSAVerifier: public Verifier + { + public: + + DSAVerifier (const uint8_t * signingKey) + { + m_PublicKey.Initialize (dsap, dsaq, dsag, CryptoPP::Integer (signingKey, 128)); + } + + bool Verify (const uint8_t * buf, size_t len, const uint8_t * signature) + { + CryptoPP::DSA::Verifier verifier (m_PublicKey); + return verifier.VerifyMessage (buf, len, signature, 40); + } + + private: + + CryptoPP::DSA::PublicKey m_PublicKey; + }; +} +} + +#endif + diff --git a/Win32/i2pd.vcxproj b/Win32/i2pd.vcxproj index 20a04ff4..80fed8e5 100644 --- a/Win32/i2pd.vcxproj +++ b/Win32/i2pd.vcxproj @@ -84,6 +84,8 @@ + + diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index f37f39ed..85f4f2ec 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -77,6 +77,7 @@ set ( HEADERS SOCKS.h I2PTunnel.h version.h + Signature.h ) if (WIN32) diff --git a/filelist.mk b/filelist.mk index dc13a773..9a7e9d9c 100644 --- a/filelist.mk +++ b/filelist.mk @@ -11,7 +11,7 @@ H_FILES := CryptoConst.h base64.h NTCPSession.h RouterInfo.h Transports.h \ RouterContext.h NetDb.h LeaseSet.h Tunnel.h TunnelEndpoint.h TunnelGateway.h \ TransitTunnel.h I2NPProtocol.h Log.h Garlic.h HTTPServer.h Streaming.h Identity.h \ SSU.h util.h Reseed.h DaemonLinux.h SSUData.h i2p.h aes.h SOCKS.h UPnP.h TunnelPool.h \ - HTTPProxy.h AddressBook.h Daemon.h I2PTunnel.h version.h + HTTPProxy.h AddressBook.h Daemon.h I2PTunnel.h version.h Signature.h OBJECTS = $(addprefix obj/, $(notdir $(CPP_FILES:.cpp=.o)))