20个文件已修改
4 文件已重命名
2个文件已删除
| | |
| | | </tool> |
| | | </toolChain> |
| | | </folderInfo> |
| | | <folderInfo id="cdt.managedbuild.toolchain.gnu.base.1941555127.1870622802" name="/" resourcePath="src"> |
| | | <toolChain id="cdt.managedbuild.toolchain.gnu.base.1412322516" name="cdt.managedbuild.toolchain.gnu.base" superClass="cdt.managedbuild.toolchain.gnu.base" unusedChildren=""> |
| | | <tool id="cdt.managedbuild.tool.gnu.archiver.base.924146927" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base.1063978701"/> |
| | | <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.455275272" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base.1465609732"> |
| | | <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.743382935" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> |
| | | </tool> |
| | | <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1499862118" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base.589770174"> |
| | | <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.16209603" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> |
| | | </tool> |
| | | <tool id="cdt.managedbuild.tool.gnu.c.linker.base.1934467411" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base.1466986479"/> |
| | | <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.263030776" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base.233385682"/> |
| | | <tool id="cdt.managedbuild.tool.gnu.assembler.base.1495429968" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base.1674253564"> |
| | | <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1348112222" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> |
| | | </tool> |
| | | </toolChain> |
| | | </folderInfo> |
| | | <sourceEntries> |
| | | <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/> |
| | | <entry excluding="**/win/**" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/> |
| | | <entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="test"/> |
| | | </sourceEntries> |
| | | </configuration> |
| | |
| | | SET(LICENSECC_VERSION "${LICENSECC_MAJOR_VERSION}.${LICENSECC_MINOR_VERSION}.${LICENSECC_PATCH_VERSION}") |
| | | SET(LICENSECC_SHORT_LICENSE "BSD Software License") |
| | | |
| | | SET(CMAKE_DISABLE_SOURCE_CHANGES OFF) |
| | | SET(CMAKE_DISABLE_SOURCE_CHANGES ON) |
| | | SET(CMAKE_DISABLE_IN_SOURCE_BUILD ON) |
| | | SET(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "CMake verbose" FORCE) |
| | | |
| | |
| | | #include "pc-identifiers.h" |
| | | #include "LicenseReader.h" |
| | | #include "base/StringUtils.h" |
| | | #include "base/public-key.h" |
| | | #include "public-key.h" |
| | | #include <build_properties.h> |
| | | |
| | | #include "os/os-cpp.h" |
| | |
| | | } |
| | | |
| | | void EventRegistry::addError(EVENT_TYPE event) { |
| | | addEvent(event, SVRT_ERROR); |
| | | this->addEvent(event, SVRT_ERROR); |
| | | } |
| | | |
| | | void EventRegistry::addEvent(EVENT_TYPE event, SEVERITY severity) { |
| | |
| | | #ifndef _GNU_SOURCE |
| | | #define _GNU_SOURCE /* To get defns of NI_MAXSERV and NI_MAXHOST */ |
| | | #endif |
| | | #include <arpa/inet.h> |
| | | #include <sys/socket.h> |
| | | #include <netdb.h> |
| | |
| | | #include <sys/ioctl.h> |
| | | #include <sys/stat.h> |
| | | #include "../os.h" |
| | | #include "../../base/public-key.h" |
| | | #include "public-key.h" |
| | | |
| | | #include <openssl/evp.h> |
| | | #include <openssl/bio.h> |
| | |
| | | #ifndef _GNU_SOURCE |
| | | #define _GNU_SOURCE /* To get defns of NI_MAXSERV and NI_MAXHOST */ |
| | | #endif |
| | | #include <arpa/inet.h> |
| | | #include <sys/socket.h> |
| | | #include <netdb.h> |
| | |
| | | #include <sys/ioctl.h> |
| | | #include <sys/stat.h> |
| | | #include "../os-cpp.h" |
| | | #include "../../base/public-key.h" |
| | | #include "public-key.h" |
| | | |
| | | #include <openssl/evp.h> |
| | | #include <openssl/bio.h> |
| | |
| | | const char* signatureB64) { |
| | | EVP_MD_CTX *mdctx = NULL; |
| | | |
| | | char *pubKey = PUBLIC_KEY; |
| | | const char *pubKey = PUBLIC_KEY; |
| | | |
| | | BIO* bio = BIO_new_mem_buf((void*) (pubKey), strlen(pubKey)); |
| | | RSA *rsa = PEM_read_bio_RSAPublicKey(bio, NULL, NULL, NULL); |
| | |
| | | virtual const string exportPrivateKey() const = 0; |
| | | virtual const string exportPublicKey() const = 0; |
| | | |
| | | virtual const string signString(const unsigned char* privateKey, |
| | | virtual const string signString(const void* privateKey, |
| | | size_t pklen, const string& license) const = 0; |
| | | static unique_ptr<CryptoHelper> getInstance(); |
| | | virtual ~CryptoHelper(); |
| | |
| | | #include <openssl/bio.h> |
| | | #include <openssl/pem.h> |
| | | #include <openssl/err.h> |
| | | #include <openssl/rsa.h> |
| | | #include <stdexcept> |
| | | #include <string> |
| | | #include <cstddef> |
| | |
| | | return subject; |
| | | } |
| | | |
| | | |
| | | CryptoHelperLinux::CryptoHelperLinux() { |
| | | static int initialized = 0; |
| | | rsa = NULL; |
| | |
| | | |
| | | } |
| | | void CryptoHelperLinux::generateKeyPair() { |
| | | srand(time(NULL)); /* seed random number generator */ |
| | | int random = rand(); |
| | | rsa = RSA_generate_key(kBits, kExp, 0, 0); |
| | | } |
| | | |
| | | const string CryptoHelperLinux::exportPrivateKey() const { |
| | | if (rsa == NULL) { |
| | | throw logic_error(string("Export not initialized.Call generateKeyPair first.")); |
| | | throw logic_error( |
| | | string("Export not initialized.Call generateKeyPair first.")); |
| | | } |
| | | BIO* bio_private = BIO_new(BIO_s_mem()); |
| | | PEM_write_bio_RSAPrivateKey(bio_private, rsa, NULL, NULL, 0, NULL, NULL); |
| | | int keylen = BIO_pending(bio_private); |
| | | char* pem_key = (char*) (calloc(keylen + 1, 1)); /* Null-terminate */ |
| | | BIO_read(bio_private, pem_key, keylen); |
| | | string dest = replaceAll(string(pem_key), string("\n"), |
| | | string("\\n\" \\\n\"")); |
| | | string dest = string("\"") |
| | | + replaceAll(string(pem_key), string("\n"), string("\\n\" \\\n\"")) |
| | | + string("\""); |
| | | BIO_free_all(bio_private); |
| | | free(pem_key); |
| | | return dest; |
| | |
| | | |
| | | const string CryptoHelperLinux::exportPublicKey() const { |
| | | if (rsa == NULL) { |
| | | throw logic_error(string("Export not initialized.Call generateKeyPair first.")); |
| | | throw logic_error( |
| | | string("Export not initialized.Call generateKeyPair first.")); |
| | | } |
| | | BIO* bio_private = BIO_new(BIO_s_mem()); |
| | | PEM_write_bio_RSAPrivateKey(bio_private, rsa, NULL, NULL, 0, NULL, NULL); |
| | | int keylen = BIO_pending(bio_private); |
| | | BIO* bio_public = BIO_new(BIO_s_mem()); |
| | | PEM_write_bio_RSAPublicKey(bio_public, rsa); |
| | | int keylen = BIO_pending(bio_public); |
| | | char* pem_key = (char*) (calloc(keylen + 1, 1)); /* Null-terminate */ |
| | | BIO_read(bio_private, pem_key, keylen); |
| | | std::string dest = replaceAll(string(pem_key), string("\n"), |
| | | string("\\n\" \\\n\"")); |
| | | BIO_free_all(bio_private); |
| | | BIO_read(bio_public, pem_key, keylen); |
| | | std::string dest = string("\"") |
| | | + replaceAll(string(pem_key), string("\n"), string("\\n\" \\\n\"")) |
| | | + string("\""); |
| | | BIO_free_all(bio_public); |
| | | free(pem_key); |
| | | return dest; |
| | | } |
| | | |
| | | string CryptoHelperLinux::signString(const unsigned char* privateKey, size_t pklen, |
| | | const string& license) const { |
| | | string CryptoHelperLinux::signString(const void* privateKey, |
| | | size_t pklen, const string& license) const { |
| | | size_t slen; |
| | | unsigned char* signature; |
| | | signature = NULL; |
| | |
| | | if (!mdctx) { |
| | | throw logic_error("Message digest creation context"); |
| | | } |
| | | |
| | | |
| | | BIO* bio = BIO_new_mem_buf((void*) (privateKey), pklen); |
| | | EVP_PKEY *pktmp = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL); |
| | |
| | | EVP_MD_CTX_destroy(mdctx); |
| | | } |
| | | /* Call update with the message */ |
| | | if (EVP_DigestSignUpdate(mdctx, (const void*) license.c_str(), (size_t) license.length()) != 1) { |
| | | if (EVP_DigestSignUpdate(mdctx, (const void* ) license.c_str(), |
| | | (size_t ) license.length()) |
| | | != 1) { |
| | | EVP_MD_CTX_destroy(mdctx); |
| | | throw logic_error("Message signing exception"); |
| | | } |
| | |
| | | return signatureStr; |
| | | } |
| | | |
| | | const string CryptoHelperLinux::Opensslb64Encode(size_t slen, unsigned char* signature) const{ |
| | | const string CryptoHelperLinux::Opensslb64Encode(size_t slen, |
| | | unsigned char* signature) const { |
| | | /* |
| | | FILE* stream = fmemopen(*buffer, encodedSize+1, "w"); |
| | | */ |
| | |
| | | virtual const string exportPrivateKey() const; |
| | | virtual const string exportPublicKey() const; |
| | | |
| | | virtual string signString(const unsigned char* privateKey, size_t pklen, |
| | | virtual string signString(const void* privateKey, size_t pklen, |
| | | const string& license) const; |
| | | virtual ~CryptoHelperLinux(); |
| | | }; |
| | |
| | | class CryptoHelperWindows: public CryptoHelper { |
| | | public: |
| | | CryptoHelperWindows(); |
| | | |
| | | virtual void generateKeyPair(); |
| | | virtual const string exportPrivateKey() const; |
| | | virtual const string exportPublicKey() const; |
| | | |
| | | virtual string signString(const void* privateKey, size_t pklen, |
| | | const string& license) const; |
| | | |
| | | virtual ~CryptoHelperWindows(); |
| | | }; |
| | | |
| | |
| | | add_executable( |
| | | bootstrap |
| | | Main.cpp |
| | | bootstrap.cpp |
| | | ) |
| | | |
| | | |
| | |
| | | |
| | | # add the command to generate the source code |
| | | add_custom_command ( |
| | | OUTPUT "${CMAKE_BINARY_DIR}/src/tools/license-generator/private-key.h" "${CMAKE_BINARY_DIR}/src/library/base/public-key.h" |
| | | COMMAND bootstrap "${CMAKE_BINARY_DIR}/src/tools/license-generator/private-key.h" "${CMAKE_BINARY_DIR}/src/library/base/public-key.h" |
| | | OUTPUT "${CMAKE_BINARY_DIR}/private-key.h" "${CMAKE_BINARY_DIR}/public-key.h" |
| | | COMMAND bootstrap "${CMAKE_BINARY_DIR}/private-key.h" "${CMAKE_BINARY_DIR}/public-key.h" |
| | | DEPENDS bootstrap |
| | | ) |
| | | |
| | | add_custom_target(private_key DEPENDS "${CMAKE_BINARY_DIR}/src/tools/license-generator/private-key.h") |
| | | add_custom_target(public_key DEPENDS "${CMAKE_BINARY_DIR}/src/library/base/public-key.h") |
| | | add_custom_target(private_key DEPENDS "${CMAKE_BINARY_DIR}/private-key.h") |
| | | add_custom_target(public_key DEPENDS "${CMAKE_BINARY_DIR}/public-key.h") |
| | | |
| | | |
| | | # add the command to generate the source code |
File was renamed from src/tools/bootstrap/Main.cpp |
| | |
| | | } |
| | | fprintf(fp, "//file generated by bootstrap.cpp, do not edit.\n\n"); |
| | | fprintf(fp, "#ifndef PUBLIC_KEY_H_\n#define PUBLIC_KEY_H_\n"); |
| | | fprintf(fp, "define PUBLIC_KEY { \n"); |
| | | fprintf(fp, "#define PUBLIC_KEY { \\\n"); |
| | | fprintf(fp, "%s", pbPublicKey.c_str()); |
| | | fprintf(fp, "\n};\n\n"); |
| | | fprintf(fp, "}\n\n"); |
| | | int random = rand() % 1000; |
| | | fprintf(fp, "#define SHARED_RANDOM %d;\n", random); |
| | | fprintf(fp, "#endif\n"); |
| | |
| | | } |
| | | fprintf(fp, "//file generated by bootstrap.cpp, do not edit.\n\n"); |
| | | fprintf(fp, "#ifndef PRIVATE_KEY_H_\n#define PRIVATE_KEY_H_\n"); |
| | | fprintf(fp, "define PRIVATE_KEY = {\n"); |
| | | fprintf(fp, "#define PRIVATE_KEY { \\\n"); |
| | | fprintf(fp, "%s", privateKey.c_str()); |
| | | fprintf(fp, "\n};\n\n"); |
| | | fprintf(fp, "}\n\n"); |
| | | fprintf(fp, "#endif\n"); |
| | | fclose(fp); |
| | | } |
| | |
| | | target_link_libraries( |
| | | license_generator_lib |
| | | tools_base |
| | | license++_static |
| | | $<$<CONFIG:Debug>:${Boost_PROGRAM_OPTIONS_LIBRARY_DEBUG}> |
| | | $<$<NOT:$<CONFIG:Debug>>:${Boost_PROGRAM_OPTIONS_LIBRARY_RELEASE}> |
| | | $<$<CONFIG:Debug>:${Boost_SYSTEM_LIBRARY_DEBUG}> |
| | | $<$<NOT:$<CONFIG:Debug>>:${Boost_SYSTEM_LIBRARY_RELEASE}> |
| | | $<$<CONFIG:Debug>:${Boost_DATE_TIME_LIBRARY_DEBUG}> |
| | | $<$<NOT:$<CONFIG:Debug>>:${Boost_DATE_TIME_LIBRARY_RELEASE}> |
| | | ${EXTERNAL_LIBS} |
| | | ) |
| | | |
| | |
| | | #include <build_properties.h> |
| | | #include "LicenseSigner.h" |
| | | #include <private-key.h> |
| | | #include "license-generator.h" |
| | | #include "../library/base/StringUtils.h" |
| | | #include "../base_lib/CryptoHelper.h" |
| | | #include <stdlib.h> |
| | | #include <stdio.h> |
| | | #include <iostream> |
| | |
| | | client_signature = vm["client_signature"].as<string>(); |
| | | //fixme match + and / |
| | | /*regex e("(A-Za-z0-9){4}-(A-Za-z0-9){4}-(A-Za-z0-9){4}-(A-Za-z0-9){4}"); |
| | | if (!regex_match(client_signature, e)) { |
| | | cerr << endl << "Client signature not recognized: " |
| | | << client_signature |
| | | << " Please enter a valid signature in format XXXX-XXXX-XXXX-XXXX" |
| | | << endl; |
| | | exit(2); |
| | | }*/ |
| | | if (!regex_match(client_signature, e)) { |
| | | cerr << endl << "Client signature not recognized: " |
| | | << client_signature |
| | | << " Please enter a valid signature in format XXXX-XXXX-XXXX-XXXX" |
| | | << endl; |
| | | exit(2); |
| | | }*/ |
| | | } |
| | | string extra_data = ""; |
| | | if (vm.count("extra_data")) { |
| | | extra_data = vm["extra_data"].as<string>(); |
| | | } |
| | | unsigned int from_sw_version = vm["start_version"].as< |
| | | unsigned int>(); |
| | | unsigned int to_sw_version = |
| | | vm["end_version"].as<unsigned int>(); |
| | | unsigned int from_sw_version = vm["start_version"].as<unsigned int>(); |
| | | unsigned int to_sw_version = vm["end_version"].as<unsigned int>(); |
| | | if (vm.count("product") == 0) { |
| | | cerr << endl << "Parameter [product] not found. " << endl; |
| | | exit(2); |
| | |
| | | void LicenseGenerator::generateAndOutputLicenses(const po::variables_map& vm, |
| | | ostream& outputFile) { |
| | | vector<FullLicenseInfo> licenseInfo = parseLicenseInfo(vm); |
| | | license::LicenseSigner licSigner = |
| | | vm.count("private_key") == 0 ? |
| | | license::LicenseSigner() : |
| | | license::LicenseSigner(vm["private_key"].as<string>()); |
| | | unique_ptr<CryptoHelper> helper = CryptoHelper::getInstance(); |
| | | const char pkey[] = PRIVATE_KEY; |
| | | size_t len = sizeof(pkey); |
| | | for (auto it = licenseInfo.begin(); it != licenseInfo.end(); ++it) { |
| | | licSigner.signLicense(*it); |
| | | const string license = it->printForSign(); |
| | | string signature = helper->signString((const void *)pkey,len,license); |
| | | it->license_signature = signature; |
| | | it->printAsIni(outputFile); |
| | | } |
| | | } |
| | |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | const std::string formats[] = { "%4u-%2u-%2u","%4u/%2u/%2u","%4u%2u%2u" }; |
| | | const std::string formats[] = { "%4u-%2u-%2u", "%4u/%2u/%2u", "%4u%2u%2u" }; |
| | | const size_t formats_n = 3; |
| | | |
| | | string LicenseGenerator::normalize_date(const char * s) { |
| | | unsigned int year, month, day; |
| | | int chread; |
| | | bool found = false; |
| | | for (size_t i = 0; i < formats_n &&!found; ++i) { |
| | | chread = sscanf(s, formats[i].c_str(),&year, &month, &day); |
| | | if (chread == 3){ |
| | | for (size_t i = 0; i < formats_n && !found; ++i) { |
| | | chread = sscanf(s, formats[i].c_str(), &year, &month, &day); |
| | | if (chread == 3) { |
| | | found = true; |
| | | } |
| | | } |
| | | if (!found){ |
| | | if (!found) { |
| | | throw invalid_argument("Date not recognized."); |
| | | } |
| | | ostringstream oss; |
| | | oss << year << "-"<<setfill('0') << std::setw(2)<< month<<"-"<<day; |
| | | oss << year << "-" << setfill('0') << std::setw(2) << month << "-" << day; |
| | | //delete (facet); |
| | | return oss.str(); |
| | | } |
| | |
| | | #define LICENSE_GENERATOR_H_ |
| | | |
| | | #include <boost/program_options.hpp> |
| | | #include "../library/LicenseReader.h" |
| | | #include "../../library/LicenseReader.h" |
| | | |
| | | namespace license { |
| | | |
| | |
| | | //#define BOOST_TEST_MAIN |
| | | //#define BOOST_TEST_DYN_LINK |
| | | #include <boost/test/unit_test.hpp> |
| | | #include "../../../src/license-generator/license-generator.h" |
| | | #include "../../../src/tools/license-generator/license-generator.h" |
| | | #include "../../../src/library/api/license++.h" |
| | | #include <build_properties.h> |
| | | #include <boost/filesystem.hpp> |
| | |
| | | */ |
| | | |
| | | #include <boost/test/unit_test.hpp> |
| | | #include "../../../src/license-generator/license-generator.h" |
| | | #include "../../../src/tools/license-generator/license-generator.h" |
| | | #include <build_properties.h> |
| | | #include <boost/filesystem.hpp> |
| | | #include "../../src/library/ini/SimpleIni.h" |
| | |
| | | //#define BOOST_TEST_MAIN |
| | | //#define BOOST_TEST_DYN_LINK |
| | | #include <boost/test/unit_test.hpp> |
| | | #include "../../../src/license-generator/license-generator.h" |
| | | #include "../../../src/tools/license-generator/license-generator.h" |
| | | #include "../../../src/library/api/license++.h" |
| | | #include <build_properties.h> |
| | | #include <boost/filesystem.hpp> |
| | |
| | | #include <boost/test/unit_test.hpp> |
| | | #include <fstream> |
| | | #include <cstring> |
| | | #include "../../../src/license-generator/license-generator.h" |
| | | #include "../../../src/tools/license-generator/license-generator.h" |
| | | #include "../../../src/library/api/license++.h" |
| | | #include <build_properties.h> |
| | | #include <boost/filesystem.hpp> |
| | |
| | | } |
| | | |
| | | BOOST_AUTO_TEST_CASE( read_network_adapters ) { |
| | | AdapterInfo * adapter_info = NULL; |
| | | OsAdapterInfo * adapter_info = NULL; |
| | | size_t adapter_info_size = 0; |
| | | FUNCTION_RETURN result = getAdapterInfos(NULL, &adapter_info_size); |
| | | BOOST_CHECK_EQUAL(result, FUNC_RET_OK); |
| | | BOOST_CHECK_GT(adapter_info_size, 0); |
| | | adapter_info = (AdapterInfo*) malloc( |
| | | sizeof(AdapterInfo) * adapter_info_size); |
| | | adapter_info = (OsAdapterInfo*) malloc( |
| | | sizeof(OsAdapterInfo) * adapter_info_size); |
| | | result = getAdapterInfos(adapter_info, &adapter_info_size); |
| | | BOOST_CHECK_EQUAL(result, FUNC_RET_OK); |
| | | for (size_t i = 0; i < adapter_info_size; i++) { |
| | |
| | | //#define BOOST_TEST_MAIN |
| | | //#define BOOST_TEST_DYN_LINK |
| | | #include <boost/test/unit_test.hpp> |
| | | #include "../../../src/license-generator/license-generator.h" |
| | | #include "../../../src/tools/license-generator/license-generator.h" |
| | | #include <build_properties.h> |
| | | #include <boost/filesystem.hpp> |
| | | #include "../../src/library/ini/SimpleIni.h" |