Skip to content

Commit

Permalink
Merge pull request #16 from troian/pss
Browse files Browse the repository at this point in the history
feat: implement PSS sign and verify
  • Loading branch information
troian authored Oct 17, 2019
2 parents 460405f + 06183aa commit 42d4c34
Show file tree
Hide file tree
Showing 28 changed files with 916 additions and 399 deletions.
114 changes: 93 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,103 @@
language: cpp
sudo: required
dist: trusty

language: cpp

os: linux

matrix:
include:
- compiler: gcc
env:
- COMPILER_PACKAGE=g++-7
- C_COMPILER=gcc-7
- CXX_COMPILER=g++-7

- compiler: gcc
os: osx
env:
- COMPILER_PACKAGE=g++-7
- C_COMPILER=gcc-7
- CXX_COMPILER=g++-7

- compiler: gcc
env:
- COMPILER_PACKAGE=g++-8
- C_COMPILER=gcc-8
- CXX_COMPILER=g++-8

- compiler: gcc
os: osx
env:
- COMPILER_PACKAGE=g++-8
- C_COMPILER=gcc-8
- CXX_COMPILER=g++-8

- compiler: clang
env:
- COMPILER_PACKAGE=clang-5.0
- C_COMPILER=clang-5.0
- CXX_COMPILER=clang++-5.0

- compiler: clang
os: osx
env:
- COMPILER_PACKAGE=clang-5.0
- C_COMPILER=clang-5.0
- CXX_COMPILER=clang++-5.0

- compiler: clang
env:
- COMPILER_PACKAGE=clang-6.0
- C_COMPILER=clang-6.0
- CXX_COMPILER=clang++-6.0

- compiler: clang
os: osx
env:
- COMPILER_PACKAGE=clang-6.0
- C_COMPILER=clang-6.0
- CXX_COMPILER=clang++-6.0

git:
depth: 1
compiler:
- clang
- gcc
os:
- linux
- osx

before_install:
- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get update && sudo apt-get install libssl-dev; fi
- if [ $TRAVIS_OS_NAME == linux ]; then git clone https://github.com/open-source-parsers/jsoncpp.git ~/jsoncpp; fi
- if [ $TRAVIS_OS_NAME == linux ]; then export BLD_PATH=`pwd`; cd ~/jsoncpp; mkdir build && cd build; fi
- if [ $TRAVIS_OS_NAME == linux ]; then cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release ..; fi
- if [ $TRAVIS_OS_NAME == linux ]; then make && sudo make install && cd $BLD_PATH; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install openssl --force && brew install jsoncpp; fi
# Dependencies required by the CI are installed in ${TRAVIS_BUILD_DIR}/deps/
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
- mkdir -p "${DEPS_DIR}"
- cd "${DEPS_DIR}"
############################################################################
# Install a recent CMake (unless already installed on OS X)
############################################################################
- CMAKE_VERSION=3.15.4
- |
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
CMAKE_URL="https://cmake.org/files/v${CMAKE_VERSION%.[0-9]}/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz"
mkdir cmake && travis_retry wget --no-check-certificate -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
else
brew install cmake || brew upgrade cmake
fi
- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get update && sudo apt-get install libssl-dev; fi
- if [ $TRAVIS_OS_NAME == linux ]; then git clone https://github.com/open-source-parsers/jsoncpp.git ~/jsoncpp; fi
- if [ $TRAVIS_OS_NAME == linux ]; then export BLD_PATH=`pwd`; cd ~/jsoncpp; mkdir build && cd build; fi
- if [ $TRAVIS_OS_NAME == linux ]; then cmake -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release ..; fi
- if [ $TRAVIS_OS_NAME == linux ]; then make && sudo make install && cd $BLD_PATH; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install openssl --force && brew install jsoncpp; brew install cmake; fi
before_script:
- git submodule update --init --recursive
- mkdir build
- cd build
- if [ $TRAVIS_OS_NAME == osx ]; then cmake -Wno-dev -DWITH_TESTS=ON -DBUILD_SHARED_LIBS=ON -DOPENSSL_ROOT_DIR=$(brew --prefix openssl) -DCMAKE_INSTALL_PREFIX=/usr/local ..; fi
- if [ $TRAVIS_OS_NAME == linux ]; then cmake -DWITH_TESTS=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/usr/local ..; fi
- cd ${TRAVIS_BUILD_DIR}
- git submodule update --init --recursive
- mkdir build
- cd build
- if [ $TRAVIS_OS_NAME == osx ]; then cmake -Wno-dev -DWITH_TESTS=ON -DBUILD_SHARED_LIBS=ON -DOPENSSL_ROOT_DIR=$(brew --prefix openssl) -DCMAKE_INSTALL_PREFIX=/usr/local ..; fi
- if [ $TRAVIS_OS_NAME == linux ]; then cmake -DWITH_TESTS=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/usr/local ..; fi
script:
- make
- ./josepp_test
- sudo make install
- make
- cd ..
- ./build/josepp_test
- cd build
- sudo make install
branches:
only:
- master
Expand Down
115 changes: 60 additions & 55 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "

find_package(OpenSSL REQUIRED)
if (NOT WIN32)
find_package(PkgConfig REQUIRED)
pkg_check_modules(JsonCPP REQUIRED jsoncpp)
find_package(PkgConfig REQUIRED)
pkg_check_modules(JsonCPP REQUIRED jsoncpp)
endif (NOT WIN32)

include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR})
Expand All @@ -44,34 +44,33 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
endif (NOT MSVC)
#add_compile_options("-DOPENSSL_NO_DEPRECATED")

set(EXPORT_INCLUDES
include/export
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
endif ()

set(LIB_SOURCES
src/b64.cpp
src/claims.cpp
src/crypto.cpp
src/digest.cpp
src/ecdsa.cpp
src/header.cpp
src/hmac.cpp
src/jws.cpp
src/rsa.cpp
src/tools.cpp

${EXPORT_INCLUDES}/josepp/b64.hpp
${EXPORT_INCLUDES}/josepp/claims.hpp
${EXPORT_INCLUDES}/josepp/crypto.hpp
${EXPORT_INCLUDES}/josepp/digest.hpp
${EXPORT_INCLUDES}/josepp/header.hpp
${EXPORT_INCLUDES}/josepp/jws.hpp
${EXPORT_INCLUDES}/josepp/tools.hpp
${EXPORT_INCLUDES}/josepp/types.hpp
src/b64.cpp
src/claims.cpp
src/crypto.cpp
src/digest.cpp
src/ecdsa.cpp
src/header.cpp
src/hmac.cpp
src/jws.cpp
src/rsa.cpp
src/tools.cpp
src/pss.cpp
src/statics.cpp

include/export/josepp/b64.hpp
include/export/josepp/claims.hpp
include/export/josepp/crypto.hpp
include/export/josepp/digest.hpp
include/export/josepp/header.hpp
include/export/josepp/jws.hpp
include/export/josepp/tools.hpp
include/export/josepp/types.hpp
include/export/josepp/sstring.hh
include/local/josepp/statics.hh
)

add_library(${PROJECT_NAME}-static STATIC ${LIB_SOURCES})
Expand All @@ -80,8 +79,10 @@ set_target_properties(${PROJECT_NAME}-static PROPERTIES OUTPUT_NAME ${PROJECT_NA
target_include_directories(
${PROJECT_NAME}-static
PUBLIC
${EXPORT_INCLUDES}
${JsonCPP_INCLUDE_DIRS}
include/export
${JsonCPP_INCLUDE_DIRS}
PRIVATE
include/local
)

target_link_libraries(
Expand All @@ -93,12 +94,12 @@ target_link_libraries(
if (WITH_INSTALL)
install(
TARGETS
${PROJECT_NAME}-static
ARCHIVE
DESTINATION
lib
${PROJECT_NAME}-static
ARCHIVE
DESTINATION
lib
)
endif()
endif ()

if (BUILD_SHARED_LIBS)
add_library(${PROJECT_NAME}-shared SHARED ${LIB_SOURCES})
Expand All @@ -107,31 +108,34 @@ if (BUILD_SHARED_LIBS)
target_include_directories(
${PROJECT_NAME}-shared
PUBLIC
${EXPORT_INCLUDES}
${JsonCPP_INCLUDE_DIRS}
include/export
${JsonCPP_INCLUDE_DIRS}
PRIVATE
include/local
)

target_link_libraries(
${PROJECT_NAME}-shared
${OPENSSL_LIBRARIES}
${JsonCPP_LIBRARIES}
PUBLIC
${OPENSSL_LIBRARIES}
${JsonCPP_LIBRARIES}
)

if (WITH_INSTALL)
install(
TARGETS
${PROJECT_NAME}-shared
LIBRARY
DESTINATION
lib
DESTINATION
lib
)
endif ()
endif()
endif ()

if (WITH_INSTALL)
install(
DIRECTORY
${EXPORT_INCLUDES}/josepp
include/export/josepp
DESTINATION include
FILES_MATCHING PATTERN "*.hpp"
)
Expand All @@ -147,7 +151,7 @@ if (WITH_INSTALL)
)

install(FILES ${JOSEPP_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
endif()
endif ()

if (WITH_TESTS)
enable_testing()
Expand All @@ -156,27 +160,28 @@ if (WITH_TESTS)
include_directories(${PROJECT_SOURCE_DIR}/gtest/googletest/include)

set(JOSEPP_TEST_SRS
tests/b64.cpp
tests/claims.cpp
tests/ecdsa.cpp
tests/hmac.cpp
tests/rsa.cpp
tests/b64.cpp
tests/claims.cpp
tests/ecdsa.cpp
tests/hmac.cpp
tests/rsa.cpp
tests/pss.cpp
)

add_executable(josepp_test ${JOSEPP_TEST_SRS})

if (WIN32)
set(WIN32_DEP_LIBS crypt32.lib ws2_32.lib)
endif (WIN32)
if (WIN32)
set(WIN32_DEP_LIBS crypt32.lib ws2_32.lib)
endif (WIN32)

target_link_libraries(
josepp_test
gtest_main
${PROJECT_NAME}-static
${WIN32_DEP_LIBS}
${WIN32_DEP_LIBS}
)

add_test(UnitTests josepp_test)
endif()
endif ()


4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ JSON Object Signing and Encryption library for C++

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/da9665fd01ba4c759cef755d1ff03d2c)](https://www.codacy.com/app/troian/josepp?utm_source=github.com&utm_medium=referral&utm_content=troian/josepp&utm_campaign=badger)
[![Build Status](https://travis-ci.org/troian/josepp.svg?branch=master)](https://travis-ci.org/troian/josepp)
<a href="https://jwt.io"> <img src="https://jwt.io/img/badge-compatible.svg?sanitize=true" width="80"/></a>

#### Dependencies:
- [jsoncpp](https://github.com/open-source-parsers/jsoncpp)
Expand All @@ -28,6 +29,9 @@ JSON Object Signing and Encryption library for C++
| ES256 | **Supported** |
| ES384 | **Supported** |
| ES512 | **Supported** |
| PS256 | **Supported** |
| PS384 | **Supported** |
| PS512 | **Supported** |

#### Claims
|Claim|Options|Status|
Expand Down
2 changes: 1 addition & 1 deletion gtest
Submodule gtest updated 361 files
Loading

0 comments on commit 42d4c34

Please sign in to comment.