From 3f66cee0c9f3f731e11ee8106f75b6ff54b4e4f4 Mon Sep 17 00:00:00 2001 From: Dario via Pythagoras Date: Tue, 6 Oct 2020 11:46:39 +0200 Subject: [PATCH 1/2] changes in cmake, working in progess --- .gitmodules | 3 ++ CMakeLists.txt | 46 ++++++++++++++++++++++++++++-- dependencies/poco | 1 + src/cpp/Crypto/KeyPair.cpp | 12 ++++---- src/cpp/Crypto/KeyPairHedera.cpp | 6 ++-- src/cpp/controller/HederaAccount.h | 4 +-- src/proto | 2 +- 7 files changed, 59 insertions(+), 15 deletions(-) create mode 160000 dependencies/poco diff --git a/.gitmodules b/.gitmodules index 94115f227..7500d3d77 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "dependencies/grpc"] path = dependencies/grpc url = https://github.com/grpc/grpc.git +[submodule "dependencies/poco"] + path = dependencies/poco + url = https://github.com/pocoproject/poco.git diff --git a/CMakeLists.txt b/CMakeLists.txt index c8cbe2e74..ac13fb891 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ include_directories( "dependencies/spirit-po/include" "dependencies/grpc/include" "dependencies/grpc/third_party/protobuf/src" + #"dependencies/grpc/third_party/boringssl-with-bazel/src/include" "src/cpp/proto" #"dependencies/mariadb-connector-c/build/include" #"dependencies/mariadb-connector-c/include" @@ -22,6 +23,7 @@ include_directories( ) + FILE(GLOB CONTROLLER "src/cpp/controller/*.cpp" "src/cpp/controller/*.h") FILE(GLOB TINF "dependencies/tinf/src/*.c" "dependencies/tinf/src/*.h") FILE(GLOB HTTPInterface "src/cpp/HTTPInterface/*.h" "src/cpp/HTTPInterface/*.cpp") @@ -81,6 +83,7 @@ source_group("Test\\controller" FILES ${TEST_CONTROLLER}) source_group("Test" FILES ${TEST}) endif(MSVC) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() @@ -165,16 +168,38 @@ set(CMAKE_CXX_FLAGS "/MP /EHsc") #set(CMAKE_CXX_FLAGS_RELEASE "-O3") else(WIN32) +set(GRPC_BORING_SSL_PATH "dependencies/grpc/build/third_party/boringssl-with-bazel") +find_library(GRPC_BORING_SSL_CRYPTO crypto ${GRPC_BORING_SSL_PATH} REQUIRED) +find_library(GRPC_BORING_SSL_SSL ssl ${GRPC_BORING_SSL_PATH} REQUIRED) +set(GRPC_LIBS + #${GRPC_BORING_SSL_CRYPTO} + #${GRPC_BORING_SSL_SSL} +) +#find_package(OpenSSL REQUIRED) +find_package(PROTOBUF PATHS "dependencies/grpc/build/third_party/protobuf" REQUIRED) +set(gRPC_SSL_PROVIDER "module") +find_package(gRPC PATHS "dependencies/grpc/build" REQUIRED) +find_package(Threads REQUIRED) +set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) + +#find_package(Poco REQUIRED) +#find_package(libsodium REQUIRED) +#find_package(gtest REQUIRED) find_library(IROHA_ED25519 ed25519 PATHS "dependencies/iroha-ed25519/build" REQUIRED) # set vars for mariadb cmake files set(INSTALL_BINDIR "bin") set(INSTALL_PLUGINDIR "bin") +OPTION(WITH_SSL "" OFF) add_subdirectory("dependencies/mariadb-connector-c") include_directories( "dependencies/mariadb-connector-c/include" "build/dependencies/mariadb-connector-c/include" + #${OpenSSL_INCLUDE_DIR} + #${Poco_INCLUDE_DIR} + #${libsodium_INCLUDE_DIR} + #${gtest_INCLUDE_DIR} ) @@ -183,13 +208,28 @@ endif(WIN32) add_subdirectory("dependencies/grpc/third_party/abseil-cpp") -target_link_libraries(Gradido_LoginServer absl::base absl::flat_hash_map absl::flags absl::memory absl::meta absl::numeric absl::strings ${CONAN_LIBS} ${IROHA_ED25519}) +#target_link_libraries(Gradido_LoginServer absl::base absl::flat_hash_map absl::flags absl::memory absl::meta absl::numeric absl::strings)# ${CONAN_LIBS} ${IROHA_ED25519}) +message(STATUS "Conan libs: ") +list(REMOVE_ITEM CONAN_LIBS "ssl") +list(REMOVE_ITEM CONAN_LIBS "crypto") +foreach(i ${CONAN_LIBS}) + +message(STATUS ${i}) + +endforeach(i) + if(WIN32) TARGET_LINK_LIBRARIES(Gradido_LoginServer optimized ${MYSQL_LIBRARIES} Shlwapi) TARGET_LINK_LIBRARIES(Gradido_LoginServer debug ${COMPILED_MARIADB_CLIENT_DEBUG} Shlwapi) TARGET_LINK_LIBRARIES(Gradido_LoginServer debug ${GRPC_LIBS} ${PROTOBUF_DEBUG_LIBS}) else(WIN32) -target_link_libraries(Gradido_LoginServer libmariadb protoc protobuf -pthread) +target_link_libraries(Gradido_LoginServer gRPC::grpc++) +target_link_libraries(Gradido_LoginServer ${CONAN_LIBS}) +target_link_libraries(Gradido_LoginServer libmariadb )# ${GRPC_LIBS} protoc protobuf pthread) +#target_link_libraries(Gradido_LoginServer ${OpenSSL_LIBS} ${Poco_LIBS} ${libsodium_LIBS} ) + + + endif(WIN32) # install @@ -220,7 +260,7 @@ if(WIN32) TARGET_LINK_LIBRARIES(Gradido_LoginServer_Test debug ${COMPILED_MARIADB_CLIENT_DEBUG} Shlwapi) TARGET_LINK_LIBRARIES(Gradido_LoginServer_Test debug ${GRPC_LIBS} ${PROTOBUF_DEBUG_LIBS}) else(WIN32) - target_link_libraries(Gradido_LoginServer_Test libmariadb protoc protobuf -pthread) + target_link_libraries(Gradido_LoginServer_Test libmariadb protoc protobuf pthread) endif(WIN32) add_test(NAME main COMMAND Gradido_LoginServer_Test) diff --git a/dependencies/poco b/dependencies/poco new file mode 160000 index 000000000..3fc3e5f5b --- /dev/null +++ b/dependencies/poco @@ -0,0 +1 @@ +Subproject commit 3fc3e5f5b8462f7666952b43381383a79b8b5d92 diff --git a/src/cpp/Crypto/KeyPair.cpp b/src/cpp/Crypto/KeyPair.cpp index 770f3dedf..9c6e3a22e 100644 --- a/src/cpp/Crypto/KeyPair.cpp +++ b/src/cpp/Crypto/KeyPair.cpp @@ -76,18 +76,18 @@ bool KeyPair::generateFromPassphrase(const char* passphrase, const Mnemonic* wor createClearPassphraseFromWordIndices(word_indices, &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER]); // printf("clear passphrase: %s\n", clearPassphrase.data()); - sha_context state; + crypto_hash_sha512_state state; - unsigned char hash[SHA_512_SIZE]; + unsigned char hash[crypto_hash_sha512_BYTES]; //crypto_auth_hmacsha512_state state; size_t word_index_size = sizeof(word_indices); //crypto_auth_hmacsha512_init(&state, (unsigned char*)word_indices, sizeof(word_indices)); - sha512_init(&state); - sha512_update(&state, *word_indices, word_indices->size()); - sha512_update(&state, (unsigned char*)clearPassphrase.data(), clearPassphrase.size()); + crypto_hash_sha512_init(&state); + crypto_hash_sha512_update(&state, *word_indices, word_indices->size()); + crypto_hash_sha512_update(&state, (unsigned char*)clearPassphrase.data(), clearPassphrase.size()); //crypto_auth_hmacsha512_update(&state, (unsigned char*)passphrase, pass_phrase_size); - sha512_final(&state, hash); + crypto_hash_sha512_final(&state, hash); //crypto_auth_hmacsha512_final(&state, hash); /* diff --git a/src/cpp/Crypto/KeyPairHedera.cpp b/src/cpp/Crypto/KeyPairHedera.cpp index c2738e886..e16b76e05 100644 --- a/src/cpp/Crypto/KeyPairHedera.cpp +++ b/src/cpp/Crypto/KeyPairHedera.cpp @@ -44,7 +44,7 @@ KeyPairHedera::KeyPairHedera(const unsigned char* privateKey, size_t privateKeyS } break; default: - throw std::exception("[KeyPairHedera] invalid private key"); + throw Poco::Exception("[KeyPairHedera] invalid private key"); } // check public @@ -62,7 +62,7 @@ KeyPairHedera::KeyPairHedera(const unsigned char* privateKey, size_t privateKeyS } break; default: - throw std::exception("[KeyPairHedera] invalid public key"); + throw Poco::Exception("[KeyPairHedera] invalid public key"); } } auto public_key_2 = mm->getFreeMemory(ed25519_pubkey_SIZE); @@ -218,4 +218,4 @@ MemoryBin* KeyPairHedera::getPublicKeyCopy() const auto public_key = mm->getFreeMemory(ed25519_pubkey_SIZE); memcpy(*public_key, mPublicKey, ed25519_pubkey_SIZE); return public_key; -} \ No newline at end of file +} diff --git a/src/cpp/controller/HederaAccount.h b/src/cpp/controller/HederaAccount.h index 709e84c7a..94e21a597 100644 --- a/src/cpp/controller/HederaAccount.h +++ b/src/cpp/controller/HederaAccount.h @@ -29,7 +29,7 @@ namespace controller { inline bool deleteFromDB() { return mDBModel->deleteFromDB(); } - std::string HederaAccount::toShortSelectOptionName(); + std::string toShortSelectOptionName(); inline Poco::AutoPtr getModel() { return _getModel(); } inline const model::table::HederaAccount* getModel() const { return _getModel(); } @@ -53,4 +53,4 @@ namespace controller { }; } -#endif //GRADIDO_LOGIN_SERVER_CONTROLLER_HEDERA_ACCOUNT_INCLUDE \ No newline at end of file +#endif //GRADIDO_LOGIN_SERVER_CONTROLLER_HEDERA_ACCOUNT_INCLUDE diff --git a/src/proto b/src/proto index 72e8fe7b7..81a461566 160000 --- a/src/proto +++ b/src/proto @@ -1 +1 @@ -Subproject commit 72e8fe7b73a1aaf2d057d2fef59ade9268830008 +Subproject commit 81a461566e46d71533dc3e284fa075d7d68fd020 From fdf15bb94825ccec3d52cfa2d5a4ddefb599f397 Mon Sep 17 00:00:00 2001 From: Dario via Pythagoras Date: Tue, 6 Oct 2020 12:03:25 +0200 Subject: [PATCH 2/2] add linux parse file --- unix_parse_proto.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 unix_parse_proto.sh diff --git a/unix_parse_proto.sh b/unix_parse_proto.sh new file mode 100755 index 000000000..3727cc985 --- /dev/null +++ b/unix_parse_proto.sh @@ -0,0 +1,19 @@ +#!/bin/bash +if [ ! -d "./src/cpp/proto" ] ; then + mkdir ./src/cpp/proto +fi +if [ ! -d "./src/cpp/proto/gradido" ] ; then + mkdir ./src/cpp/proto/gradido +fi +PROTOC_PATH=./dependencies/grpc/build/third_party/protobuf +CPP_PLUGIN_PATH=./dependencies/grpc/build +$PROTOC_PATH/protoc --cpp_out=./src/cpp/proto --proto_path=./src/proto ./src/proto/gradido/*.proto + +if [ ! -d "./src/cpp/proto/hedera" ] ; then + mkdir ./src/cpp/proto/hedera +fi + +GOOGLE_PROTOBUF_INCLUDES=./dependencies/grpc/third_party/protobuf/src +$PROTOC_PATH/protoc --plugin=protoc-gen-grpc=$CPP_PLUGIN_PATH/grpc_cpp_plugin --cpp_out=./src/cpp/proto/hedera --grpc_out=./src/cpp/proto/hedera --proto_path=$GOOGLE_PROTOBUF_INCLUDES --proto_path=./src/proto/hedera/hedera-protobuf/src/main/proto ./src/proto/hedera/hedera-protobuf/src/main/proto/*.proto + +