From: Krzysztof Jackiewicz Date: Mon, 27 Nov 2017 09:32:31 +0000 (+0100) Subject: Add dummy plugin X-Git-Tag: submit/tizen/20171201.152910~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=85edf6898cc316442a494e87ac10c5714b41e5fc;p=platform%2Fcore%2Fsecurity%2Fode.git Add dummy plugin Change-Id: Id817932002f094c13dc605f86bf911367e854bd5 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 51f5eb5..3e6a5f1 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ SET(ODE_KEY_STORAGE_PLUGIN ${PROJECT_SOURCE_DIR}/ode-key-storage-plugin) SET(ODE_SERVER ${PROJECT_SOURCE_DIR}/server) SET(ODE_TOOLS ${PROJECT_SOURCE_DIR}/tools) SET(ODE_TESTS ${PROJECT_SOURCE_DIR}/tests) +SET(ODE_DUMMY_KSP ${PROJECT_SOURCE_DIR}/dummy-ksp) IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) SET(CXX_STD "c++0x") @@ -102,3 +103,4 @@ ADD_SUBDIRECTORY(${ODE_KEY_STORAGE_PLUGIN}) ADD_SUBDIRECTORY(${ODE_SERVER}) ADD_SUBDIRECTORY(${ODE_TOOLS}) ADD_SUBDIRECTORY(${ODE_TESTS}) +ADD_SUBDIRECTORY(${ODE_DUMMY_KSP}) diff --git a/dummy-ksp/CMakeLists.txt b/dummy-ksp/CMakeLists.txt new file mode 100755 index 0000000..80eaef2 --- /dev/null +++ b/dummy-ksp/CMakeLists.txt @@ -0,0 +1,26 @@ +# +# Copyright (c) 2017 Samsung Electronics Co., Ltd 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. +# +SET(DUMMY_PLUGIN ${KEY_STORAGE_PLUGIN}) + +ADD_LIBRARY(${DUMMY_PLUGIN} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/main.c) + +TARGET_INCLUDE_DIRECTORIES(${DUMMY_PLUGIN} PRIVATE ${ODE_KEY_STORAGE_PLUGIN}) + +SET_TARGET_PROPERTIES(${DUMMY_PLUGIN} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") +SET_TARGET_PROPERTIES(${DUMMY_PLUGIN} PROPERTIES SOVERSION "0") +SET_TARGET_PROPERTIES(${DUMMY_PLUGIN} PROPERTIES VERSION "1") + +INSTALL(TARGETS ${DUMMY_PLUGIN} DESTINATION ${KEY_STORAGE_PLUGIN_DIR} COMPONENT DevelopmentLibraries) \ No newline at end of file diff --git a/dummy-ksp/main.c b/dummy-ksp/main.c new file mode 100644 index 0000000..91949e9 --- /dev/null +++ b/dummy-ksp/main.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd 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 + +#include +#include + +static int copy(const unsigned char* in, size_t in_len, + unsigned char** out, size_t* out_len) +{ + if (in == NULL || in_len == 0 || out == NULL || out_len == NULL) + return ODE_KSP_ERROR_INVALID_PARAMETER; + + *out = malloc(in_len * sizeof(unsigned char)); + if (*out == NULL) + return ODE_KSP_ERROR_UNKNOWN; + + memcpy(*out, in, in_len * sizeof(unsigned char)); + *out_len = in_len; + + return ODE_KSP_ERROR_NONE; +} + +int ode_ksp_store(const unsigned char* key, size_t key_len, + unsigned char** token, size_t* token_len) +{ + return copy(key, key_len, token, token_len); +} + +int ode_ksp_load(const unsigned char* token, size_t token_len, + unsigned char** key, size_t* key_len) +{ + return copy(token, token_len, key, key_len); +} + +int ode_ksp_remove(const unsigned char* token, size_t token_len) +{ + return ODE_KSP_ERROR_NONE; +} diff --git a/packaging/ode.spec b/packaging/ode.spec index 9ddb80b..bbd5c30 100755 --- a/packaging/ode.spec +++ b/packaging/ode.spec @@ -152,3 +152,17 @@ developing device encryption client program. %manifest ode.manifest %defattr(644,root,root,755) %attr(755,root,root) %{_bindir}/ode-engine-unit-tests + +## Dummy key storage plugin Package ########################################################### +%package dummy-ksp +Summary: Dummy key storage plugin for FOTA binary upgrade testing +Group: Security/Testing + +%description dummy-ksp +The ode-dummy-ksp package includes the dummy key storage plugin that can be used +for testing the binary upgrade process (FOTA). The plugin will be used by ode to +store the master encryption key in a file to use during FOTA process. + +%files dummy-ksp +%manifest ode.manifest +%attr(755,root,root) %{key_storage_plugin_dir}/*