Skip to content

Commit

Permalink
Merge pull request #1 from muflihun/develop
Browse files Browse the repository at this point in the history
1.0.0 release
  • Loading branch information
abumq authored Sep 5, 2017
2 parents 07de1f1 + 76a56f3 commit 8930432
Show file tree
Hide file tree
Showing 37 changed files with 8,949 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
logs
CMakeFiles
build
CMakeLists.txt.user
63 changes: 63 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
language: cpp
compiler:
- clang
dist: trusty
before_install:
- sudo add-apt-repository ppa:kubuntu-ppa/backports -y
- sudo apt-get -qq update
- sudo apt-get install -y libssl-dev libgtest-dev php5-cli valgrind
- sudo apt-get install --only-upgrade cmake
- cmake --version
- g++ --version
# Crypto++ (We manually install it because we need Pem Pack as well)
- wget https://raw.githubusercontent.com/muflihun/muflihun.github.io/master/downloads/cryptocpp.tar.gz
- tar xf cryptocpp.tar.gz
- cd cryptopp-CRYPTOPP_5_6_5
- wget https://raw.githubusercontent.com/muflihun/muflihun.github.io/master/downloads/pem_pack.zip
- unzip pem_pack.zip
- cmake .
- make
- sudo make install
## Ripe
# - RIPE_VERSION=4.0.0
# - RIPE_VERSION_URL="v$RIPE_VERSION"
# - wget -O ripe-code.zip https://github.com/muflihun/ripe/archive/$RIPE_VERSION_URL.zip
# - unzip ripe-code.zip
# - cd ripe-$RIPE_VERSION
# - cmake .
# - make
# - ls -l
# - sudo make install
# GTest
- wget -O gtest.tar.gz https://github.com/google/googletest/archive/release-1.7.0.tar.gz
- tar xf gtest.tar.gz
- cd googletest-release-1.7.0
- cmake -DBUILD_SHARED_LIBS=ON .
- make
- sudo cp -a include/gtest /usr/include
- sudo cp -a libgtest_main.so libgtest.so /usr/lib/
- cd ..
## Easylogging++
- wget https://github.com/muflihun/easyloggingpp/archive/master.zip
- unzip master.zip
- cd easyloggingpp-master
- cmake .
- make
- sudo make install
## Build
- cd "${TRAVIS_BUILD_DIR}"
- pwd
- php build.php # build mine headers
- mkdir build
- cd build
- pwd
- ls -l
- ls -l ..
- cmake -Dtest_main_header=ON -Dtest_wstring_conversions=OFF ..
- make

script: "./mine-unit-tests"
branches:
only:
- develop

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Change Log

## [1.0.0] - 05-09-2017
### Added
- Initial release
182 changes: 182 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
cmake_minimum_required(VERSION 2.8.12)

project(Mine)

option (test_main_header "Test main header (mine.h)" OFF)
option (test_wstring_conversions "Test std::wstring (wchar_t*) conversions for encodings" ON)

set (MINE_VERSION "1.0.0")
set (MINE_SOVERSION "1.0.0")

add_definitions (-DMINE_VERSION="${MINE_VERSION}")

set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")

set(MINE_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in")

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

install(FILES
package/mine.h
package/mine.cc
DESTINATION "${MINE_INCLUDE_INSTALL_DIR}"
COMPONENT dev
)


include(FindPackageHandleStandardArgs)

# We need C++11
macro(require_cpp11)
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.0)
# CMake 3.1 has built-in CXX standard checks.
message("-- Setting C++11")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED on)
else()
if (CMAKE_CXX_COMPILER_ID MATCHES "GCC")
message ("-- GNU CXX (-std=c++11)")
list(APPEND CMAKE_CXX_FLAGS "-std=c++11")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message ("-- CLang CXX (-std=c++11)")
list(APPEND CMAKE_CXX_FLAGS "-std=c++11")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message ("-- GNU CXX (-std=c++11)")
list(APPEND CMAKE_CXX_FLAGS "-std=c++11")
else()
message ("-- Requires C++11. Your compiler does not support it.")
endif()
endif()
endmacro()

# http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH
if (APPLE)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif()
endif()

list (APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wunused ")

require_cpp11()

# Check for cryptopp (static)
set(CryptoPP_USE_STATIC_LIBS ON)
find_package(CryptoPP REQUIRED)
message ("-- Crypto++ binary: " ${CRYPTOPP_LIBRARY})
include_directories (${CRYPTOPP_INCLUDE_DIRS})

# Check for include files and stdlib properties.
include (CheckIncludeFileCXX)
check_include_file_cxx (attr/xattr.h HAVE_ATTR_XATTR_H)
check_include_file_cxx (sys/xattr.h HAVE_SYS_XATTR_H)

# Check if xattr functions take extra arguments, as they do on OSX.
# Output error is misleading, so do this test quietly.
include (CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
set (CMAKE_REQUIRED_QUIET True)
check_cxx_source_compiles ("#include <sys/types.h>
#include <sys/xattr.h>
int main() { getxattr(0,0,0,0,0,0); return 1; }
" XATTR_ADD_OPT)
set (CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})

# Reference all headers, to make certain IDEs happy.
file (GLOB_RECURSE all_headers ${CMAKE_SOURCE_DIR}/*.h)
add_custom_target (all_placeholder SOURCES ${all_headers})

#find_package(OPENSSL REQUIRED)
#if (OPENSSL_FOUND)
# include_directories(${OPENSSL_INCLUDE_DIR})
#endif(OPENSSL_FOUND)

find_package(ZLIB REQUIRED)
if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
endif(ZLIB_FOUND)

########################################## CLI Tool ###################################

add_executable (mine-cli cli/mine.cc
src/mine-common.cc
src/base64.cc
src/base16.cc
src/aes.cc
src/zlib.cc)

set_target_properties (mine-cli PROPERTIES
OUTPUT_NAME "mine"
VERSION ${MINE_VERSION}
)

target_link_libraries(mine-cli
${ZLIB_LIBRARIES}
#${OPENSSL_CRYPTO_LIBRARY}
)

install (TARGETS mine-cli DESTINATION bin)

########################################## Unit Testing ###################################

# Check for Easylogging++
find_package(EASYLOGGINGPP REQUIRED)
include_directories (${EASYLOGGINGPP_INCLUDE_DIR})

find_package (gtest REQUIRED)

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

enable_testing()

if (test_main_header)
add_executable(mine-unit-tests
test/main.cc
package/mine.cc
${EASYLOGGINGPP_INCLUDE_DIR}/easylogging++.cc
)

target_compile_definitions (mine-unit-tests PUBLIC
MINE_SINGLE_HEADER_TEST
)
else()
add_executable(mine-unit-tests
test/main.cc
src/mine-common.cc
src/rsa.cc
src/aes.cc
src/base16.cc
src/base64.cc
src/zlib.cc
${EASYLOGGINGPP_INCLUDE_DIR}/easylogging++.cc
)
endif()

target_link_libraries(mine-unit-tests
${ZLIB_LIBRARIES}
)

if (test_wstring_conversions)
target_compile_definitions (mine-unit-tests PUBLIC
MINE_WSTRING_CONVERSION
)
endif()

target_compile_definitions (mine-unit-tests PUBLIC
ELPP_STL_LOGGING
)

# Standard linking to gtest stuff.
target_link_libraries(mine-unit-tests gtest gtest_main)

# Extra linking for the project.
target_link_libraries(mine-unit-tests ${CRYPTOPP_LIBRARIES})

add_test(NAME mineUnitTests COMMAND mine-unit-tests)
49 changes: 34 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,52 @@

# Mine
Mine is minimal cryptography implementation of [RFC-3447](https://tools.ietf.org/html/rfc3447) and [RFC-3602](https://tools.ietf.org/html/rfc3602).
![banner]

# Introduction
It all started with [ripe](https://github.com/muflihun/ripe) that is dependent upon third-party library (initially OpenSSL then Crypto++) statically linked. However after using it for a while in [residue](https://github.com/muflihun/residue), we realized that portability became an issue for _minimal_ library. So we decided to start implementing the standards ourself, forming _mine_.
Mine is single-header minimal cryptography implementation for small-medium projects that cannot afford to link to external libraries.

# Status
Currently, it is not production ready. It depends upon third-party library. We are actively working on the development and implementation of RFC. We cannot guarantee the timeframe as all the contributors are full time workers and only do this project in their spare time.
[![Build Status](https://img.shields.io/travis/muflihun/mine/develop.svg)](https://travis-ci.org/muflihun/mine)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/muflihun/mine/blob/master/LICENCE)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/MuflihunDotCom/25)

# Overview
It all started with [ripe](https://github.com/muflihun/ripe) that depends on third-party library (initially OpenSSL then Crypto++) linked statically. However after deploying [residue](https://github.com/muflihun/residue) with ripe to older distributions of linux, we realized that portability is an issue for ripe as _minimal_ library. So we started to implement standards forming _Mine_.

We are very careful with our implementations and have [unit tests](/test/) in place.

# Installation
Simply copy `mine.h` and `mine.cc` from [`package/`](/package/) directory to your project or your local machine.

Alternatively, feel free to link it as shared or static library (you will need to compile yourself)

# Features
Mine _will_ support following features:
Mine supports following features:

* RSA (Encrypt, Decrypt, Sign and Verify) [[RFC-3447](https://tools.ietf.org/html/rfc3447)]
* AES-CBC [[RFC-3602](https://tools.ietf.org/html/rfc3602)]
* ZLib (Depend upon libz, eventually implement [[RFC-1950](https://tools.ietf.org/html/rfc3602)]
* Base-64 (Encode, Decode)
* Hex (Encode, Decode)
* Base16 Encoding
* Base64 Encoding
* RSA [[RFC-3447](https://tools.ietf.org/html/rfc3447)]
* AES [[FIPS Pub. 197](http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197.pdf)]
* ZLib (Depends upon libz)

For _minimal_ library this is what we are aiming.
This is what we are aiming for _minimal_ crypto library.

# Notes

* It is natively developed on macOS and Linux operating systems
* It is extremely fast with compiler optimization level 1 (or higher)
* RSA needs big number implementation, for unit tests we use [Integer from Crypto++](https://www.cryptopp.com/wiki/Integer)
* RSA currently does not support signing & verification or reading keys from PEM files

# Contribution
We are currently not accepting any pull requests for this project but if you have security concerns or see an issue in implementation please let us know via github issues.
You can contribute to the project by testing on various platforms (e.g, Windows, Android etc)

# License

```
Copyright 2017 Muflihun Labs
https://github.com/muflihun/
https://muflihun.com
https://muflihun.github.io
https://muflihun.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -43,3 +60,5 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

[banner]: https://raw.githubusercontent.com/muflihun/mine/develop/mine.png
Loading

0 comments on commit 8930432

Please sign in to comment.