INCLUDE(GNUInstallDirs)
INCLUDE(FindPkgConfig)
INCLUDE(CheckLibraryExists)
-INCLUDE(GenerateExportHeader)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "RELEASE")
##Testing
-There are currently three general testing applications and one KONAI SE specific tool:
+There are currently two general testing applications and one KONAI SE specific tool:
- *dcm_api_test*
- *dcm_example_capi*
-- *dcm_example_client*
All testing applications should be executed after implementing changes to the DCM or to the DCM backend repository.
There is also one KONAI SE specific tool: *dcm_konaise_tool* used to test the KONAI SE backend implementation.
${PROTO_SRCS}
${PROTO_HDRS})
-GENERATE_EXPORT_HEADER(${TARGET_CLIENT}
- BASE_NAME DEVICE_CERTIFICATE_MANAGER
- PREFIX_NAME API_)
-
-
TARGET_LINK_LIBRARIES(${TARGET_CLIENT}
${Boost_SYSTEM_LIBRARY}
${PROTOBUF_LITE_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
SET_PROPERTY(TARGET ${TARGET_CLIENT} APPEND PROPERTY LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/version_script.lds")
-SET_PROPERTY(TARGET ${TARGET_CLIENT} PROPERTY DEFINE_SYMBOL DEVICE_CERTIFICATE_MANAGER_EXPORT)
-SET_PROPERTY(TARGET ${TARGET_CLIENT} PROPERTY VISIBILITY_INLINES_HIDDEN TRUE)
-SET_PROPERTY(TARGET ${TARGET_CLIENT} PROPERTY VERSION 2.0)
-SET_PROPERTY(TARGET ${TARGET_CLIENT} PROPERTY C_VISIBILITY_PRESET hidden)
-SET_PROPERTY(TARGET ${TARGET_CLIENT} PROPERTY CXX_VISIBILITY_PRESET hidden)
+SET_TARGET_PROPERTIES(${TARGET_CLIENT}
+ PROPERTIES
+ VERSION 2.0
+ DEFINE_SYMBOL DEVICE_CERTIFICATE_MANAGER_EXPORT
+ VISIBILITY_INLINES_HIDDEN TRUE
+ C_VISIBILITY_PRESET hidden
+ CXX_VISIBILITY_PRESET hidden)
INSTALL(TARGETS ${TARGET_CLIENT}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
INSTALL(FILES
- ${CMAKE_CURRENT_BINARY_DIR}/device_certificate_manager_export.h
- dcm_client.h
device_certificate_manager.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/device-certificate-manager)
/******************************************************************
*
- * Copyright 2017 - 2018 Samsung Electronics All Rights Reserved.
+ * Copyright 2017 - 2020 Samsung Electronics All Rights Reserved.
*
* Author: Jaroslaw Pelczar <j.pelczar@samsung.com>
*
#ifndef DCM_CLIENT_DCM_CLIENT_H_
#define DCM_CLIENT_DCM_CLIENT_H_
-#include "device_certificate_manager_export.h"
-
#include <mbedtls/md.h>
#include <memory>
#include <vector>
-class API_DEVICE_CERTIFICATE_MANAGER_EXPORT dcm_client_connection :
+class dcm_client_connection :
public std::enable_shared_from_this<dcm_client_connection>
{
private:
dcm_client_connection& operator = (const dcm_client_connection&) = delete;
protected:
- dcm_client_connection() API_DEVICE_CERTIFICATE_MANAGER_NO_EXPORT;
- ~dcm_client_connection() API_DEVICE_CERTIFICATE_MANAGER_NO_EXPORT;
+ dcm_client_connection();
+ ~dcm_client_connection();
public:
/*!
/******************************************************************
*
- * Copyright 2017 Samsung Electronics All Rights Reserved.
+ * Copyright 2017 - 2020 Samsung Electronics All Rights Reserved.
*
* Author: Jaroslaw Pelczar <j.pelczar@samsung.com>
*
#include <array>
#include <boost/asio.hpp>
-class API_DEVICE_CERTIFICATE_MANAGER_NO_EXPORT dcm_client_connection_impl final : public dcm_client_connection
+class dcm_client_connection_impl final : public dcm_client_connection
{
public:
dcm_client_connection_impl();
*
******************************************************************/
-#include "device_certificate_manager_export.h"
#include "device_certificate_manager.h"
#include "dcm_client.h"
#include <vector>
#include <cstring>
+#ifndef API_DEVICE_CERTIFICATE_MANAGER_EXPORT
+#define API_DEVICE_CERTIFICATE_MANAGER_EXPORT __attribute__((visibility("default")))
+#endif
+
#define LOG_TAG "DCM_CLIENT"
#include <dlog.h>
dcm_get_key_bit_length;
dcm_get_key_type;
dcm_create_signature;
- extern "C++" {
- dcm_client_connection::*;
- };
-
local:
*;
};
%package -n device-certificate-manager-devel
Summary: Device Certificate Manager (development)
Group: Security/Development
-Requires: pkgconfig(iotivity)
Requires: device-certificate-manager = %{version}-%{release}
%description -n device-certificate-manager-devel
%post
/sbin/ldconfig
systemctl daemon-reload
-systemctl restart device-certificate-manager.socket
-systemctl restart device-certificate-manager.service
+if [ $1 = 1 ]; then
+ # installation
+ systemctl start device-certificate-manager.socket device-certificate-manager.service
+fi
+
+if [ $1 = 2 ]; then
+ # update
+ systemctl stop device-certificate-manager.service device-certificate-manager.socket
+ systemctl start device-certificate-manager.socket device-certificate-manager.service
+fi
%preun
if [ $1 = 0 ]; then
- # unistall
- systemctl stop device-certificate-manager.service device-certificate-manager.socket
+ # unistall
+ systemctl stop device-certificate-manager.service device-certificate-manager.socket
fi
%postun
+/sbin/ldconfig
if [ $1 = 0 ]; then
- # unistall
- systemctl daemon-reload
+ # unistall
+ systemctl daemon-reload
fi
%files
%manifest %{name}.manifest
%license LICENSE
%{_libdir}/libdevice-certificate-manager.so
-%{_includedir}/device-certificate-manager/device_certificate_manager_export.h
-%{_includedir}/device-certificate-manager/dcm_client.h
%{_includedir}/device-certificate-manager/device_certificate_manager.h
%{_libdir}/pkgconfig/device-certificate-manager.pc
%license LICENSE
%{_bindir}/dcm_api_test
%{_bindir}/dcm_example_capi
-%{_bindir}/dcm_example_client
Name: device-certificate-manager
Description: Device Certificate Manager Package
Version: @VERSION@
-Requires: iotivity
Libs: -L${libdir} -ldevice-certificate-manager
Cflags: -I${includedir}/device-certificate-manager
INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
-INCLUDE_DIRECTORIES(../dcm-client ../shared ${CMAKE_BINARY_DIR}/dcm-client)
+INCLUDE_DIRECTORIES(../dcm-client)
ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
ADD_EXECUTABLE(dcm_example_capi example_capi.c)
TARGET_LINK_LIBRARIES(dcm_example_capi device-certificate-manager)
-ADD_EXECUTABLE(dcm_example_client example_client.cpp)
-TARGET_LINK_LIBRARIES(dcm_example_client device-certificate-manager)
-
ADD_EXECUTABLE(dcm_api_test api_test.cpp)
TARGET_LINK_LIBRARIES(dcm_api_test
device-certificate-manager
INSTALL(TARGETS
dcm_example_capi
- dcm_example_client
dcm_api_test
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2017 - 2019 Samsung Electronics All Rights Reserved.
- *
- * 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.
- *
- ******************************************************************/
-
-#include "dcm_client.h"
-#include <iostream>
-#include <iomanip>
-
-int main()
-{
- std::shared_ptr<dcm_client_connection> connection;
- try {
- connection = dcm_client_connection::create();
- } catch(std::exception& ex) {
- std::cerr << "Can't create connection: " << ex.what() << std::endl;
- return -1;
- }
-
- if(!connection->create_context("example_client", "test_usage", "")) {
- std::cerr << "Can't create context" << std::endl;
- return -1;
- }
-
- std::cout << "Using key type " << connection->key_type() << std::endl;
-
- std::vector<uint8_t> cert;
- connection->get_certificate_chain(cert);
-
- std::cout << "Cert is " << cert.size() << " bytes" << std::endl;
-
- cert.push_back('\0');
-
- std::cout << "Received cert " << ((const char *)&cert[0]) << std::endl;
-
- std::cout << "Private key is " << connection->key_length() << " bits" << std::endl;
- std::cout << "Private key is " << connection->key_type() << std::endl;
-
- std::vector<uint8_t> signature;
- if(connection->sign_data(MBEDTLS_MD_SHA256, "12345678901234567890123456789012", 32, signature) == 0) {
- for(auto v : signature) {
- std::cout << std::hex << std::setw(2) << (unsigned int)v << " ";
- }
- std::cout << std::endl;
- } else {
- std::cerr << "Signing failure" << std::endl;
- }
-
- return 0;
-}