diff --git a/Crypto.cpp b/Crypto.cpp index 9e328fd0..0ac65671 100644 --- a/Crypto.cpp +++ b/Crypto.cpp @@ -799,7 +799,7 @@ namespace crypto }*/ - void InitCrypto (bool precomputation, bool withGost) + void InitCrypto (bool precomputation) { SSL_library_init (); /* auto numLocks = CRYPTO_num_locks(); diff --git a/Crypto.h b/Crypto.h index f55e1bd7..16a4da3c 100644 --- a/Crypto.h +++ b/Crypto.h @@ -279,7 +279,7 @@ namespace crypto #endif }; - void InitCrypto (bool precomputation, bool withGost = false); + void InitCrypto (bool precomputation); void TerminateCrypto (); } } diff --git a/tests/Makefile b/tests/Makefile index bcf1cfa5..d1284602 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,7 +1,6 @@ CXXFLAGS += -Wall -Wextra -pedantic -O0 -g -std=c++11 -D_GLIBCXX_USE_NANOSLEEP=1 -TESTS = test-gost test-http-url test-http-req test-http-res test-http-url_decode \ - test-http-merge_chunked test-base-64 +TESTS = test-gost test-gost-sig test-base-64 all: $(TESTS) run @@ -11,9 +10,12 @@ test-http-%: ../HTTP.cpp test-http-%.cpp test-base-%: ../Base.cpp test-base-%.cpp $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ -test-gost: ../Gost.cpp test-gost.cpp +test-gost: ../Gost.cpp ../I2PEndian.cpp test-gost.cpp $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ -lcrypto +test-gost-sig: ../Gost.cpp ../I2PEndian.cpp ../Signature.cpp ../Crypto.cpp ../Log.cpp test-gost-sig.cpp + $(CXX) $(CXXFLAGS) $(NEEDED_CXXFLAGS) $(INCFLAGS) -o $@ $^ -lcrypto -lssl -lboost_system + run: $(TESTS) @for TEST in $(TESTS); do ./$$TEST ; done diff --git a/tests/test-gost-sig.cpp b/tests/test-gost-sig.cpp new file mode 100644 index 00000000..fd222dd2 --- /dev/null +++ b/tests/test-gost-sig.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +#include "../Gost.h" +#include "../Signature.h" + +const uint8_t example2[72] = +{ + 0xfb,0xe2,0xe5,0xf0,0xee,0xe3,0xc8,0x20,0xfb,0xea,0xfa,0xeb,0xef,0x20,0xff,0xfb, + 0xf0,0xe1,0xe0,0xf0,0xf5,0x20,0xe0,0xed,0x20,0xe8,0xec,0xe0,0xeb,0xe5,0xf0,0xf2, + 0xf1,0x20,0xff,0xf0,0xee,0xec,0x20,0xf1,0x20,0xfa,0xf2,0xfe,0xe5,0xe2,0x20,0x2c, + 0xe8,0xf6,0xf3,0xed,0xe2,0x20,0xe8,0xe6,0xee,0xe1,0xe8,0xf0,0xf2,0xd1,0x20,0x2c, + 0xe8,0xf0,0xf2,0xe5,0xe2,0x20,0xe5,0xd1 +}; + + +int main () +{ + uint8_t priv[64], pub[128], signature[128]; + i2p::crypto::CreateGOSTR3410RandomKeys (i2p::crypto::eGOSTR3410TC26A512, priv, pub); + i2p::crypto::GOSTR3410_2012_512_Signer signer (i2p::crypto::eGOSTR3410TC26A512, priv); + signer.Sign (example2, 72, signature); + i2p::crypto::GOSTR3410_2012_512_Verifier verifier (i2p::crypto::eGOSTR3410TC26A512, pub); + assert (verifier.Verify (example2, 72, signature)); +} + + +