Skip to content

Commit

Permalink
1.1.0 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
abumq committed Jul 20, 2023
1 parent 6b26248 commit 6d24300
Show file tree
Hide file tree
Showing 40 changed files with 667 additions and 1,240 deletions.
1 change: 0 additions & 1 deletion .github/FUNDING.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
CMakeLists.txt.user
build
.vscode
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ install:

## Crypto++ (We dont need this for residue, we need it for ripe and mine)
- git clone https://github.com/weidai11/cryptopp.git
- git clone https://github.com/amraynweb/cryptopp-pem.git
- git clone https://github.com/abumq/cryptopp-pem.git
- cp cryptopp-pem/* cryptopp/
- cd cryptopp
- make
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [1.1.0] - 20-07-2023
- Updated Crypto++ dep to 8.8.0
- Change C++ dependency to C++14
- Using `std::array` instead of raw array
- C bindings (special shout out to [`spotzai`](https://github.com/spotzai) for PR)

## [1.0.6] - 24-11-2018
- Updated license

Expand Down
36 changes: 20 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ option (test "Build all tests" OFF)
option (BUILD_SHARED_LIBS "build shared libraries" ON)
option (travis "Travis CI" OFF)

set (EXTERNAL_INCLUDE_DIR "external")

set (LICENSEPP_MAJOR "1")
set (LICENSEPP_MINOR "0")
set (LICENSEPP_PATCH "6")
set (LICENSEPP_MINOR "1")
set (LICENSEPP_PATCH "0")

set (LICENSEPP_SOVERSION "${LICENSEPP_MAJOR}.${LICENSEPP_MINOR}.${LICENSEPP_PATCH}")
set (LICENSEPP_NAME "licensepp")

add_definitions (-DLICENSEPP_SOVERSION="${LICENSEPP_SOVERSION}")
add_definitions (-DRIPE_VERSION="4.0.1-custom-static")
if (travis)
add_definitions (-DLICENSEPP_ON_CI)
endif()
Expand All @@ -36,7 +37,7 @@ if (APPLE)
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 -Wall -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O3 -Wall -Werror -Wno-return-stack-address")
endif()

# Check for cryptopp (static)
Expand All @@ -45,13 +46,18 @@ find_package(CryptoPP REQUIRED)
message ("-- Crypto++ binary: " ${CRYPTOPP_LIBRARY})
include_directories (${CRYPTOPP_INCLUDE_DIRS})

# Ripe (static)
set(RIPE_USE_STATIC_LIBS OFF)
find_package(Ripe REQUIRED)

include_directories (${EXTERNAL_INCLUDE_DIR})

set(LICENSEPP_SOURCE_FILES
license++/license-exception.h
license++/license.h
license++/issuing-authority.h
license++/base-license-manager.h
src/external/Ripe.cc
license++/c-bindings.h
src/utils.cc
src/json-object.cc
src/crypto/aes.cc
Expand All @@ -60,6 +66,7 @@ set(LICENSEPP_SOURCE_FILES
src/crypto/rsa.cc
src/issuing-authority.cc
src/license.cc
src/c-bindings.cc
)

add_library (licensepp-lib ${LICENSEPP_SOURCE_FILES})
Expand All @@ -68,8 +75,10 @@ set_target_properties (licensepp-lib PROPERTIES
VERSION ${LICENSEPP_SOVERSION}
)
target_include_directories (licensepp-lib PUBLIC $<INSTALL_INTERFACE:include>)

target_link_libraries (licensepp-lib
${CRYPTOPP_LIBRARIES}
${RIPE_LIBRARY}
)

set_target_properties (licensepp-lib PROPERTIES OUTPUT_NAME "licensepp")
Expand All @@ -78,6 +87,7 @@ install (FILES license++/base-license-manager.h DESTINATION "include/license++")
install (FILES license++/issuing-authority.h DESTINATION "include/license++")
install (FILES license++/license.h DESTINATION "include/license++")
install (FILES license++/license-exception.h DESTINATION "include/license++")
install (FILES license++/c-bindings.h DESTINATION "include/license++")
install (EXPORT licensepp-config DESTINATION share/licensepp/cmake)
export (TARGETS licensepp-lib FILE licensepp-config.cmake)

Expand All @@ -95,20 +105,14 @@ set (CPACK_SOURCE_IGNORE_FILES
)
include (CPack)

# Compile-time configuration.
configure_file (
${CMAKE_SOURCE_DIR}/cmake/config.h.cmake
${CMAKE_BINARY_DIR}/config.h
)

include_directories (${CMAKE_BINARY_DIR})
include_directories (${CMAKE_SOURCE_DIR})

if (test)

find_package (gtest REQUIRED)
find_package (GTest REQUIRED)

include_directories (${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
include_directories (${GTEST_INCLUDE_DIRS})

enable_testing()

Expand All @@ -120,12 +124,12 @@ if (test)
)

# Standard linking to gtest stuff.
target_link_libraries (licensepp-unit-tests gtest gtest_main)
target_link_libraries (licensepp-unit-tests
${GTEST_LIBRARIES}
)

# Extra linking for the project.
target_link_libraries (licensepp-unit-tests licensepp-lib)

target_link_libraries (licensepp-unit-tests ${CRYPTOPP_LIBRARIES})

add_test (NAME licenseppUnitTests COMMAND licensepp-unit-tests)
endif() ## test
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,23 @@ I created a concept of digital software licence and implemented it under this pr

### Dependencies

* C++11
* C++11 (C++14 if building with test since latest Google C++ Testing Library requires C++14)
* [Crypto++](https://www.cryptopp.com/) v5.6.5+ [with Pem Pack](https://abumq.github.io/downloads/pem_pack.zip)
* [cmake](https://cmake.org/) v2.8.12+
* [Ripe](https://github.com/abumq/ripe)

### Installation
* [Download](https://github.com/abumq/licensepp/archive/master.zip) or [clone]([email protected]:abumq/licensepp.git) the repository
* Install Crypto++
```
git clone https://github.com/abumq/licensepp
git clone https://github.com/weidai11/cryptopp.git
git clone https://github.com/noloader/cryptopp-pem.git
cp cryptopp-pem/* cryptopp/
cd cryptopp
make
sudo make install
wget https://raw.githubusercontent.com/abumq/abumq.github.io/master/downloads/cryptocpp.tar.gz
tar xf cryptocpp.tar.gz
cd cryptopp-CRYPTOPP_5_6_5
wget https://raw.githubusercontent.com/abumq/abumq.github.io/master/downloads/pem_pack.zip
unzip pem_pack.zip
cmake .
make
sudo make install
```
* Use CMake to build the project
```
Expand All @@ -48,7 +50,7 @@ I created a concept of digital software licence and implemented it under this pr
make
sudo make install
## build with test
## build with test (make sure you have Google C++ Testing Library)
cmake -Dtest=ON ..
make
sudo make install
Expand Down
2 changes: 1 addition & 1 deletion cli/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
license-manager: main.cc licensing/license-manager-key-register.cc
g++ main.cc licensing/license-manager-key-register.cc -I/usr/local/lib -llicensepp -lcryptopp -std=c++11 -O3 -o license-manager
g++ main.cc licensing/license-manager-key-register.cc -I/usr/local/lib -llicensepp -std=c++11 -O3 -o license-manager


2 changes: 1 addition & 1 deletion cli/licensing/license-manager-key-register.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using namespace licensepp;

const unsigned char LicenseManagerKeyRegister::LICENSE_MANAGER_SIGNATURE_KEY[16] = {
const std::array<unsigned char, 16> LicenseManagerKeyRegister::LICENSE_MANAGER_SIGNATURE_KEY = {
0x5B, 0x6A, 0xF5, 0x93, 0xED, 0xAB, 0xB3, 0x10, 0xF5, 0xBE, 0x00, 0xE6, 0x4F, 0x1B, 0x70, 0xC8
};

Expand Down
3 changes: 2 additions & 1 deletion cli/licensing/license-manager-key-register.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
#ifndef LicenseManagerKeyRegister_h
#define LicenseManagerKeyRegister_h

#include <array>
#include <string>
#include <vector>
#include <license++/issuing-authority.h>

class LicenseManagerKeyRegister
{
public:
static const unsigned char LICENSE_MANAGER_SIGNATURE_KEY[];
static const std::array<unsigned char, 16> LICENSE_MANAGER_SIGNATURE_KEY;

static const std::vector<licensepp::IssuingAuthority> LICENSE_ISSUING_AUTHORITIES;
};
Expand Down
6 changes: 3 additions & 3 deletions cli/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Copyright © 2018-present @abumq (Majid Q.)
//
// See https://github.com/amrayn/licensepp/blob/master/LICENSE
// See https://github.com/abumq/licensepp/blob/master/LICENSE
//

#include <cstring>
Expand All @@ -18,7 +18,7 @@ void displayUsage() {
}

void displayVersion() {
std::cout << "License Manager v1.0.0" << std::endl;
std::cout << "License Manager v1.1.0" << std::endl;
}

int main(int argc, char* argv[])
Expand Down Expand Up @@ -91,7 +91,7 @@ int main(int argc, char* argv[])
std::cout << "Invalid issuing authority." << std::endl;
return 1;
}
licensepp::License license = licenseManager.issue(licensee, period, issuingAuthority, secret, signature,additionalPayload);
licensepp::License license = licenseManager.issue(licensee, period, issuingAuthority, secret, signature, additionalPayload);
std::cout << license.toString() << std::endl;
std::cout << "Licensed to " << license.licensee() << std::endl;
std::cout << "Subscription is active until " << license.formattedExpiry() << std::endl << std::endl;
Expand Down
39 changes: 39 additions & 0 deletions cmake/FindRipe.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# CMake module for Ripe cryptography wrapper
#
# Creates ${RIPE_INCLUDE_DIR} and ${RIPE_LIBRARY}
#
# If ${RIPE_USE_STATIC_LIBS} is ON then static libs are preferred over shared
#
# Copyright 2017-present @abumq (Majid Q.)
#
# https://github.com/abumq/ripe
#

set(RIPE_PATHS ${RIPE_ROOT} $ENV{RIPE_ROOT})

find_path(RIPE_INCLUDE_DIR
Ripe.h
PATH_SUFFIXES include
PATHS ${RIPE_PATHS}
)

if (RIPE_USE_STATIC_LIBS)
message ("-- Ripe: Static linking")
find_library(RIPE_LIBRARY
NAMES libripe.a
HINTS "${CMAKE_PREFIX_PATH}/lib"
)
else()
message ("-- Ripe: Dynamic linking")
find_library(RIPE_LIBRARY
NAMES libripe.dylib
HINTS "${CMAKE_PREFIX_PATH}/lib"
)
endif()

message ("-- Ripe: Include: " ${RIPE_INCLUDE_DIR} ", Binary: " ${RIPE_LIBRARY})

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(Ripe REQUIRED_VARS RIPE_INCLUDE_DIR RIPE_LIBRARY)
10 changes: 0 additions & 10 deletions cmake/config.h.cmake

This file was deleted.

5 changes: 2 additions & 3 deletions doxygen/README_DOXYGEN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ License++ is a cross platform software licensing library which allows you to imp
## Licence

```
Copyright (c) 2018-present Amrayn Web Services
Copyright (c) 2018-present @abumq (Majid Q.)
https://github.com/amrayn/
https://muflihun.com
https://github.com/abumq/
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion doxygen/customdoxygen.css
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ tr.heading h2 {
text-shadow: none;
}

div.image img[src="https://raw.githubusercontent.com/amrayn/residue/master/docs/Residue.png"] {
div.image img[src="https://raw.githubusercontent.com/abumq/residue/master/docs/Residue.png"] {
width: 50%;
max-width: 446px;
}
File renamed without changes.
19 changes: 9 additions & 10 deletions license++/base-license-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// See https://github.com/abumq/licensepp/blob/master/LICENSE
//

#ifndef BaseLicenseManager_h
#define BaseLicenseManager_h
#ifndef LICENSEPP_BaseLicenseManager_h
#define LICENSEPP_BaseLicenseManager_h

#include <iostream>
#include <string>
Expand All @@ -27,7 +27,7 @@ namespace licensepp {
/// key register.
///
/// The key register must contains two static members.
/// 1. static const unsigned char LICENSE_MANAGER_SIGNATURE_KEY[];
/// 1. static const std:array<unsigned char, 16> LICENSE_MANAGER_SIGNATURE_KEY;
/// 2. static const std::vector<licensepp::IssuingAuthority> LICENSE_ISSUING_AUTHORITIES;
///
/// Definitions must be provided as well.
Expand All @@ -37,12 +37,12 @@ namespace licensepp {
/// class LicenseKeysRegister
/// {
/// public:
/// static const unsigned char LICENSE_MANAGER_SIGNATURE_KEY[];
/// static const std::array<unsigned char, 16> LICENSE_MANAGER_SIGNATURE_KEY;
///
/// static const std::vector<IssuingAuthority> LICENSE_ISSUING_AUTHORITIES;
/// };
///
/// const unsigned char LicenseKeysRegister::LICENSE_MANAGER_SIGNATURE_KEY[] =
/// const std::array<unsigned char, 16> LicenseKeysRegister::LICENSE_MANAGER_SIGNATURE_KEY =
/// {
/// 0x27, 0xD4, 0x91, 0x55, 0xE6, 0x6D, 0xC3, 0x11,
/// 0x8D, 0xC0, 0x52, 0x0B, 0x2C, 0x9F, 0x84, 0xF3,
Expand All @@ -65,7 +65,7 @@ namespace licensepp {
/// };
/// </pre>
///
/// \see https://github.com/amrayn/licensepp/blob/master/sample/
/// \see https://github.com/abumq/licensepp/blob/master/sample/
///
template <class LicenseKeysRegister>
class BaseLicenseManager
Expand Down Expand Up @@ -145,12 +145,11 @@ class BaseLicenseManager
{
const std::string b16list = "0123456789ABCDEF";
std::stringstream ss;
for (auto i = 0; i < 16; ++i) {
ss << b16list[LicenseKeysRegister::LICENSE_MANAGER_SIGNATURE_KEY[i] >> 4]
<< b16list[LicenseKeysRegister::LICENSE_MANAGER_SIGNATURE_KEY[i] & 0xf];
for (const auto c : LicenseKeysRegister::LICENSE_MANAGER_SIGNATURE_KEY) {
ss << b16list[c >> 4] << b16list[c & 0xf];
}
return ss.str();
}
};
}
#endif // BaseLicenseManager_h
#endif // LICENSEPP_BaseLicenseManager_h
Loading

0 comments on commit 6d24300

Please sign in to comment.