From dd64f246510b6c4e0618130bacbca5046c6295aa Mon Sep 17 00:00:00 2001
From: open-license-manager <rillf@maildrop.cc>
Date: 摹曛, 17 4月 2014 05:08:21 +0800
Subject: [PATCH] signature

---
 src/library/os/linux/os-linux.cpp |    9 ++++-----
 src/library/LicenseReader.cpp     |   25 +++++++++++++------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/library/LicenseReader.cpp b/src/library/LicenseReader.cpp
index 174bdb0..6e1c064 100644
--- a/src/library/LicenseReader.cpp
+++ b/src/library/LicenseReader.cpp
@@ -285,21 +285,22 @@
 	oss << toupper_copy(trim_copy(this->product));
 	oss << SHARED_RANDOM
 	;
-	/*if (has_client_sig) {
-	 oss << trim_copy(this->client_signature);
-	 }
-	 if (has_versions) {
-	 oss << "|" << this->from_sw_version << "-" << this->to_sw_version;
-	 }*/
+	if (has_client_sig) {
+		oss << trim_copy(this->client_signature);
+	}
+	if (has_versions) {
+		oss << "|" << this->from_sw_version << "-" << this->to_sw_version;
+	}
 	if (has_expiry) {
 		oss << "|" << this->from_date << "|" << this->to_date;
-	}/*
-	 if (this->extra_data.length() > 0) {
-	 oss << "|" << extra_data;
-	 }*/
-	string result = oss.str();
+	}
+	if (this->extra_data.length() > 0) {
+		oss << "|" << extra_data;
+	}
+#ifdef _DEBUG
 	cout << "[" << oss.str() << "]" << endl;
-	return result;
+#endif
+	return oss.str();
 
 }
 
diff --git a/src/library/os/linux/os-linux.cpp b/src/library/os/linux/os-linux.cpp
index f818677..eb515b2 100644
--- a/src/library/os/linux/os-linux.cpp
+++ b/src/library/os/linux/os-linux.cpp
@@ -14,7 +14,7 @@
 #include <openssl/bio.h>
 #include <openssl/pem.h>
 #include <openssl/err.h>
-#include <iostream>
+
 namespace license {
 
 using namespace std;
@@ -74,12 +74,11 @@
 	RSA *rsa = PEM_read_bio_RSAPublicKey(bio, NULL, NULL, NULL);
 	BIO_free(bio);
 	if (rsa == NULL) {
-		cout<<"cippa!"<<endl;
 		throw new logic_error("Error reading public key");
 	}
 	EVP_PKEY *pkey = EVP_PKEY_new();
 
-	cout << "test:" <<EVP_PKEY_assign_RSA(pkey, rsa)<<endl;
+	EVP_PKEY_assign_RSA(pkey, rsa);
 
 	/*BIO* bo = BIO_new(BIO_s_mem());
 	 BIO_write(bo, pubKey, strlen(pubKey));
@@ -89,7 +88,7 @@
 
 	//RSA* rsa = EVP_PKEY_get1_RSA( key );
 	//RSA * pubKey = d2i_RSA_PUBKEY(NULL, <der encoded byte stream pointer>, <num bytes>);
-	unsigned char buffer[129];
+	unsigned char buffer[512];
 	BIO* b64 = BIO_new(BIO_f_base64());
 	BIO* encoded_signature = BIO_new_mem_buf((void *) signatureB64,
 			strlen(signatureB64));
@@ -112,7 +111,7 @@
 	if (1
 			!= EVP_DigestVerifyUpdate(mdctx, stringToVerify,
 					en)) {
-		throw new logic_error("Error initializing digest");
+		throw new logic_error("Error verifying digest");
 	}
 	bool result;
 	int res= EVP_DigestVerifyFinal(mdctx, buffer, len);

--
Gitblit v1.9.1