--- /dev/null
+#
+# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Contact: Krzysztof Jackiewicz <k.jackiewicz@samsung.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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
+#
+#
+# @file CMakeLists.txt
+# @author Dariusz Michaluk (d.michaluk@samsung.com)
+#
+
+CMAKE_MINIMUM_REQUIRED (VERSION 2.6.2)
+
+PROJECT(owl)
+SET(VERSION "0.0.1")
+
+## pkgconfig ###################################################################
+INCLUDE(FindPkgConfig)
+
+## default CMAKE_INSTALL_* variables ###########################################
+INCLUDE(GNUInstallDirs)
+
+## Color output if it's possible:
+IF (( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9))
+ OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" ))
+
+ IF (OWL_BUILD_FORCE_COMPILER_COLORS)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
+ ENDIF()
+ENDIF()
+
+## Compiler flags, depending on the build type #################################
+IF(NOT CMAKE_BUILD_TYPE)
+ SET(CMAKE_BUILD_TYPE "DEBUG")
+ENDIF(NOT CMAKE_BUILD_TYPE)
+
+## Print build information #####################################################
+MESSAGE(STATUS "-------------------------------------------------")
+MESSAGE(STATUS "Compiler: " ${CMAKE_C_COMPILER_ID})
+MESSAGE(STATUS "Compiler version: " ${CMAKE_C_COMPILER_VERSION})
+MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
+MESSAGE(STATUS "-------------------------------------------------")
+
+SET(CMAKE_C_FLAGS_DEBUG "-std=c99 -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
+SET(CMAKE_C_FLAGS_RELEASE "-std=c99 -O2 -DNDEBUG")
+
+ADD_DEFINITIONS("-fPIC") # Position Independent Code
+ADD_DEFINITIONS("-Werror") # Make all warnings into errors
+ADD_DEFINITIONS("-Wall") # Generate all warnings
+#ADD_DEFINITIONS("-Wextra") # Generate even more extra warnings
+#ADD_DEFINITIONS("-pedantic") # Be pedantic
+#ADD_DEFINITIONS("-pedantic-errors") # Make pedantic warnings into errors
+ADD_DEFINITIONS(-DPROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}")
+
+IF("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+ # Warn about documentation problems
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdocumentation")
+ # Enable all diagnostics
+ #SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Weverything")
+ENDIF()
+
+## Subdirectories ##############################################################
+SET(API_FOLDER ${PROJECT_SOURCE_DIR}/api)
+SET(EXAMPLES_FOLDER ${PROJECT_SOURCE_DIR}/examples)
+SET(SRC_FOLDER ${PROJECT_SOURCE_DIR}/src)
+SET(TEST_FOLDER ${PROJECT_SOURCE_DIR}/test)
+
+IF(NOT DEFINED LIB_INSTALL_DIR)
+ SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
+ENDIF(NOT DEFINED LIB_INSTALL_DIR)
+
+IF(NOT DEFINED INCLUDE_INSTALL_DIR)
+ SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
+ENDIF(NOT DEFINED INCLUDE_INSTALL_DIR)
+
+ADD_SUBDIRECTORY(${SRC_FOLDER})
+#ADD_SUBDIRECTORY(${TEST_FOLDER})
+#ADD_SUBDIRECTORY(${EXAMPLES_FOLDER})
+++ /dev/null
-.PHONY: all build clean
-all: build
-
-build:
- make -C src
- make -C examples
-
-clean:
- make -C src clean
- make -C examples clean
*
* @param[in] algo Encryption algorithm.
* @param[in] bcm Chain mode.
- * @param[in] len Key length (@see owl_key_len_e).
+ * @param[in] key_len Key length (@see crypto_key_len_e).
*
* @return negative on error (@see error.h) or the IV length.
*/
--- /dev/null
+Name: owl
+Version: 0.0.1
+Release: 0
+Source0: %{name}-%{version}.tar.gz
+License: Apache-2.0
+Group: Security/Other
+Summary: Openssl wrapper layer
+BuildRequires: cmake
+BuildRequires: pkgconfig(openssl)
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+The package provides Openssl wrapper layer.
+
+%files
+%defattr(644,root,root,755)
+%{_libdir}/libowl.so.0
+%attr(755,root,root) %{_libdir}/libowl.so.%{version}
+
+%prep
+%setup -q
+
+%build
+%{!?build_type:%define build_type "RELEASE"}
+
+%cmake . -DCMAKE_BUILD_TYPE=%{build_type}
+make -k %{?jobs:-j%jobs}
+
+%install
+%make_install
+
+%clean
+rm -rf %{buildroot}
+
+%post -n owl -p /sbin/ldconfig
+
+%postun -n owl -p /sbin/ldconfig
+
+## Devel Package ###############################################################
+%package devel
+Summary: Development Openssl wrapper layer
+Group: Security/Other
+Requires: owl = %{version}-%{release}
+
+%description devel
+The package provides Openssl wrapper development layer.
+
+%files devel
+%defattr(644,root,root,755)
+%{_libdir}/libowl.so
+%{_includedir}/owl
+%{_libdir}/pkgconfig/owl.pc
--- /dev/null
+#
+# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Contact: Krzysztof Jackiewicz <k.jackiewicz@samsung.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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
+#
+#
+# @file CMakeLists.txt
+# @author Dariusz Michaluk (d.michaluk@samsung.com)
+#
+
+PROJECT(owl)
+
+MESSAGE(STATUS "")
+MESSAGE(STATUS "Generating makefile for the owl...")
+
+FILE(GLOB HEADERS ${API_FOLDER}/crypto/*.h)
+FILE(GLOB SRCS *.c *.h)
+
+SET(_LIB_VERSION_ "${VERSION}")
+SET(_LIB_SOVERSION_ "0")
+SET(PC_FILE "${PROJECT_NAME}.pc")
+
+## Set the default ELF image symbol visibility to hidden. Using this feature
+## can very substantially improve linking and load times of shared object
+## libraries, produce more optimized code, provide near-perfect API export
+## and prevent symbol clashes
+ADD_DEFINITIONS(-fvisibility=hidden)
+
+## Setup target ################################################################
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS} ${HEADERS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
+ SOVERSION ${_LIB_SOVERSION_}
+ VERSION ${_LIB_VERSION_}
+)
+
+## Link libraries ##############################################################
+PKG_CHECK_MODULES(OWL_DEPS REQUIRED openssl)
+
+INCLUDE_DIRECTORIES(${API_FOLDER})
+INCLUDE_DIRECTORIES(SYSTEM ${OWL_DEPS_INCLUDE_DIRS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${OWL_DEPS_LIBRARIES})
+
+## Generate the pc file ########################################################
+CONFIGURE_FILE(${PC_FILE}.in ${CMAKE_CURRENT_BINARY_DIR}/${PC_FILE} @ONLY)
+
+## Install #####################################################################
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PC_FILE}
+ DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+
+INSTALL(TARGETS ${PROJECT_NAME}
+ DESTINATION ${LIB_INSTALL_DIR}
+ COMPONENT RuntimeLibraries)
+
+INSTALL(FILES ${HEADERS}
+ DESTINATION ${INCLUDE_INSTALL_DIR}/owl)
+++ /dev/null
-# Sample makefile - for now it only checks if sources compile
-files := $(basename $(wildcard *.c))
-objs := $(addsuffix .o, $(files))
-deps := $(addsuffix .d, $(files))
-
-libs := libCryptoAPI.so libCryptoAPI.a
-
-LIBS := $(shell pkg-config --libs openssl)
-CFLAGS := $(shell pkg-config --cflags openssl) -I../api -Wall -MMD -fPIC -fvisibility=hidden
-
-.PHONY: all build clean
-all: build
-
-build: $(libs)
-
-clean:
- rm -f $(objs) $(deps) $(libs)
-
-%.so: $(objs)
- gcc $(LDFLAGS) $^ $(LIBS) -shared -o $@
-
-%.a: $(objs)
- ar rcs $@ $<
-
-%.o: %.c
- gcc $(CFLAGS) -c $< -o $@
-
--include $(deps)
--- /dev/null
+# Package Information for pkg-config
+
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@
+
+Name: owl
+Description: Openssl wrapper layer
+Version: @_LIB_VERSION_@
+Libs: -L${libdir} -l@PROJECT_NAME@
+Cflags: -I${includedir}