From f318dffdebfd4a408d8753fee4ad30c2d56146a8 Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Wed, 4 Apr 2018 11:04:59 -0400 Subject: [PATCH] Revert "SPARK-959 Implement functions for CME "secure" logon." This reverts commit ac2fa9b7bc8cfcfd94840db801286792cd7e603e. --- .vscode/launch.json | 2 +- docker/linux | 2 +- src/lib/CMakeDeps.cmake | 2 +- src/lib/CMakeLists.txt | 1 - src/lib/utils/SecureLogon.cpp | 126 ---------------------------------- src/lib/utils/SecureLogon.h | 25 ------- src/lib/utils/bts_assert.h | 2 +- 7 files changed, 4 insertions(+), 156 deletions(-) delete mode 100644 src/lib/utils/SecureLogon.cpp delete mode 100644 src/lib/utils/SecureLogon.h diff --git a/.vscode/launch.json b/.vscode/launch.json index 68235aaab..d4a93a50a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -111,7 +111,7 @@ "type": "cppdbg", "request": "launch", "program": "/home/bts/spark/build/ninja_debug/src/server/sparkd/sparkd", - "args": ["test", "-a", "LoadSessionKeys"], + "args": ["test", "-a", "[synthetic]"], "stopAtEntry": false, "cwd": "/home/bts/spark/build/ninja_debug/src/server/sparkd/", "environment": [], diff --git a/docker/linux b/docker/linux index 4261d624c..735b68832 160000 --- a/docker/linux +++ b/docker/linux @@ -1 +1 @@ -Subproject commit 4261d624c197c72b8bccd19a8c5cd2b82252e914 +Subproject commit 735b68832737b750201b677211e3c2b200808fee diff --git a/src/lib/CMakeDeps.cmake b/src/lib/CMakeDeps.cmake index ae2893842..795ccf44b 100644 --- a/src/lib/CMakeDeps.cmake +++ b/src/lib/CMakeDeps.cmake @@ -1 +1 @@ -set(sources api/apicore.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/services/AccountService.proto;api/services/ApiUnitTestService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/ShellDiagnosticService.proto;api/services/SyntheticSecurityService.proto;api/services/UserService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/Executor.conf;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/edge.conf;config/defaults/expiration_display_offset.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/testkeys.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/environment.proto;config/protos/expiration_display_offset.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/quickbus_cfg.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPriceLantencyTester.cpp;md/Diag/ShmDumper.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/windows_test_driver.cpp;utils/Dispatcher.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SecureLogon.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp) \ No newline at end of file +set(sources api/apicore.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/services/AccountService.proto;api/services/ApiUnitTestService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MarketDataRelay.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/ShellDiagnosticService.proto;api/services/SyntheticSecurityService.proto;api/services/UserService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/Executor.conf;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/Symbols.conf;config/defaults/edge.conf;config/defaults/expiration_display_offset.conf;config/defaults/jetfix.conf;config/defaults/logging.conf;config/defaults/testkeys.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/ExchangeSimCfg.proto;config/protos/MarketData.proto;config/protos/Ports.proto;config/protos/Symbols.proto;config/protos/UI.proto;config/protos/environment.proto;config/protos/expiration_display_offset.proto;config/protos/jetfix.proto;config/protos/logging.proto;config/protos/quickbus_cfg.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/toggles.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain_model/Security.cpp;domain_model/Security.proto;expression/BooleanGrammar.cpp;expression/ExpressionEvaluator.cpp;expression/ParserExceptions.cpp;expression/Value.cpp;expression/tests/expression_parser_tests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/Diag/MDPriceLantencyTester.cpp;md/Diag/ShmDumper.cpp;md/MDConsumer.cpp;md/MDConsumerHandle.cpp;md/MDConsumerInterop.cpp;md/MDProducer.cpp;md/MDProducerHandle.cpp;md/MDRecoverableConsumer.cpp;md/MemorySegmentUtils.cpp;md/PlatformLoader.cpp;md/PriceSize.cpp;md/SecurityDB.cpp;md/SecurityIDRecorder.cpp;md/SettlementRecorder.cpp;md/Shm/FixedSecurity.cpp;md/SyntheticSecurityService.cpp;md/common.cpp;md/protos/co2.proto;md/relay/QueryServer.cpp;md/relay/RelayClient.cpp;md/relay/RelayRecorder.cpp;md/test/Co2TestInstrument.cpp;md/test/md2_tests.cpp;md/test/synthetic_book_merge_tests.cpp;os/os.cpp;os/tests/os_tests.cpp;quickbus/core/LocalNode.cpp;quickbus/core/Quickbus.cpp;quickbus/core/SubscriptionID.cpp;quickbus/core/TableID.cpp;quickbus/message_model/Update.cpp;quickbus/message_model/merge_updates.cpp;quickbus/network/QBConnection.cpp;quickbus/network/QBConnectionManager.cpp;quickbus/network/endpoint_description.cpp;quickbus/network/quickbus_msgs.proto;quickbus/pubsub/TablePublisher.cpp;quickbus/pubsub/TableSubscriber.cpp;quickbus/pubsub/tests/qb_pubsub_tests.cpp;quickbus/routing/INode.cpp;quickbus/routing/NodeID.cpp;quickbus/routing/Router.cpp;quickbus/rpc/RPCClient.cpp;quickbus/rpc/RPCServer.cpp;quickbus/rpc/RPCSessionID.cpp;quickbus/rpc/rpc_utils.cpp;quickbus/rpc/tests/qb_rpc_tests.cpp;quickbus/tests/quickbus_tests.cpp;sparkproto/SparkProtos.proto;testing/windows_test_driver.cpp;utils/Dispatcher.cpp;utils/HTTPStream.cpp;utils/PBUtils.cpp;utils/Puid.cpp;utils/SharedMemory.cpp;utils/Sqlite_utils.cpp;utils/Uuid.cpp;utils/datetime.cpp;utils/download.cpp;utils/file_utils.cpp;utils/init_spark_lib.cpp;utils/is_unittest_environment.cpp) \ No newline at end of file diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 6003ef96a..dffc3b81b 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -104,7 +104,6 @@ else () protobuf uuid.a sqlite3 - crypto++ -lrt -ldl -static-libgcc diff --git a/src/lib/utils/SecureLogon.cpp b/src/lib/utils/SecureLogon.cpp deleted file mode 100644 index 96ce4e914..000000000 --- a/src/lib/utils/SecureLogon.cpp +++ /dev/null @@ -1,126 +0,0 @@ -#ifndef _WIN32 -#include "SecureLogon.h" -#include "lib/utils/bts_assert.h" - -#include "lib/config/config.h" -#include "lib/config/protos/system.pb.h" - -// libcrypto++-dev -#include -#include -#include -#include - -#include -#include -#include -// #include "catch/catch.hpp" - -#include - -using namespace CryptoPP; -using std::string; - -namespace glbx { - -std::tuple load_session_keys(const string& session) { - using namespace boost; - using namespace boost::filesystem; - auto path = bts::config::get().data_path() + "glbx_logon/"; - if (is_directory(path)) { - // iterate though each file - for (const auto& f : directory_iterator(path)) { - std::ifstream input(f.path().string()); - while (input && !input.eof()) { - // iterate though each line - string line; - std::getline(input, line); - char_separator sep(", \t"); - tokenizer> tokens(line, sep); - auto t = tokens.begin(); - // if first token matches session return the next 2 tokens - if (t != tokens.end() && *t == session) { - auto id = *(++t); - auto secret = *(++t); - return {id,secret}; - } - } - } - } - bts_assert(false); -} - -LogonData calculate_hmac( - const std::string& session_id, - const std::string& msg_seq_num, - const std::string& sender_comp_id, - const std::string& sender_sub_id, - const std::string& sending_time, - const std::string& target_sub_id, - const std::string& heartbeat_interval, - const std::string& sender_location_id, - const std::string& application_system_name, - const std::string& application_system_version, - const std::string& application_system_vendor - ) { - string canonical; - canonical += msg_seq_num; - canonical += '\n'; - canonical += sender_comp_id; - canonical += '\n'; - canonical += sender_sub_id; - canonical += '\n'; - canonical += sending_time; - canonical += '\n'; - canonical += target_sub_id; - canonical += '\n'; - canonical += heartbeat_interval; - canonical += '\n'; - canonical += sender_location_id; - canonical += '\n'; - canonical += application_system_name; - canonical += '\n'; - canonical += application_system_version; - canonical += '\n'; - canonical += application_system_vendor; - - string secret_key, access_id; - std::tie(access_id, secret_key) = load_session_keys(session_id); - - try { - string decoded_key; - StringSink key_sink(decoded_key); - Base64URLDecoder decoder(&key_sink); - StringSource(secret_key, true, &decoder); - - HMAC hmac( (const byte*)decoded_key.c_str(), decoded_key.size()); - string calculated_hmac; - StringSink hmac_sink(calculated_hmac); - HashFilter filter(hmac, &hmac_sink); - StringSource(canonical, true, &filter); - - string encoded_hmac; - StringSink result_sink(encoded_hmac); - Base64URLEncoder url_enc(&result_sink); - StringSource(calculated_hmac, true, &url_enc); - - return { access_id, encoded_hmac }; - } - catch(const Exception& e) { - bts_assert_msg(false, e.what()); - } - bts_assert(false); - } - - - // TEST_CASE("LoadSessionKeys", "") { - // std::string session_id = "1U7"; - // string secret_key, access_id; - // std::tie(access_id, secret_key) = load_session_keys(session_id); - // REQUIRE(access_id == "ozXmORijPtJriTg6Wwny"); - // REQUIRE(secret_key == "A1KOwrhH8GojNotjkCfVwHRSi_OS280xihaRZwJLFKo"); - // } - -} - -#endif \ No newline at end of file diff --git a/src/lib/utils/SecureLogon.h b/src/lib/utils/SecureLogon.h deleted file mode 100644 index 3d66ddfb7..000000000 --- a/src/lib/utils/SecureLogon.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include - -namespace glbx { - -struct LogonData { - std::string access_key; - std::string signature; -}; - -LogonData calculate_hmac( - const std::string& session_id, - const std::string& msg_seq_num, - const std::string& sender_comp_id, - const std::string& sender_sub_id, - const std::string& sending_time, - const std::string& target_sub_id, - const std::string& heartbeat_interval, - const std::string& sender_location_id, - const std::string& application_system_name, - const std::string& application_system_version, - const std::string& application_system_vendor - ); - -} \ No newline at end of file diff --git a/src/lib/utils/bts_assert.h b/src/lib/utils/bts_assert.h index 9b6c40d09..c4d0c4565 100644 --- a/src/lib/utils/bts_assert.h +++ b/src/lib/utils/bts_assert.h @@ -16,7 +16,7 @@ #define bts_assert_msg(EXP, msg) \ do { \ if (!(EXP)) { \ - LOG(Assert, bts::Fatal, "Assert failure: {} {}", std::string(#EXP), \ + LOG(Assert, Fatal, "Assert failure: {} {}", std::string(#EXP), \ std::string(msg)); \ std::this_thread::sleep_for(std::chrono::seconds(1)); \ if (is_debugger_present()) \