build: fixed licensing project

* fixed license includes for windows
This commit is contained in:
malte_langkabel
2016-01-21 13:54:41 +01:00
parent 46d9825454
commit 3b62c1353e
3 changed files with 18 additions and 19 deletions
+4 -1
View File
@@ -30,9 +30,12 @@ For Win32:
Build release lib in ${BOTAN_DIR}/release Build release lib in ${BOTAN_DIR}/release
Build debug lib in ${BOTAN_DIR}/debug Build debug lib in ${BOTAN_DIR}/debug
for Windows: for Windows release build:
$ python configure.py --cc=msvc --cpu=x86_32 --via-amalgamation --disable-shared $ python configure.py --cc=msvc --cpu=x86_32 --via-amalgamation --disable-shared
for Windows debug build:
python configure.py --cc=msvc --cpu=x86_32 --via-amalgamation --disable-shared --no-optimizations --with-debug-info
for other: for other:
$ python configure.py --via-amalgamation --disable-shared $ python configure.py --via-amalgamation --disable-shared
+6 -11
View File
@@ -1,21 +1,15 @@
#include "License.h" #include "License.h"
#include <algorithm> #include <algorithm>
#include <cctype>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <istream> #include <istream>
// #include "botan/pubkey.h" #include "botan_all.h"
// #include "botan/base64.h"
// #include "botan/passhash9.h"
#include "boost/filesystem.hpp" #include "boost/filesystem.hpp"
// #ifdef BOTAN_HAS_RSA
// #include "botan/rsa.h"
// #endif
namespace namespace
{ {
std::string trim(const std::string &str) std::string trim(const std::string &str)
@@ -27,6 +21,7 @@ namespace
} }
License::License() License::License()
: m_rng(std::make_shared<Botan::AutoSeeded_RNG>())
{ {
} }
@@ -86,7 +81,7 @@ void License::create(std::string user, std::string version, Botan::RSA_PrivateKe
while (size_t got = in.read(buf, sizeof(buf))) { while (size_t got = in.read(buf, sizeof(buf))) {
signer.update(buf, got); signer.update(buf, got);
} }
std::string signature = Botan::base64_encode(signer.signature(m_rng)); std::string signature = Botan::base64_encode(signer.signature(*(m_rng.get())));
addSignature(signature); addSignature(signature);
} }
@@ -106,7 +101,7 @@ void License::createMessage(std::string user, std::string version, unsigned int
lines.push_back(typestring); lines.push_back(typestring);
std::string versionstring = "Coati " + getVersion(); std::string versionstring = "Coati " + getVersion();
lines.push_back(versionstring); lines.push_back(versionstring);
std::string pass9 = Botan::generate_passhash9(versionstring, m_rng); std::string pass9 = Botan::generate_passhash9(versionstring, *(m_rng.get()));
lines.push_back(pass9); lines.push_back(pass9);
} }
@@ -293,7 +288,7 @@ std::string License::getLicenseString() const
std::string License::hashLocation(const std::string& location) std::string License::hashLocation(const std::string& location)
{ {
return Botan::generate_passhash9(location, m_rng); return Botan::generate_passhash9(location, *(m_rng.get()));
} }
bool License::checkLocation(const std::string& location, const std::string& hash) bool License::checkLocation(const std::string& location, const std::string& hash)
+8 -7
View File
@@ -1,15 +1,16 @@
#ifndef COATI_LICENSE_H #ifndef COATI_LICENSE_H
#define COATI_LICENSE_H #define COATI_LICENSE_H
#include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
//#include "botan/botan.h" namespace Botan
#include "botan_all.h" {
class RSA_PublicKey;
#ifdef BOTAN_HAS_RSA class RSA_PrivateKey;
//#include "botan/rsa.h" class AutoSeeded_RNG;
#endif }
class License class License
{ {
@@ -60,7 +61,7 @@ private:
std::string m_publicKeyFilename; std::string m_publicKeyFilename;
std::shared_ptr<Botan::RSA_PublicKey> m_publicKey; std::shared_ptr<Botan::RSA_PublicKey> m_publicKey;
std::vector<std::string> lines; std::vector<std::string> lines;
Botan::AutoSeeded_RNG m_rng; std::shared_ptr<Botan::AutoSeeded_RNG> m_rng;
const std::string KEY_FILEENDING = ".pem"; const std::string KEY_FILEENDING = ".pem";
const std::string BEGIN_LICENSE = "-----BEGIN LICENSE-----"; const std::string BEGIN_LICENSE = "-----BEGIN LICENSE-----";